libqi-api  2.4.3.28
 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_DETAILS_ANYVALUE_HPP_
8 #define _QITYPE_DETAILS_ANYVALUE_HPP_
9 
10 namespace qi {
11 
20  {
21  public:
22 
23  AnyValue();
24  AnyValue(const AnyValue& b);
25  explicit AnyValue(const AnyReference& b, bool copy, bool free);
26  explicit AnyValue(const AutoAnyReference& b);
27  explicit AnyValue(qi::TypeInterface *type);
29  template<typename T> static AnyValue make();
30 
34  AnyReference ref = AnyReference(_type, _value);
35  _allocated = false;
36  _value = 0;
37  _type = 0;
38  return ref;
39  }
40 
42 
45  static AnyValue makeTuple(const AnyReferenceVector& values);
46  static AnyValue makeTupleFromValue(const AutoAnyReference& v0,
47  const AutoAnyReference& v1,
48  const AutoAnyReference& v2,
49  const AutoAnyReference& v3,
50  const AutoAnyReference& v4,
51  const AutoAnyReference& v5,
52  const AutoAnyReference& v6,
53  const AutoAnyReference& v7,
54  const AutoAnyReference& v8,
55  const AutoAnyReference& v9);
56 
57  template<typename T>
58  static AnyValue makeList(const AnyReferenceVector& values);
59  static AnyValue makeGenericList(const AnyReferenceVector& values);
60  template<typename K, typename V>
61  static AnyValue makeMap(const std::map<AnyReference, AnyReference>& values);
62  static AnyValue makeGenericMap(const std::map<AnyReference, AnyReference>& values);
64 
65  ~AnyValue();
66  void operator=(const AnyReference& b);
67  void operator=(const AnyValue& b);
68 
69  void reset();
70  void reset(qi::TypeInterface *type);
71 
72  template <typename T>
73  void set(const T& t) { detail::AnyReferenceBase::set<T>(t); }
74 
75  void reset(const AnyReference& src);
76  void reset(const AnyReference& src, bool copy, bool free);
77 
78  void swap(AnyValue& b);
79 
81  //AnyRef == AnyRefBase
82  return *reinterpret_cast<const AnyReference*>(
83  static_cast<const detail::AnyReferenceBase*>(this));
84  }
85 
86  template<typename T>
87  static AnyValue from(const T& r) {
88  //explicit AutoAnyReference to avoid ambiguous call for object implementing cast to AnyValue
89  return AnyValue(AutoAnyReference(r));
90  }
91 
92  private:
93  //hide AnyReference::destroy
94  //simply assign an empty AnyValue.
95  void destroy() { return detail::AnyReferenceBase::destroy(); }
96 
97  //we dont accept GVP here. (block set<T> with T=GVP)
98  void set(const AnyReference& t);
99  bool _allocated;
100  };
101 
103  QI_API bool operator<(const AnyValue& a, const AnyValue& b);
104 
106  QI_API bool operator==(const AnyValue& a, const AnyValue& b);
107  QI_API bool operator!=(const AnyValue& a, const AnyValue& b);
108 
109  typedef std::vector<AnyValue> AnyValueVector;
110 
112 
113 }
114 
116 
117 #endif // _QITYPE_DETAILS_ANYVALUE_HPP_
AnyReference release()
Definition: anyvalue.hpp:33
void destroy()
Stop and flush the logging system.
#define QI_API
Definition: api.hpp:34
static AnyValue from(const T &r)
Definition: anyvalue.hpp:87
void destroy()
Deletes storage.
std::vector< AnyReference > AnyReferenceVector
bool operator==(const Signature &lhs, const Signature &rhs)
AnyReferenceVector asAnyReferenceVector(const AnyValueVector &vect)
Definition: anyvalue.hxx:212
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
Definition: anyfunction.hxx:89
AnyReference asReference() const
Definition: anyvalue.hpp:80
void set(const T &t)
Definition: anyvalue.hpp:73
bool operator<(const AnyReference &a, const AnyReference &b)
bool operator!=(const Signature &lhs, const Signature &rhs)
Definition: signature.hpp:154
std::vector< AnyValue > AnyValueVector
Definition: anyvalue.hpp:109