libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dynamicobjectbuilder.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 _QI_TYPE_DYNAMICOBJECTBUILDER_HPP_
8 #define _QI_TYPE_DYNAMICOBJECTBUILDER_HPP_
9 
10 #include <boost/noncopyable.hpp>
11 #include <qi/anyobject.hpp>
12 #include <qi/property.hpp>
13 
14 namespace qi {
15 
16  class DynamicObject;
17  class DynamicObjectBuilderPrivate;
18  class QI_API DynamicObjectBuilder : private boost::noncopyable
19  {
20  public:
22  DynamicObjectBuilder(DynamicObject *dynobject, bool deleteOnDestroy = true);
23 
25 
26  // throw on error
27  template <typename OBJECT_TYPE, typename METHOD_TYPE>
28  inline unsigned int advertiseMethod(const std::string& name,
29  OBJECT_TYPE object,
30  METHOD_TYPE method,
31  const std::string& desc = "",
32  MetaCallType threadingModel = MetaCallType_Auto);
33 
34  // throw on error
35  template <typename FUNCTION_TYPE>
36  inline unsigned int advertiseMethod(const std::string& name,
37  FUNCTION_TYPE function,
38  const std::string& desc = "",
39  MetaCallType threadingModel = MetaCallType_Auto);
40 
41  // throw on error
42  template <typename OBJECT_TYPE, typename METHOD_TYPE>
43  inline unsigned int advertiseMethod(MetaMethodBuilder& builder,
44  OBJECT_TYPE object,
45  METHOD_TYPE method,
46  MetaCallType threadingModel = MetaCallType_Auto);
47 
48  // throw on error
49  template <typename FUNCTION_TYPE>
50  inline unsigned int advertiseMethod(MetaMethodBuilder& builder,
51  FUNCTION_TYPE function,
52  MetaCallType threadingModel = MetaCallType_Auto);
53 
57  template<typename T, typename... Args>
58  inline unsigned int advertiseFactory(const std::string& name)
59  {
60  qi::Object<T>(*constructor)(Args...) = [](Args... args) { return constructObject<T>(args...); };
61  return advertiseMethod(name, constructor);
62  }
63 
64  template <typename... Args>
65  unsigned int advertiseSignal(const std::string& name);
66 
68  template<typename T>
69  unsigned int advertiseSignalF(const std::string& name);
70 
71  unsigned int advertiseSignal(const std::string &name, qi::SignalBase *signal);
72 
73  template<typename T>
74  unsigned int advertiseProperty(const std::string& name);
76  unsigned int advertiseProperty(const std::string &name, qi::PropertyBase *sig);
77 
78  void setThreadingModel(ObjectThreadingModel model);
79 
80  unsigned int xAdvertiseMethod(const Signature &sigret,
81  const std::string &name,
82  const Signature &signature,
83  AnyFunction func, const std::string& desc = "",
84  MetaCallType threadingModel = MetaCallType_Auto);
85 
86  unsigned int xAdvertiseMethod(MetaMethodBuilder& builder, AnyFunction func,
87  MetaCallType threadingModel = MetaCallType_Auto);
88 
89  unsigned int xAdvertiseSignal(const std::string &name, const Signature &signature, bool isSignalProperty = false);
90  unsigned int xAdvertiseProperty(const std::string& name, const Signature& sig, int id=-1);
91  void setDescription(const std::string& desc);
92  qi::AnyObject object(boost::function<void (GenericObject*)> onDelete = boost::function<void (GenericObject*)>());
94  template<typename T> qi::AnyObject object(boost::shared_ptr<T> other);
95  void markProperty(unsigned int ev, unsigned int getter, unsigned int setter);
96  private:
97  DynamicObject* bareObject();
98  void setManageable(DynamicObject* obj, Manageable* m);
99  DynamicObjectBuilderPrivate *_p;
100  };
101 }
102 
104 
105 #endif // _QITYPE_DYNAMICOBJECTBUILDER_HPP_
#define QI_API
Definition: api.hpp:33
unsigned int advertiseFactory(const std::string &name)
Honor the default behavior.
Definition: typeobject.hpp:26
MetaCallType
Definition: typeobject.hpp:24
ObjectThreadingModel
Possible thread models for an object.
Definition: manageable.hpp:33