lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
CmpMap.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_CMPMAP_H
23 #define ASTSHIM_CMPMAP_H
24 
25 #include <memory>
26 #include <sstream>
27 #include <stdexcept>
28 
29 #include "astshim/base.h"
30 #include "astshim/detail/utils.h"
31 #include "astshim/Mapping.h"
32 
33 namespace ast {
34 
56 class CmpMap : public Mapping {
57  friend class Object;
58 
59 public:
73  explicit CmpMap(Mapping const &map1, Mapping const &map2, bool series, std::string const &options = "")
74  : Mapping(reinterpret_cast<AstMapping *>(astCmpMap(const_cast<AstObject *>(map1.getRawPtr()),
75  const_cast<AstObject *>(map2.getRawPtr()),
76  series, options.c_str()))) {}
77 
78  virtual ~CmpMap() {}
79 
80  CmpMap(CmpMap const &) = delete;
81  CmpMap(CmpMap &&) = default;
82  CmpMap & operator=(CmpMap const &) = delete;
83  CmpMap & operator=(CmpMap &&) = default;
84 
86  std::shared_ptr<CmpMap> copy() const {
87  return std::static_pointer_cast<CmpMap>(_copyPolymorphic());
88  }
89 
96  std::shared_ptr<Mapping> operator[](int i) const {
97  return _decompose<Mapping>(i, false);
98  };
99 
101  bool getSeries() { return detail::isSeries(reinterpret_cast<AstCmpMap *>(getRawPtr())); }
102 
103 protected:
106  explicit CmpMap(AstCmpMap * rawptr) :
107  Mapping(reinterpret_cast<AstMapping *>(rawptr))
108  {
109  if (!astIsACmpMap(getRawPtr())) {
110  std::ostringstream os;
111  os << "this is a " << getClass() << ", which is not a CmpMap";
112  throw std::invalid_argument(os.str());
113  }
114  }
115 };
116 
117 } // namespace ast
118 
119 #endif
CmpMap(Mapping const &map1, Mapping const &map2, bool series, std::string const &options="")
Definition: CmpMap.h:73
std::string getClass() const
Definition: Object.h:117
CmpMap(AstCmpMap *rawptr)
Definition: CmpMap.h:106
Definition: Mapping.h:59
Definition: Object.h:49
bool getSeries()
Return True if the map is in series.
Definition: CmpMap.h:101
Definition: CmpMap.h:56
std::shared_ptr< Mapping > operator[](int i) const
Definition: CmpMap.h:96
std::shared_ptr< CmpMap > copy() const
Return a deep copy of this object.
Definition: CmpMap.h:86
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: Mapping.h:450
AstObject const * getRawPtr() const
Definition: Object.h:260