lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
TimeMap.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_TIMEMAP_H
23 #define ASTSHIM_TIMEMAP_H
24 
25 #include <memory>
26 #include <sstream>
27 #include <stdexcept>
28 #include <vector>
29 
30 #include "astshim/base.h"
31 #include "astshim/Mapping.h"
32 
33 namespace ast {
34 
40 class TimeMap : public Mapping {
41 friend class Object;
42 public:
55  explicit TimeMap(std::string const & options="") :
56  Mapping(reinterpret_cast<AstMapping *>(astTimeMap(0, options.c_str())))
57  {}
58 
59  virtual ~TimeMap() {}
60 
61  TimeMap(TimeMap const &) = delete;
62  TimeMap(TimeMap &&) = default;
63  TimeMap & operator=(TimeMap const &) = delete;
64  TimeMap & operator=(TimeMap &&) = default;
65 
67  std::shared_ptr<TimeMap> copy() const {
68  return std::static_pointer_cast<TimeMap>(_copyPolymorphic());
69  }
70 
182  void add(std::string const & cvt, std::vector<double> const & args) {
183  astTimeAdd(getRawPtr(), cvt.c_str(), args.size(), args.data());
184  assertOK();
185  }
186 
187 protected:
188  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
189  return _copyImpl<TimeMap, AstTimeMap>();
190  }
191 
193  explicit TimeMap(AstTimeMap * rawptr) :
194  Mapping(reinterpret_cast<AstMapping *>(rawptr))
195  {
196  if (!astIsATimeMap(getRawPtr())) {
197  std::ostringstream os;
198  os << "this is a " << getClass() << ", which is not a TimeMap";
199  throw std::invalid_argument(os.str());
200  }
201  }
202 };
203 
204 } // namespace ast
205 
206 #endif
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: TimeMap.h:188
TimeMap(std::string const &options="")
Definition: TimeMap.h:55
TimeMap(AstTimeMap *rawptr)
Construct a TimeMap from a raw AST pointer.
Definition: TimeMap.h:193
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Definition: base.cc:53
std::string getClass() const
Definition: Object.h:117
void add(std::string const &cvt, std::vector< double > const &args)
Definition: TimeMap.h:182
Definition: Mapping.h:59
Definition: Object.h:49
std::shared_ptr< TimeMap > copy() const
Return a deep copy of this object.
Definition: TimeMap.h:67
Definition: TimeMap.h:40
AstObject const * getRawPtr() const
Definition: Object.h:260