libqi-api  2.8.7.4
 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 
12 
13 namespace qi
14 {
16  : _resultType(0)
17  {
18  }
19 
21  {
22  return _resultType;
23  }
24 
25  inline const std::vector<TypeInterface*>& CallableTypeInterface::argumentsType()
26  {
27  return _argumentsType;
28  }
29 
31  {
32  return call(args);
33  }
34 
36  : type(0), value(0)
37  {}
38 
40  {
41  type = b.type;
42  value = type?type->clone(b.value):0;
43  transform = b.transform;
44  }
45 
47  : type(type)
48  , value(value)
49  {
50  }
51 
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 
65  {
66  if (type)
67  type->destroy(value);
68  }
69 
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 
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_
AnyReference call(const AnyReferenceVector &args)
FunctionTypeInterface * functionType() const
Definition: anyfunction.hxx:82
AnyFunction & operator=(const AnyFunction &b)
Definition: anyfunction.hxx:52
AnyReference operator()(const AnyReferenceVector &args)
Call the function, reference must be destroy()ed.
Definition: anyfunction.hxx:30
const std::vector< TypeInterface * > & argumentsType()
Definition: anyfunction.hxx:25
std::vector< AnyReference > AnyReferenceVector
void swap(::qi::AnyFunction &a,::qi::AnyFunction &b)
Definition: anyfunction.hxx:92
virtual void destroy(void *)=0
Free all resources of a storage.
TypeInterface * _resultType
Definition: anyfunction.hpp:83
TypeInterface * resultType()
Definition: anyfunction.hxx:20
void swap(AnyFunction &b)
Definition: anyfunction.hxx:70
virtual void * clone(void *)=0
Allocate a storage and copy the value given as an argument.
std::vector< TypeInterface * > _argumentsType
Definition: anyfunction.hpp:85