libqi-api  2.4.3.28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Functions
objecttypebuilder.hpp File Reference
#include <qi/api.hpp>
#include <string>
#include <boost/function.hpp>
#include <qi/signature.hpp>
#include <sstream>
#include <qi/type/typeinterface.hpp>
#include <qi/type/detail/staticobjecttype.hpp>
#include <qi/type/detail/accessor.hxx>
#include <qi/type/detail/object.hxx>
#include <qi/property.hpp>
#include <qi/type/detail/objecttypebuilder.hxx>

Go to the source code of this file.

Classes

class  qi::SignalF< T >
 
class  qi::ObjectTypeBuilderBase
 
class  qi::ObjectTypeBuilder< T >
 
class  qi::TypeOfTemplate< qi::Future >
 
class  qi::TypeOfTemplateImpl< qi::Future, T >
 
class  qi::TypeOfTemplate< qi::FutureSync >
 
class  qi::TypeOfTemplateImpl< qi::FutureSync, T >
 
class  qi::TypeOfTemplate< qi::Promise >
 
class  qi::TypeOfTemplateImpl< qi::Promise, T >
 
struct  qi::detail::TypeManager< Future< T > >
 
struct  qi::detail::TypeManager< FutureSync< T > >
 
struct  qi::detail::TypeManager< Promise< T > >
 

Namespaces

 qi
 
 qi::detail
 

Macros

#define _QI_TYPE_OBJECTTYPEBUILDER_HPP_
 
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
 
#define QI_OBJECT_BUILDER_ADVERTISE(builder, cls, name)   builder.advertise(BOOST_PP_STRINGIZE(name), &cls::name)
 
#define QI_OBJECT_BUILDER_ADVERTISE_OVERLOAD(builder, cls, name, ret, args)   builder.advertiseMethod(BOOST_PP_STRINGIZE(name), static_cast<ret (cls::*)args>(&cls::name))
 
#define __QI_REGISTER_ELEMENT(_, name, field)   b.advertise(BOOST_PP_STRINGIZE(field), & name::field);
 
#define QI_REGISTER_OBJECT(name,...)
 
#define QI_REGISTER_MT_OBJECT(name,...)
 
#define QI_REGISTER_IMPLEMENTATION(parent, name)
 
#define _QI_REGISTER_TEMPLATE_OBJECT(name, model,...)
 
#define QI_TEMPLATE_OBJECT(name,...)
 
#define QI_REGISTER_TEMPLATE_OBJECT(name,...)   QI_TEMPLATE_OBJECT(name, __VA_ARGS__)
 
#define QI_MT_TEMPLATE_OBJECT(name,...)
 

Functions

 QI_TEMPLATE_TYPE_DECLARE (qi::Future)
 
 QI_TEMPLATE_TYPE_DECLARE (qi::FutureSync)
 
 QI_TEMPLATE_TYPE_DECLARE (qi::Promise)
 

Macro Definition Documentation

#define __QI_REGISTER_ELEMENT (   _,
  name,
  field 
)    b.advertise(BOOST_PP_STRINGIZE(field), & name::field);

Definition at line 177 of file objecttypebuilder.hpp.

#define _QI_REGISTER_TEMPLATE_OBJECT (   name,
  model,
  ... 
)
Value:
namespace qi \
{ \
template <> \
class QI_API TypeOfTemplate<name> : public detail::StaticObjectTypeBase \
{ \
public: \
virtual TypeInterface* templateArgument() = 0; \
}; \
template <typename T> \
class TypeOfTemplateImpl<name, T> : public TypeOfTemplate<name> \
{ \
public: \
TypeOfTemplateImpl() \
{ \
/* early self registering to avoid recursive init */ \
::qi::registerType(typeid(name<T>), this); \
ObjectTypeBuilder<name<T> > b(false); \
b.setThreadingModel(model); \
QI_VAARGS_APPLY(__QI_REGISTER_ELEMENT, name<T>, __VA_ARGS__) \
this->initialize(b.metaObject(), b.typeData()); \
} \
virtual TypeInterface* templateArgument() { return typeOf<T>(); } \
typedef DefaultTypeImplMethods<name<T> > Methods; \
}; \
} \
#define __QI_REGISTER_ELEMENT(_, name, field)
#define QI_API
Definition: api.hpp:34
QI_TEMPLATE_TYPE_DECLARE(qi::Future)
bool registerType(const std::type_info &typeId, TypeInterface *type)
Runtime Type factory setter.
#define _QI_BOUNCE_TYPE_METHODS(Bounce)
Implement all methods of Type as bouncers to Bouncer.
Definition: typeimpl.hxx:275
#define QI_VAARGS_APPLY(Macro, Arg,...)
Call Macro(useless, Arg, elem) for each elem (extra argument).
Definition: preproc.hpp:416

Definition at line 229 of file objecttypebuilder.hpp.

#define _QI_TYPE_OBJECTTYPEBUILDER_HPP_

Definition at line 8 of file objecttypebuilder.hpp.

#define genCall (   n,
  ATYPEDECL,
  ATYPES,
  ADECL,
  AUSE,
  comma 
)
Value:
template<typename T comma ATYPEDECL> \
inline unsigned int advertiseFactory(const std::string& name) \
{ \
return advertiseMethod(name, &constructObject<T comma ATYPES>); \
}

create a T, wrap in a AnyObject All template parameters are given to the T constructor except the first one

Definition at line 74 of file objecttypebuilder.hpp.

#define QI_MT_TEMPLATE_OBJECT (   name,
  ... 
)
Value:
__VA_ARGS__)
Object is thread safe, multiple calls can occur in different threads in parallel. ...
Definition: manageable.hpp:35
#define _QI_REGISTER_TEMPLATE_OBJECT(name, model,...)

Same as QI_TEMPLATE_OBJECT for multithread objects

Definition at line 273 of file objecttypebuilder.hpp.

#define QI_OBJECT_BUILDER_ADVERTISE (   builder,
  cls,
  name 
)    builder.advertise(BOOST_PP_STRINGIZE(name), &cls::name)

Advertise a member on a builder.

Parameters
builderThe builder on which to advertise
clsThe class to register
nameThe name of the member

Definition at line 161 of file objecttypebuilder.hpp.

#define QI_OBJECT_BUILDER_ADVERTISE_OVERLOAD (   builder,
  cls,
  name,
  ret,
  args 
)    builder.advertiseMethod(BOOST_PP_STRINGIZE(name), static_cast<ret (cls::*)args>(&cls::name))

Advertise an overloaded function on a builder.

Parameters
builderThe builder on which to advertise
clsThe class to register
nameThe name of the function
retThe return type
argsThe arguments as a tuple (ex: (const std::string&))

You must use this macro with the exact types of your method with references, pointers, cv-qualifiers (to the arguments and the method).

Definition at line 174 of file objecttypebuilder.hpp.

#define QI_REGISTER_IMPLEMENTATION (   parent,
  name 
)
Value:
static bool _qiregister##name() \
{ \
qi::registerType(typeid(name), qi::typeOf<parent>()); \
name* ptr = static_cast<name*>(reinterpret_cast<void*>(0x10000)); \
parent* pptr = ptr; \
intptr_t offset = reinterpret_cast<intptr_t>(pptr) - reinterpret_cast<intptr_t>(ptr); \
if (offset) \
{ \
qiLogError("qitype.register") << "non-zero offset for implementation " << #name << " of " << #parent \
<< ", call will fail at runtime"; \
throw std::runtime_error("non-zero offset between implementation and interface"); \
} \
return true; \
} \
static bool BOOST_PP_CAT(__qi_registration, __LINE__) = _qiregister##name();
bool registerType(const std::type_info &typeId, TypeInterface *type)
Runtime Type factory setter.
#define qiLogError(...)
Log in error mode.
Definition: log.hpp:113

Register object name as implementation of parent FIXME: support inheritance with offset. This implementation just bounces to parent's TypeInterfac. If that doesn't fit your need, you can always re-register everything from the interface on your class.

Definition at line 212 of file objecttypebuilder.hpp.

#define QI_REGISTER_MT_OBJECT (   name,
  ... 
)
Value:
static bool _qiregister##name() { \
b.registerType(); \
return true; \
} \
static bool BOOST_PP_CAT(__qi_registration, __LINE__) = _qiregister##name();
#define __QI_REGISTER_ELEMENT(_, name, field)
Object is thread safe, multiple calls can occur in different threads in parallel. ...
Definition: manageable.hpp:35
void setThreadingModel(ObjectThreadingModel model)
#define QI_VAARGS_APPLY(Macro, Arg,...)
Call Macro(useless, Arg, elem) for each elem (extra argument).
Definition: preproc.hpp:416

Definition at line 196 of file objecttypebuilder.hpp.

#define QI_REGISTER_OBJECT (   name,
  ... 
)
Value:
static bool _qiregister##name() { \
b.registerType(); \
return true; \
} \
static bool BOOST_PP_CAT(__qi_registration, __LINE__) = _qiregister##name();
#define __QI_REGISTER_ELEMENT(_, name, field)
#define QI_VAARGS_APPLY(Macro, Arg,...)
Call Macro(useless, Arg, elem) for each elem (extra argument).
Definition: preproc.hpp:416

Register an object to the typesystem

Parameters
namethe class name, without any namespace
...the names of the methods, signals and properties of the class
Warning
must be called from an unique compilation unit (not a header), from within the namespace of the class

Definition at line 187 of file objecttypebuilder.hpp.

#define QI_REGISTER_TEMPLATE_OBJECT (   name,
  ... 
)    QI_TEMPLATE_OBJECT(name, __VA_ARGS__)
Deprecated:
since 2.3, use QI_TEMPLATE_OBJECT

Definition at line 268 of file objecttypebuilder.hpp.

#define QI_TEMPLATE_OBJECT (   name,
  ... 
)
Value:
__VA_ARGS__)
#define _QI_REGISTER_TEMPLATE_OBJECT(name, model,...)
Object is not thread safe, all method calls must occur in the same thread.
Definition: manageable.hpp:33

Register name as a template object type Remaining arguments are the methods, signals and properties of the object. Use QI_TEMPLATE_TYPE_GET() to access the TypeOfTemplate<T> from a Type.

Definition at line 262 of file objecttypebuilder.hpp.

Function Documentation

QI_TEMPLATE_TYPE_DECLARE ( qi::Future  )
QI_TEMPLATE_TYPE_DECLARE ( qi::FutureSync  )
QI_TEMPLATE_TYPE_DECLARE ( qi::Promise  )