libqi-api  release-2.5.3-2016-11-18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dynamicobject.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_DYNAMICOBJECT_HPP_
8 #define _QI_TYPE_DYNAMICOBJECT_HPP_
9 
10 #include <qi/anyobject.hpp>
11 #include <qi/property.hpp>
12 
13 #ifdef _MSC_VER
14 # pragma warning( push )
15 # pragma warning( disable: 4251 )
16 #endif
17 
18 namespace qi
19 {
20 
21  class DynamicObjectPrivate;
22 
35  public:
36  DynamicObject();
37 
38  virtual ~DynamicObject();
39 
41  virtual void setMetaObject(const MetaObject& mo);
42 
43 
44  MetaObject &metaObject();
45 
46  void setMethod(unsigned int id, AnyFunction callable, MetaCallType threadingModel = MetaCallType_Auto);
47  void setSignal(unsigned int id, SignalBase* signal);
48  void setProperty(unsigned int id, PropertyBase* property);
49 
50  const AnyFunction& method(unsigned int id) const;
51  SignalBase* signal(unsigned int id) const;
52  PropertyBase* property(unsigned int) const;
53 
54  virtual qi::Future<AnyReference> metaCall(AnyObject context, unsigned int method, const GenericFunctionParameters& params, MetaCallType callType = MetaCallType_Auto, Signature returnSignature=Signature());
55  virtual void metaPost(AnyObject context, unsigned int event, const GenericFunctionParameters& params);
57  virtual qi::Future<SignalLink> metaConnect(unsigned int event, const SignalSubscriber& subscriber);
59  virtual qi::Future<void> metaDisconnect(SignalLink linkId);
60  virtual qi::Future<AnyValue> metaProperty(AnyObject context, unsigned int id);
61  virtual qi::Future<void> metaSetProperty(AnyObject context, unsigned int id, AnyValue val);
62 
63  void setThreadingModel(ObjectThreadingModel model);
64  ObjectThreadingModel threadingModel() const;
65  // internal use, call once to update with Manageable methods and signals
66  void setManageable(Manageable* m);
67  // C4251
68  boost::shared_ptr<DynamicObjectPrivate> _p;
69  };
70 
71  //Make an AnyObject of DynamicObject kind from a DynamicObject
72  QI_API AnyObject makeDynamicAnyObject(DynamicObject *obj, bool destroyObject = true,
73  boost::function<void (GenericObject*)> onDelete = boost::function<void (GenericObject*)>());
74 
75  QI_API AnyObject makeDynamicSharedAnyObjectImpl(DynamicObject* obj, boost::shared_ptr<Empty> other);
76 
80  template<typename T>
81  inline AnyObject makeDynamicSharedAnyObject(DynamicObject *obj, boost::shared_ptr<T> other)
82  {
83  return makeDynamicSharedAnyObjectImpl(obj, boost::shared_ptr<Empty>(other, 0));
84  }
85 
86 
87  QI_API ObjectTypeInterface* getDynamicTypeInterface();
88 }
89 
90 #ifdef _MSC_VER
91 # pragma warning( pop )
92 #endif
93 
94 #endif // _QITYPE_DYNAMICOBJECT_HPP_
#define QI_API
Definition: api.hpp:33
qi::Future< AnyReference > metaCall(ExecutionContext *ec, ObjectThreadingModel objectThreadingModel, MetaCallType methodThreadingModel, MetaCallType callType, AnyObject manageable, unsigned int methodId, AnyFunction func, const GenericFunctionParameters &params, bool noCloneFirst=false, unsigned int callerId=0, qi::os::timeval postTimestamp=qi::os::timeval())
boost::shared_ptr< DynamicObjectPrivate > _p
AnyObject makeDynamicAnyObject(DynamicObject *obj, bool destroyObject=true, boost::function< void(GenericObject *)> onDelete=boost::function< void(GenericObject *)>())
AnyObject makeDynamicSharedAnyObjectImpl(DynamicObject *obj, boost::shared_ptr< Empty > other)
Honor the default behavior.
Definition: typeobject.hpp:23
AnyObject makeDynamicSharedAnyObject(DynamicObject *obj, boost::shared_ptr< T > other)
MetaCallType
Definition: typeobject.hpp:21
ObjectTypeInterface * getDynamicTypeInterface()
qi::uint64_t SignalLink
Definition: signal.hpp:35
ObjectThreadingModel
Possible thread models for an object.
Definition: manageable.hpp:33
int context()
Get log context.
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25