lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
base.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_BASE_H
23 #define ASTSHIM_BASE_H
24 
25 #include <string>
26 #include <stdexcept>
27 #include <vector>
28 
29 #include "ndarray.h"
30 
31 extern "C" {
32 #include "ast.h"
33 }
34 
35 // Do not delete this or free functions and enums will not be documented
37 namespace ast {
38 
44 class notfound_error : public std::runtime_error {
45 public:
47  notfound_error(std::string const &msg) : std::runtime_error(msg){};
48 };
49 
50 using Array2D = ndarray::Array<double, 2, 2>;
51 using ConstArray2D = ndarray::Array<double const, 2, 2>;
52 using PointI = std::vector<int>;
53 using PointD = std::vector<double>;
54 
55 enum class DataType {
56  IntType = AST__INTTYPE,
57  ShortIntType = AST__SINTTYPE,
58  ByteType = AST__BYTETYPE,
59  DoubleType = AST__DOUBLETYPE,
60  FloatType = AST__FLOATTYPE,
61  StringType = AST__STRINGTYPE,
62  ObjectType = AST__OBJECTTYPE,
63  PointerType = AST__POINTERTYPE,
64  UndefinedType = AST__UNDEFTYPE,
65  BadType = AST__BADTYPE
66 };
67 
79 ConstArray2D arrayFromVector(std::vector<double> const &vec, int nAxes);
80 
81 Array2D arrayFromVector(std::vector<double> &vec, int nAxes);
82 
92 void assertOK(AstObject *rawPtr1 = nullptr, AstObject *rawPtr2 = nullptr);
93 
124 inline bool escapes(int include = -1) {
125  assertOK();
126  int ret = astEscapes(include);
127  assertOK();
128  return ret;
129 }
130 
131 } // namespace ast
132 
133 #endif
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Definition: base.cc:53
Definition: base.h:44
bool escapes(int include=-1)
Definition: base.h:124
notfound_error(std::string const &msg)
Construct a notfound_error with a specified error message.
Definition: base.h:47
ConstArray2D arrayFromVector(std::vector< double > const &vec, int nAxes)
Definition: base.cc:69