Pothos  0.4.3-gabce2ce6
The Pothos dataflow programming software suite
DType.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
13 #include <typeinfo>
14 #include <string>
15 
16 namespace Pothos {
17 
39 {
40 public:
41 
43  DType(void);
44 
50  DType(const char *markup);
51 
63  DType(const std::string &markup);
64 
71  DType(const std::string &alias, const size_t dimension);
72 
80  DType(const std::type_info &type, const size_t dimension = 1);
81 
88  static DType fromDType(const DType &dtype, const size_t dimension);
89 
94  const std::string &name(void) const;
95 
97  size_t elemType(void) const;
98 
100  size_t elemSize(void) const;
101 
103  size_t dimension(void) const;
104 
106  size_t size(void) const;
107 
109  std::string toString(void) const;
110 
115  std::string toMarkup(void) const;
116 
121  explicit operator bool(void) const;
122 
127  bool isCustom(void) const;
128 
133  bool isFloat(void) const;
134 
139  bool isInteger(void) const;
140 
145  bool isSigned(void) const;
146 
151  bool isComplex(void) const;
152 
154  template<class Archive>
155  void serialize(Archive & ar, const unsigned int version);
156 
157 private:
158  size_t _elemType;
159  size_t _elemSize;
160  size_t _dimension;
161 };
162 
164 POTHOS_API bool operator==(const DType &lhs, const DType &rhs);
165 
166 } //namespace Pothos
167 
168 inline bool Pothos::operator==(const DType &lhs, const DType &rhs)
169 {
170  return lhs.elemType() == rhs.elemType() and
171  lhs.elemSize() == rhs.elemSize() and
172  lhs.dimension() == rhs.dimension();
173 }
174 
175 inline Pothos::DType::DType(void):
176  _elemType(0),
177  _elemSize(1),
178  _dimension(1)
179 {
180  return;
181 }
182 
183 inline size_t Pothos::DType::elemType(void) const
184 {
185  return _elemType;
186 }
187 
188 inline size_t Pothos::DType::elemSize(void) const
189 {
190  return _elemSize;
191 }
192 
193 inline size_t Pothos::DType::dimension(void) const
194 {
195  return _dimension;
196 }
197 
198 inline size_t Pothos::DType::size(void) const
199 {
200  return _elemSize*_dimension;
201 }
202 
203 inline Pothos::DType::operator bool(void) const
204 {
205  return _elemType != 0;
206 }
#define POTHOS_API
Definition: Config.hpp:41
POTHOS_API bool operator==(const Callable &lhs, const Callable &rhs)
DType(void)
Create an unknown DType of size 1.
Definition: DType.hpp:175
size_t dimension(void) const
Get the dimensionality of this type.
Definition: DType.hpp:193
Definition: CallInterface.hpp:15
size_t elemType(void) const
Get the element type descriptor.
Definition: DType.hpp:183
size_t elemSize(void) const
Get the size of a single element in bytes.
Definition: DType.hpp:188
void serialize(Archive &, Pothos::Detail::ObjectContainer &, const unsigned int)
Definition: Serialize.hpp:46
size_t size(void) const
Get the size of this DType in bytes.
Definition: DType.hpp:198
Definition: DType.hpp:38