libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
staticobjecttype.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2012 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_TYPE_DETAIL_STATICOBJECTTYPE_HPP_
8 #define _QI_TYPE_DETAIL_STATICOBJECTTYPE_HPP_
9 
10 #include <qi/api.hpp>
11 #include <qi/property.hpp>
12 #include <qi/anyvalue.hpp>
14 #include <qi/type/metaobject.hpp>
15 
16 namespace qi
17 {
18 
19 class SignalBase;
20 
21 namespace detail {
22 
23 //type-erased methods and signals accessors for a given type
25 {
27  : classType(0)
28  , threadingModel(ObjectThreadingModel_Default)
29  {}
30 
31  /* One might want this in the ObjectType virtuals, but that would
32  * bypass ObjectTypeInterface::metaCall which would have to be removed.
33  * -> RemoteObject, ALBridge needs to be rewriten.
34  */
35  using SignalGetter = boost::function<SignalBase* (void*)>;
36  using SignalGetterMap = std::map<unsigned int, SignalGetter>;
38 
39  using PropertyGetter = boost::function<PropertyBase*(void*)>;
40  using PropertyGetterMap = std::map<unsigned int, PropertyGetter>;
42 
43  using MethodMap = std::map<unsigned int, std::pair<AnyFunction, MetaCallType>>;
44 
46 
48  std::vector<std::pair<TypeInterface*, std::ptrdiff_t> > parentTypes;
51 };
52 
53 
62 {
63 public:
64  void initialize(const MetaObject& mo, const ObjectTypeData& data);
65  const TypeInfo& info() override;
66  const MetaObject& metaObject(void* instance) override;
67  ObjectUid uid(void* instance) const override;
68  qi::Future<AnyReference> metaCall(void* instance, AnyObject context, unsigned int method, const GenericFunctionParameters& params, MetaCallType callType, Signature returnSignature) override;
69  void metaPost(void* instance, AnyObject context, unsigned int signal, const GenericFunctionParameters& params) override;
70  qi::Future<SignalLink> connect(void* instance, AnyObject context, unsigned int event, const SignalSubscriber& subscriber) override;
72  qi::Future<void> disconnect(void* instance, AnyObject context, SignalLink linkId) override;
73  qi::Future<AnyValue> property(void* instance, AnyObject context, unsigned int id) override;
74  qi::Future<void> setProperty(void* instance, AnyObject context, unsigned int id, AnyValue value) override;
75 
76  const std::vector<std::pair<TypeInterface*, std::ptrdiff_t> >& parentTypes() override;
77  void* initializeStorage(void*) override;
78  void* ptrFromStorage(void**) override;
79  void* clone(void* inst) override;
80  void destroy(void*) override;
81  bool less(void* a, void* b) override;
82 private:
83  MetaObject _metaObject;
84  ObjectTypeData _data;
85 
86  ExecutionContext* getExecutionContext(void* instance, qi::AnyObject context, MetaCallType methodThreadingModel = MetaCallType_Auto);
87 };
88 
89 }
90 
91 }
92 
93 #endif
PropertyGetterMap propertyGetterMap
void destroy()
Stop and flush the logging system.
#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::function< SignalBase *(void *)> SignalGetter
Honor the default behavior.
Definition: typeobject.hpp:26
dll import/export and compiler message
boost::function< PropertyBase *(void *)> PropertyGetter
std::map< unsigned int, std::pair< AnyFunction, MetaCallType >> MethodMap
ObjectThreadingModel threadingModel
MetaCallType
Definition: typeobject.hpp:24
std::map< unsigned int, PropertyGetter > PropertyGetterMap
std::map< unsigned int, SignalGetter > SignalGetterMap
qi::uint64_t SignalLink
Definition: signal.hpp:36
ObjectThreadingModel
Possible thread models for an object.
Definition: manageable.hpp:33
std::vector< std::pair< TypeInterface *, std::ptrdiff_t > > parentTypes
int context()
Get log context.
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25