lsst.astshim  master-gd0c6fad5f5+1
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
LutMap.h
1 /*
2  * LSST Data Management System
3  * Copyright 2017 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 
65 public:
77  explicit LutMap(std::vector<double> const &lut, double start, double inc, std::string const &options = "")
78  : Mapping(reinterpret_cast<AstMapping *>(
79  astLutMap(lut.size(), lut.data(), start, inc, "%s", options.c_str()))) {}
80 
81  virtual ~LutMap() {}
82 
83  LutMap(LutMap const &) = delete;
84  LutMap(LutMap &&) = default;
85  LutMap &operator=(LutMap const &) = delete;
86  LutMap &operator=(LutMap &&) = default;
87 
89  std::shared_ptr<LutMap> copy() const { return std::static_pointer_cast<LutMap>(copyPolymorphic()); }
90 
94  double getLutEpsilon() const { return getD("LutEpsilon"); }
95 
99  int getLutInterp() const { return getI("LutInterp"); }
100 
101 protected:
102  virtual std::shared_ptr<Object> copyPolymorphic() const override {
103  return copyImpl<LutMap, AstLutMap>();
104  }
105 
107  explicit LutMap(AstLutMap *rawptr) : Mapping(reinterpret_cast<AstMapping *>(rawptr)) {
108  if (!astIsALutMap(getRawPtr())) {
109  std::ostringstream os;
110  os << "this is a " << getClassName() << ", which is not a LutMap";
111  throw std::invalid_argument(os.str());
112  }
113  }
114 };
115 
116 } // namespace ast
117 
118 #endif
int getLutInterp() const
Definition: LutMap.h:99
Definition: LutMap.h:62
std::shared_ptr< LutMap > copy() const
Return a deep copy of this object.
Definition: LutMap.h:89
Definition: Mapping.h:59
Definition: Object.h:49
virtual std::shared_ptr< Object > copyPolymorphic() const override
Definition: LutMap.h:102
double getD(std::string const &attrib) const
Definition: Object.h:357
double getLutEpsilon() const
Definition: LutMap.h:94
LutMap(AstLutMap *rawptr)
Construct an LutMap from a raw AST pointer.
Definition: LutMap.h:107
int getI(std::string const &attrib) const
Definition: Object.h:383
LutMap(std::vector< double > const &lut, double start, double inc, std::string const &options="")
Definition: LutMap.h:77
std::string getClassName() const
Definition: Object.h:118
AstObject const * getRawPtr() const
Definition: Object.h:270