- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

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
19 class QI_API AnyValue: public detail::AnyReferenceBase
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
37 AnyReference release() {
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
87 AnyReference asReference() const {
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
118 inline AnyReferenceVector asAnyReferenceVector(const AnyValueVector& vect);
119
120 }
121
122 #include <qi/type/detail/anyvalue.hxx>
123
124 #endif // _QITYPE_DETAIL_ANYVALUE_HPP_
qi::AnyValue::release
AnyReference release()
Definition: anyvalue.hpp:37
qi::AnyValue
Definition: anyvalue.hpp:19
qi::log::destroy
void destroy()
Stop and flush the logging system.
QI_API
#define QI_API
Definition: api.hpp:33
anyvalue.hxx
qi::AnyReference
Definition: anyreference.hpp:360
qi::AnyValue::from
static AnyValue from(const T &r)
Definition: anyvalue.hpp:94
qi::detail::AnyReferenceBase::destroy
void destroy()
Deletes storage.
Definition: anyreference.hxx:34
qi::TypeInterface
Definition: typeinterface.hpp:129
qi::AnyReferenceVector
std::vector< AnyReference > AnyReferenceVector
Definition: anyreference.hpp:26
qi::operator==
bool operator==(const Signature &lhs, const Signature &rhs)
qi::asAnyReferenceVector
AnyReferenceVector asAnyReferenceVector(const AnyValueVector &vect)
Definition: anyvalue.hxx:222
std::swap
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
Definition: anyfunction.hxx:92
qi::AnyValue::asReference
AnyReference asReference() const
Definition: anyvalue.hpp:87
qi::detail::AnyReferenceBase
Definition: anyreference.hpp:40
qi::AnyValue::set
void set(const T &t)
Definition: anyvalue.hpp:80
qi::src
T src(const std::atomic< T > &x)
Definition: atomic.hpp:318
qi::AutoAnyReference
Definition: anyreference.hpp:409
qi::operator<
bool operator<(const AnyReference &a, const AnyReference &b)
qi::operator!=
bool operator!=(const Signature &lhs, const Signature &rhs)
Definition: signature.hpp:157
qi::AnyValueVector
std::vector< AnyValue > AnyValueVector
Definition: anyvalue.hpp:116