lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
UnitMap.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_UNITMAP_H
23 #define ASTSHIM_UNITMAP_H
24 
25 #include <memory>
26 
27 #include "astshim/base.h"
28 #include "astshim/Mapping.h"
29 
30 namespace ast {
31 
44 class UnitMap: public Mapping {
45 friend class Object;
46 public:
53  explicit UnitMap(int ncoord, std::string const & options="") :
54  Mapping(reinterpret_cast<AstMapping *>(astUnitMap(ncoord, options.c_str())))
55  {}
56 
57  virtual ~UnitMap() {}
58 
59  UnitMap(UnitMap const &) = delete;
60  UnitMap(UnitMap &&) = default;
61  UnitMap & operator=(UnitMap const &) = delete;
62  UnitMap & operator=(UnitMap &&) = default;
63 
65  std::shared_ptr<UnitMap> copy() const {
66  return std::static_pointer_cast<UnitMap>(_copyPolymorphic());
67  }
68 
69 protected:
70  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
71  return _copyImpl<UnitMap, AstUnitMap>();
72  }
73 
75  explicit UnitMap(AstUnitMap * rawptr) :
76  Mapping(reinterpret_cast<AstMapping *>(rawptr))
77  {
78  if (!astIsAUnitMap(getRawPtr())) {
79  std::ostringstream os;
80  os << "this is a " << getClass() << ", which is not a UnitMap";
81  throw std::invalid_argument(os.str());
82  }
83  }
84 };
85 
86 } // namespace ast
87 
88 #endif
std::shared_ptr< UnitMap > copy() const
Return a deep copy of this object.
Definition: UnitMap.h:65
std::string getClass() const
Definition: Object.h:117
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: UnitMap.h:70
Definition: Mapping.h:59
Definition: Object.h:49
UnitMap(AstUnitMap *rawptr)
Construct a UnitMap from a raw AST pointer.
Definition: UnitMap.h:75
UnitMap(int ncoord, std::string const &options="")
Definition: UnitMap.h:53
Definition: UnitMap.h:44
AstObject const * getRawPtr() const
Definition: Object.h:260