lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
RateMap.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_RATEMAP_H
23 #define ASTSHIM_RATEMAP_H
24 
25 #include <algorithm>
26 
27 #include "astshim/base.h"
28 #include "astshim/Mapping.h"
29 
30 namespace ast {
31 
53 class RateMap: public Mapping {
54 friend class Object;
55 public:
70  explicit RateMap(Mapping const &map, int ax1, int ax2, std::string const &options = "")
71  : Mapping(reinterpret_cast<AstMapping *>(
72  astRateMap(const_cast<AstObject *>(map.getRawPtr()), ax1, ax2, options.c_str()))) {}
73 
74  virtual ~RateMap() {}
75 
76  RateMap(RateMap const &) = delete;
77  RateMap(RateMap &&) = default;
78  RateMap & operator=(RateMap const &) = delete;
79  RateMap & operator=(RateMap &&) = default;
80 
82  std::shared_ptr<RateMap> copy() const {
83  return std::static_pointer_cast<RateMap>(_copyPolymorphic());
84  }
85 
86 protected:
87  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
88  return _copyImpl<RateMap, AstRateMap>();
89  }
90 
92  explicit RateMap(AstRateMap * rawptr) :
93  Mapping(reinterpret_cast<AstMapping *>(rawptr))
94  {
95  if (!astIsARateMap(getRawPtr())) {
96  std::ostringstream os;
97  os << "this is a " << getClass() << ", which is not a RateMap";
98  throw std::invalid_argument(os.str());
99  }
100  }
101 };
102 
103 } // namespace ast
104 
105 #endif
Definition: RateMap.h:53
RateMap(Mapping const &map, int ax1, int ax2, std::string const &options="")
Definition: RateMap.h:70
std::string getClass() const
Definition: Object.h:117
Definition: Mapping.h:59
Definition: Object.h:49
std::shared_ptr< RateMap > copy() const
Return a deep copy of this object.
Definition: RateMap.h:82
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: RateMap.h:87
RateMap(AstRateMap *rawptr)
Construct a RateMap from a raw AST pointer.
Definition: RateMap.h:92
AstObject const * getRawPtr() const
Definition: Object.h:260