- 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
anyfunction.hxx
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_ANYFUNCTION_HXX_
8 #define _QITYPE_DETAIL_ANYFUNCTION_HXX_
9
10 #include <qi/type/detail/anyvalue.hpp>
11 #include <qi/type/detail/bindtype.hxx>
12
13 namespace qi
14 {
15 inline CallableTypeInterface::CallableTypeInterface()
16 : _resultType(0)
17 {
18 }
19
20 inline TypeInterface* CallableTypeInterface::resultType()
21 {
22 return _resultType;
23 }
24
25 inline const std::vector<TypeInterface*>& CallableTypeInterface::argumentsType()
26 {
27 return _argumentsType;
28 }
29
30 inline AnyReference AnyFunction::operator()(const AnyReferenceVector& args)
31 {
32 return call(args);
33 }
34
35 inline AnyFunction::AnyFunction()
36 : type(0), value(0)
37 {}
38
39 inline AnyFunction::AnyFunction(const AnyFunction& b)
40 {
41 type = b.type;
42 value = type?type->clone(b.value):0;
43 transform = b.transform;
44 }
45
46 inline AnyFunction::AnyFunction(FunctionTypeInterface* type, void* value)
47 : type(type)
48 , value(value)
49 {
50 }
51
52 inline AnyFunction& AnyFunction::operator=(const AnyFunction& b)
53 {
54 if (this == &b)
55 return *this;
56
57 this->~AnyFunction();
58 type = b.type;
59 value = type?type->clone(b.value):0;
60 transform = b.transform;
61 return *this;
62 }
63
64 inline AnyFunction::~AnyFunction()
65 {
66 if (type)
67 type->destroy(value);
68 }
69
70 inline void AnyFunction::swap(AnyFunction& b)
71 {
72 std::swap(value, b.value);
73 std::swap(type, b.type);
74 std::swap(transform, b.transform);
75 }
76
77 inline AnyFunction::operator bool() const
78 {
79 return type != 0;
80 }
81
82 inline FunctionTypeInterface* AnyFunction::functionType() const
83 {
84 return type;
85 }
86
87
88 } // namespace qi
89
90 namespace std
91 {
92 template<> inline void swap(::qi::AnyFunction& a, ::qi::AnyFunction & b)
93 {
94 a.swap(b);
95 }
96 }
97
98 #endif // _QITYPE_DETAIL_ANYFUNCTION_HXX_
qi::AnyFunction::call
AnyReference call(const AnyReferenceVector &args)
bindtype.hxx
qi::AnyFunction
Definition: anyfunction.hpp:149
qi::AnyReference
Definition: anyreference.hpp:360
qi::AnyFunction::functionType
FunctionTypeInterface * functionType() const
Definition: anyfunction.hxx:82
qi::AnyFunction::AnyFunction
AnyFunction()
Definition: anyfunction.hxx:35
qi::AnyFunction::operator=
AnyFunction & operator=(const AnyFunction &b)
Definition: anyfunction.hxx:52
qi::AnyFunction::operator()
AnyReference operator()(const AnyReferenceVector &args)
Call the function, reference must be destroy()ed.
Definition: anyfunction.hxx:30
qi::TypeInterface
Definition: typeinterface.hpp:129
qi::AnyFunction::~AnyFunction
~AnyFunction()
Definition: anyfunction.hxx:64
qi::CallableTypeInterface::argumentsType
const std::vector< TypeInterface * > & argumentsType()
Definition: anyfunction.hxx:25
qi::FunctionTypeInterface
Definition: anyfunction.hpp:88
qi::AnyReferenceVector
std::vector< AnyReference > AnyReferenceVector
Definition: anyreference.hpp:26
std::swap
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
Definition: anyfunction.hxx:92
qi::TypeInterface::destroy
virtual void destroy(void *)=0
Free all resources of a storage.
qi::CallableTypeInterface::_resultType
TypeInterface * _resultType
Definition: anyfunction.hpp:83
qi::CallableTypeInterface::resultType
TypeInterface * resultType()
Definition: anyfunction.hxx:20
qi::AnyFunction::swap
void swap(AnyFunction &b)
Definition: anyfunction.hxx:70
qi::TypeInterface::clone
virtual void * clone(void *)=0
Allocate a storage and copy the value given as an argument.
qi::CallableTypeInterface::CallableTypeInterface
CallableTypeInterface()
Definition: anyfunction.hxx:15
qi::CallableTypeInterface::_argumentsType
std::vector< TypeInterface * > _argumentsType
Definition: anyfunction.hpp:85
anyvalue.hpp