libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anyvalue.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QITYPE_DETAIL_ANYVALUE_HPP_
8 #define _QITYPE_DETAIL_ANYVALUE_HPP_
9 
10 namespace qi {
11 
20  {
21  public:
22 
27  AnyValue();
28  AnyValue(const AnyValue& b);
29  explicit AnyValue(const AnyReference& b, bool copy, bool free);
30  explicit AnyValue(const AutoAnyReference& b);
31  explicit AnyValue(qi::TypeInterface *type);
33  template<typename T> static AnyValue make();
34 
38  AnyReference ref = AnyReference(_type, _value);
39  _allocated = false;
40  _value = 0;
41  _type = 0;
42  return ref;
43  }
44 
46 
49  static AnyValue makeTuple(const AnyReferenceVector& values);
50  static AnyValue makeTupleFromValue(const AutoAnyReference& v0,
51  const AutoAnyReference& v1,
52  const AutoAnyReference& v2,
53  const AutoAnyReference& v3,
54  const AutoAnyReference& v4,
55  const AutoAnyReference& v5,
56  const AutoAnyReference& v6,
57  const AutoAnyReference& v7,
58  const AutoAnyReference& v8,
59  const AutoAnyReference& v9);
60 
61  template<typename T>
62  static AnyValue makeList(const AnyReferenceVector& values);
63  static AnyValue makeGenericList(const AnyReferenceVector& values);
64  template<typename K, typename V>
65  static AnyValue makeMap(const std::map<AnyReference, AnyReference>& values);
66  static AnyValue makeGenericMap(const std::map<AnyReference, AnyReference>& values);
68 
70  static AnyValue makeVoid();
71 
72  ~AnyValue();
73  AnyValue& operator=(const AnyReference& b);
74  AnyValue& operator=(const AnyValue& b);
75 
76  void reset();
77  void reset(qi::TypeInterface *type);
78 
79  template <typename T>
80  void set(const T& t) { detail::AnyReferenceBase::set<T>(t); }
81 
82  void reset(const AnyReference& src);
83  void reset(const AnyReference& src, bool copy, bool free);
84 
85  void swap(AnyValue& b);
86 
88  //AnyRef == AnyRefBase
89  return *reinterpret_cast<const AnyReference*>(
90  static_cast<const detail::AnyReferenceBase*>(this));
91  }
92 
93  template<typename T>
94  static AnyValue from(const T& r) {
95  //explicit AutoAnyReference to avoid ambiguous call for object implementing cast to AnyValue
96  return AnyValue(AutoAnyReference(r));
97  }
98 
99  private:
100  //hide AnyReference::destroy
101  //simply assign an empty AnyValue.
102  void destroy() { return detail::AnyReferenceBase::destroy(); }
103 
104  //we dont accept GVP here. (block set<T> with T=GVP)
105  void set(const AnyReference& t);
106  bool _allocated;
107  };
108 
110  QI_API bool operator<(const AnyValue& a, const AnyValue& b);
111 
113  QI_API bool operator==(const AnyValue& a, const AnyValue& b);
114  QI_API bool operator!=(const AnyValue& a, const AnyValue& b);
115 
116  using AnyValueVector = std::vector<AnyValue>;
117 
119 
120 }
121 
123 
124 #endif // _QITYPE_DETAIL_ANYVALUE_HPP_
AnyReference release()
Definition: anyvalue.hpp:37
void destroy()
Stop and flush the logging system.
#define QI_API
Definition: api.hpp:33
static AnyValue from(const T &r)
Definition: anyvalue.hpp:94
void destroy()
Deletes storage.
std::vector< AnyReference > AnyReferenceVector
bool operator==(const Signature &lhs, const Signature &rhs)
AnyReferenceVector asAnyReferenceVector(const AnyValueVector &vect)
Definition: anyvalue.hxx:222
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
Definition: anyfunction.hxx:92
AnyReference asReference() const
Definition: anyvalue.hpp:87
void set(const T &t)
Definition: anyvalue.hpp:80
T src(const std::atomic< T > &x)
Definition: atomic.hpp:318
bool operator<(const AnyReference &a, const AnyReference &b)
bool operator!=(const Signature &lhs, const Signature &rhs)
Definition: signature.hpp:157
std::vector< AnyValue > AnyValueVector
Definition: anyvalue.hpp:116