Pothos  0.1.1
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
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 
86  const std::string &name(void) const;
87 
89  size_t elemType(void) const;
90 
92  size_t elemSize(void) const;
93 
95  size_t dimension(void) const;
96 
98  size_t size(void) const;
99 
101  std::string toString(void) const;
102 
107  std::string toMarkup(void) const;
108 
113  pothos_explicit operator bool(void) const;
114 
119  bool isCustom(void) const;
120 
125  bool isFloat(void) const;
126 
131  bool isInteger(void) const;
132 
137  bool isSigned(void) const;
138 
143  bool isComplex(void) const;
144 
146  template<class Archive>
147  void serialize(Archive & ar, const unsigned int version);
148 
149 private:
150  size_t _elemType;
151  size_t _elemSize;
152  size_t _dimension;
153 };
154 
156 POTHOS_API bool operator==(const DType &lhs, const DType &rhs);
157 
158 } //namespace Pothos
159 
160 inline bool Pothos::operator==(const DType &lhs, const DType &rhs)
161 {
162  return lhs.elemType() == rhs.elemType() and
163  lhs.elemSize() == rhs.elemSize() and
164  lhs.dimension() == rhs.dimension();
165 }
166 
167 inline Pothos::DType::DType(void):
168  _elemType(0),
169  _elemSize(1),
170  _dimension(1)
171 {
172  return;
173 }
174 
175 inline size_t Pothos::DType::elemType(void) const
176 {
177  return _elemType;
178 }
179 
180 inline size_t Pothos::DType::elemSize(void) const
181 {
182  return _elemSize;
183 }
184 
185 inline size_t Pothos::DType::dimension(void) const
186 {
187  return _dimension;
188 }
189 
190 inline size_t Pothos::DType::size(void) const
191 {
192  return _elemSize*_dimension;
193 }
194 
195 inline Pothos::DType::operator bool(void) const
196 {
197  return _elemType != 0;
198 }
#define pothos_explicit
Definition: Config.hpp:85
#define POTHOS_API
Definition: Config.hpp:41
DType(void)
Create an empty DType with blank name, empty shape, and size 0.
Definition: DType.hpp:167
size_t dimension(void) const
Get the dimensionality of this type.
Definition: DType.hpp:185
bool operator==(const ManagedBuffer &lhs, const ManagedBuffer &rhs)
Definition: ManagedBuffer.hpp:132
size_t elemType(void) const
Get the element type descriptor.
Definition: DType.hpp:175
size_t elemSize(void) const
Get the size of a single element in bytes.
Definition: DType.hpp:180
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:190
Definition: DType.hpp:38