- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

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>
13 #include <qi/type/typeinterface.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
24 struct QI_API ObjectTypeData
25 {
26 ObjectTypeData()
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>;
37 SignalGetterMap signalGetterMap;
38
39 using PropertyGetter = boost::function<PropertyBase*(void*)>;
40 using PropertyGetterMap = std::map<unsigned int, PropertyGetter>;
41 PropertyGetterMap propertyGetterMap;
42
43 using MethodMap = std::map<unsigned int, std::pair<AnyFunction, MetaCallType>>;
44
45 MethodMap methodMap;
46
47 TypeInterface* classType;
48 std::vector<std::pair<TypeInterface*, std::ptrdiff_t> > parentTypes;
49 ObjectThreadingModel threadingModel;
50 qi::AnyFunction strandAccessor;
51 };
52
53
61 class QI_API StaticObjectTypeBase: public ObjectTypeInterface
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
qi::detail::ObjectTypeData::propertyGetterMap
PropertyGetterMap propertyGetterMap
Definition: staticobjecttype.hpp:41
qi::AnyValue
Definition: anyvalue.hpp:19
qi::detail::ObjectTypeData
Definition: staticobjecttype.hpp:24
qi::log::destroy
void destroy()
Stop and flush the logging system.
qi::GenericFunctionParameters
Definition: anyfunction.hpp:266
QI_API
#define QI_API
Definition: api.hpp:33
qi::metaCall
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())
qi::Future
Definition: executioncontext.hpp:20
qi::AnyFunction
Definition: anyfunction.hpp:149
qi::detail::ObjectTypeData::SignalGetter
boost::function< SignalBase *(void *)> SignalGetter
Definition: staticobjecttype.hpp:35
metaobject.hpp
qi::Signature
Definition: signature.hpp:66
qi::detail::ObjectTypeData::signalGetterMap
SignalGetterMap signalGetterMap
Definition: staticobjecttype.hpp:37
qi::MetaCallType_Auto
Honor the default behavior.
Definition: typeobject.hpp:26
qi::ExecutionContext
Definition: executioncontext.hpp:63
api.hpp
dll import/export and compiler message
qi::ObjectThreadingModel_Default
Definition: manageable.hpp:40
qi::TypeInfo
Definition: typeinterface.hpp:45
qi::TypeInterface
Definition: typeinterface.hpp:129
property.hpp
anyvalue.hpp
qi::detail::ObjectTypeData::PropertyGetter
boost::function< PropertyBase *(void *)> PropertyGetter
Definition: staticobjecttype.hpp:39
qi::detail::StaticObjectTypeBase
Definition: staticobjecttype.hpp:61
qi::ObjectTypeInterface
Definition: typeobject.hpp:48
qi::detail::ObjectTypeData::MethodMap
std::map< unsigned int, std::pair< AnyFunction, MetaCallType >> MethodMap
Definition: staticobjecttype.hpp:43
qi::detail::ObjectTypeData::classType
TypeInterface * classType
Definition: staticobjecttype.hpp:47
qi::detail::ObjectTypeData::threadingModel
ObjectThreadingModel threadingModel
Definition: staticobjecttype.hpp:49
qi::MetaCallType
MetaCallType
Definition: typeobject.hpp:24
qi::detail::ObjectTypeData::methodMap
MethodMap methodMap
Definition: staticobjecttype.hpp:45
qi::Object< Empty >
qi::detail::ObjectTypeData::strandAccessor
qi::AnyFunction strandAccessor
Definition: staticobjecttype.hpp:50
qi::detail::ObjectTypeData::PropertyGetterMap
std::map< unsigned int, PropertyGetter > PropertyGetterMap
Definition: staticobjecttype.hpp:40
qi::detail::ObjectTypeData::SignalGetterMap
std::map< unsigned int, SignalGetter > SignalGetterMap
Definition: staticobjecttype.hpp:36
qi::SignalLink
qi::uint64_t SignalLink
Definition: signal.hpp:36
typeinterface.hpp
qi::ObjectThreadingModel
ObjectThreadingModel
Possible thread models for an object.
Definition: manageable.hpp:33
qi::detail::ObjectTypeData::ObjectTypeData
ObjectTypeData()
Definition: staticobjecttype.hpp:26
qi::PtrUid
Definition: ptruid.hpp:33
qi::detail::ObjectTypeData::parentTypes
std::vector< std::pair< TypeInterface *, std::ptrdiff_t > > parentTypes
Definition: staticobjecttype.hpp:48
qi::log::context
int context()
Get log context.
qi::MetaObject
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25