libqi-api  release-2.5.3-2016-11-18
 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 
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 
66  static AnyValue makeVoid();
67 
68  ~AnyValue();
69  AnyValue& operator=(const AnyReference& b);
70  AnyValue& operator=(const AnyValue& b);
71 
72  void reset();
73  void reset(qi::TypeInterface *type);
74 
75  template <typename T>
76  void set(const T& t) { detail::AnyReferenceBase::set<T>(t); }
77 
78  void reset(const AnyReference& src);
79  void reset(const AnyReference& src, bool copy, bool free);
80 
81  void swap(AnyValue& b);
82 
84  //AnyRef == AnyRefBase
85  return *reinterpret_cast<const AnyReference*>(
86  static_cast<const detail::AnyReferenceBase*>(this));
87  }
88 
89  template<typename T>
90  static AnyValue from(const T& r) {
91  //explicit AutoAnyReference to avoid ambiguous call for object implementing cast to AnyValue
92  return AnyValue(AutoAnyReference(r));
93  }
94 
95  private:
96  //hide AnyReference::destroy
97  //simply assign an empty AnyValue.
98  void destroy() { return detail::AnyReferenceBase::destroy(); }
99 
100  //we dont accept GVP here. (block set<T> with T=GVP)
101  void set(const AnyReference& t);
102  bool _allocated;
103  };
104 
106  QI_API bool operator<(const AnyValue& a, const AnyValue& b);
107 
109  QI_API bool operator==(const AnyValue& a, const AnyValue& b);
110  QI_API bool operator!=(const AnyValue& a, const AnyValue& b);
111 
112  using AnyValueVector = std::vector<AnyValue>;
113 
115 
116 }
117 
119 
120 #endif // _QITYPE_DETAIL_ANYVALUE_HPP_
AnyReference release()
Definition: anyvalue.hpp:33
void destroy()
Stop and flush the logging system.
#define QI_API
Definition: api.hpp:33
static AnyValue from(const T &r)
Definition: anyvalue.hpp:90
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:83
void set(const T &t)
Definition: anyvalue.hpp:76
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:112