libqi-api  2.4.3.28
 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_DETAILS_ANYFUNCTION_HXX_
8 #define _QITYPE_DETAILS_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  this->~AnyFunction();
55  type = b.type;
56  value = type?type->clone(b.value):0;
57  transform = b.transform;
58  return *this;
59  }
60 
62  {
63  if (type)
64  type->destroy(value);
65  }
66 
68  {
69  std::swap(value, b.value);
70  std::swap(type, b.type);
71  std::swap(transform, b.transform);
72  }
73 
74  inline AnyFunction::operator bool() const
75  {
76  return type != 0;
77  }
78 
80  {
81  return type;
82  }
83 
84 
85 } // namespace qi
86 
87 namespace std
88 {
89  template<> inline void swap(::qi::AnyFunction& a, ::qi::AnyFunction & b)
90  {
91  a.swap(b);
92  }
93 }
94 
95 #endif // _QITYPE_DETAILS_ANYFUNCTION_HXX_
AnyReference call(const AnyReferenceVector &args)
Call the function, reference must be destroy()ed.
FunctionTypeInterface * functionType() const
Definition: anyfunction.hxx:79
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:89
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:67
virtual void * clone(void *)=0
Allocate a storage and copy the value given as an argument.
std::vector< TypeInterface * > _argumentsType
Definition: anyfunction.hpp:85