lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
LutMap.h
1 /*
2  * LSST Data Management System
3  * Copyright 2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #ifndef ASTSHIM_LUTMAP_H
23 #define ASTSHIM_LUTMAP_H
24 
25 #include <memory>
26 
27 #include "astshim/base.h"
28 #include "astshim/Mapping.h"
29 
30 namespace ast {
31 
62 class LutMap : public Mapping {
63 friend class Object;
64 public:
76  explicit LutMap(std::vector<double> const & lut, double start, double inc, std::string const & options="")
77  :
78  Mapping(reinterpret_cast<AstMapping *>(
79  astLutMap(lut.size(), lut.data(), start, inc, options.c_str())
80  ))
81  {}
82 
83  virtual ~LutMap() {}
84 
85  LutMap(LutMap const &) = delete;
86  LutMap(LutMap &&) = default;
87  LutMap & operator=(LutMap const &) = delete;
88  LutMap & operator=(LutMap &&) = default;
89 
91  std::shared_ptr<LutMap> copy() const {
92  return std::static_pointer_cast<LutMap>(_copyPolymorphic());
93  }
94 
98  double getLutEpsilon() const { return getD("LutEpsilon"); }
99 
103  int getLutInterp() const { return getI("LutInterp"); }
104 
105 protected:
106  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
107  return _copyImpl<LutMap, AstLutMap>();
108  }
109 
111  explicit LutMap(AstLutMap * rawptr) :
112  Mapping(reinterpret_cast<AstMapping *>(rawptr))
113  {
114  if (!astIsALutMap(getRawPtr())) {
115  std::ostringstream os;
116  os << "this is a " << getClass() << ", which is not a LutMap";
117  throw std::invalid_argument(os.str());
118  }
119  }
120 };
121 
122 } // namespace ast
123 
124 #endif
int getLutInterp() const
Definition: LutMap.h:103
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: LutMap.h:106
Definition: LutMap.h:62
std::string getClass() const
Definition: Object.h:117
std::shared_ptr< LutMap > copy() const
Return a deep copy of this object.
Definition: LutMap.h:91
Definition: Mapping.h:59
Definition: Object.h:49
double getD(std::string const &attrib) const
Definition: Object.h:360
double getLutEpsilon() const
Definition: LutMap.h:98
LutMap(AstLutMap *rawptr)
Construct an LutMap from a raw AST pointer.
Definition: LutMap.h:111
int getI(std::string const &attrib) const
Definition: Object.h:386
LutMap(std::vector< double > const &lut, double start, double inc, std::string const &options="")
Definition: LutMap.h:76
AstObject const * getRawPtr() const
Definition: Object.h:260