Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
Object.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
14 #include <typeinfo>
15 #include <string>
16 
17 namespace Pothos {
18 
19 //messy forward declares
20 namespace Detail {
21 struct ObjectContainer;
22 } //namespace Detail
23 
30 {
31 public:
32  NullObject(void);
33  ~NullObject(void);
34 };
35 
48 {
49 public:
50 
54  Object(void);
55 
65  template <typename ValueType>
66  static Object make(ValueType &&value);
67 
77  template <typename ValueType, typename... Args>
78  static Object emplace(Args&&... args);
79 
85  Object(const Object &obj);
86 
92  Object(Object &&obj) noexcept;
93 
98  template <typename ValueType, typename = Pothos::Util::disable_if_same<Object, ValueType>>
99  explicit Object(ValueType &&value);
100 
102  template <typename T> struct Emplace
103  {
104  explicit Emplace() = default;
105  };
106 
112  template <typename ValueType, typename... Args>
113  explicit Object(Emplace<ValueType>, Args&&... args);
114 
118  explicit Object(const char *);
119 
125  ~Object(void);
126 
133  Object &operator=(const Object &rhs);
134 
141  Object &operator=(Object &&rhs);
142 
147  explicit operator bool(void) const;
148 
153  bool unique(void) const;
154 
159  const std::type_info &type(void) const;
160 
167  template <typename ValueType>
168  const ValueType &extract(void) const;
169 
185  template <typename ValueType>
186  ValueType &ref(void);
187 
195  template <typename ValueType>
196  ValueType convert(void) const;
197 
202  template <typename ValueType>
203  operator ValueType(void) const;
204 
211  Object convert(const std::type_info &type) const;
212 
218  bool canConvert(const std::type_info &type) const;
219 
226  static bool canConvert(const std::type_info &srcType, const std::type_info &dstType);
227 
234  std::ostream &serialize(std::ostream &os) const;
235 
243  std::istream &deserialize(std::istream &is);
244 
252  int compareTo(const Object &other) const;
253 
258  size_t hashCode(void) const;
259 
264  std::string toString(void) const;
265 
269  std::string getTypeString(void) const;
270 
276  bool equals(const Object &obj) const;
277 
283  bool operator<(const Object &obj) const;
284 
290  bool operator>(const Object &obj) const;
291 
293  Detail::ObjectContainer *_impl;
294 };
295 
303 inline bool operator==(const Object &lhs, const Object &rhs);
304 
305 } //namespace Pothos
306 
307 inline bool Pothos::operator==(const Object &lhs, const Object &rhs)
308 {
309  return lhs._impl == rhs._impl;
310 }
311 
312 inline Pothos::Object::Object(Object &&obj) noexcept:
313  _impl(obj._impl)
314 {
315  obj._impl = nullptr;
316 }
Emplace dummy type to pass type to Object emplacement constructor.
Definition: Object.hpp:102
#define POTHOS_API
Definition: Config.hpp:41
POTHOS_API bool operator==(const Callable &lhs, const Callable &rhs)
Definition: ArchiveEntry.hpp:20
Detail::ObjectContainer * _impl
Private implementation details.
Definition: Object.hpp:293
Definition: Object.hpp:47
void serialize(Archive &ar, std::complex< T > &t, const unsigned int ver)
Definition: Complex.hpp:37
int compareTo(const T0 &v0, const T1 &v1)
Definition: CompareTo.hpp:27
Definition: Object.hpp:29