MIRA
Namespaces | Macros | Functions
FactoryMacros.h File Reference

$Macros for registering classes$. More...

#include <boost/mpl/assert.hpp>
#include <platform/Typename.h>
Include dependency graph for FactoryMacros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 mira
 specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
 

Macros

#define MIRA_NAMEDOBJECT(classIdentifier, className)
 Use this MACRO if you don't like the factory to automatically extract the class name from the given identifier. More...
 
#define MIRA_OBJECT(classIdentifier)
 Use this MACRO if you like the factory to automatically extract the class name from the given identifier. More...
 
#define MIRA_META_OBJECT(classIdentifier, MetaInfo)
 Use this MACRO instead of MIRA_OBJECT if you like to add meta information to your class. More...
 
#define MIRA_ABSTRACT_OBJECT(classIdentifier)   MIRA_META_OBJECT( MIRA_PPARAM( classIdentifier ), ("AbstractClass", mira::typeName<classIdentifier>()) )
 Use this MACRO instead of MIRA_OBJECT to declare the class as abstract. More...
 
#define MIRA_ABSTRACT_META_OBJECT(classIdentifier, MetaInfo)   MIRA_META_OBJECT( MIRA_PPARAM( classIdentifier ), ("AbstractClass", mira::typeName<classIdentifier>())MetaInfo )
 This MACRO provides a combination of the effects of MIRA_META_OBJECT and MIRA_ABSTRACT_OBJECT. More...
 
#define MIRA_CLASS_REGISTER(Class, ...)
 Use this macro to register your class at the ClassFactory. More...
 
#define MIRA_NO_PUBLIC_DEFAULT_CONSTRUCTOR(CLASS)
 Use this macro if your class does not have a public default constructor and should be managed by the class factory. More...
 
#define MIRA_TEMPLATE_CLASS_REGISTER(Namespace, Class, TmplSpec, ...)   MIRA_TEMPLATE_CLASS_REGISTER_IMPL( Namespace, Class, 1, MIRA_MAKE_SEQ(1,TmplSpec), __VA_ARGS__ )
 Use this macro to register your template class at the ClassFactory. More...
 
#define MIRA_VARTEMPLATE_CLASS_REGISTER(Namespace, Class, NumTmplPrm, TmplSpec, ...)   MIRA_TEMPLATE_CLASS_REGISTER_IMPL( Namespace, Class, NumTmplPrm, MIRA_MAKE_SEQ(NumTmplPrm,TmplSpec), __VA_ARGS__ )
 Use this macro to register your template class at the ClassFactory. More...
 

Functions

std::string mira_stripNameFromIdentifier (std::string const &identifier)
 Auxiliary function to extract the class name from the given identifier. More...
 
std::string replaceTemplateGeneric (std::string const &genericIdent, std::string const &specialIdent)
 

Detailed Description

$Macros for registering classes$.

Author
Ronny Stricker
Date
2011/05/24

Macro Definition Documentation

◆ MIRA_ABSTRACT_OBJECT

#define MIRA_ABSTRACT_OBJECT (   classIdentifier)    MIRA_META_OBJECT( MIRA_PPARAM( classIdentifier ), ("AbstractClass", mira::typeName<classIdentifier>()) )

Use this MACRO instead of MIRA_OBJECT to declare the class as abstract.

That enables the manifest generator to check whether classes are meant to be abstract (in addition to determining their actual abstractness), helping e.g. to prevent subclasses becoming abstract unnoticed after base class extensions (a common error hard to prevent otherwise, since subclasses may be declared in packages unknown to the base class developer, while abstractness of a class to be instantiated is not necessarily detected at compile time with dynamic instantiation using the class factory). This will add a special meta information entry "AbstractClass" with the class identifier as value.

◆ MIRA_ABSTRACT_META_OBJECT

#define MIRA_ABSTRACT_META_OBJECT (   classIdentifier,
  MetaInfo 
)    MIRA_META_OBJECT( MIRA_PPARAM( classIdentifier ), ("AbstractClass", mira::typeName<classIdentifier>())MetaInfo )

This MACRO provides a combination of the effects of MIRA_META_OBJECT and MIRA_ABSTRACT_OBJECT.

◆ MIRA_NO_PUBLIC_DEFAULT_CONSTRUCTOR

#define MIRA_NO_PUBLIC_DEFAULT_CONSTRUCTOR (   CLASS)
Value:
namespace mira { \
template<> \
class HasPublicDefaultConstructor<CLASS> : public std::false_type {}; \
}
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67

Use this macro if your class does not have a public default constructor and should be managed by the class factory.

◆ MIRA_TEMPLATE_CLASS_REGISTER

#define MIRA_TEMPLATE_CLASS_REGISTER (   Namespace,
  Class,
  TmplSpec,
  ... 
)    MIRA_TEMPLATE_CLASS_REGISTER_IMPL( Namespace, Class, 1, MIRA_MAKE_SEQ(1,TmplSpec), __VA_ARGS__ )

Use this macro to register your template class at the ClassFactory.

You should use this function if your template has only one template parameter. Please note that the syntax is different from the regular MIRA_CLASS_REGISTER. Therefore, you have to pass the Class (without any template arguments and its Parents as well as the Namespace of your class (given as boost preprocessor sequence) and the template specialization parameters. E.g. if your class is defined as mira::subspace::MyClass<T> : public mira::Base1, public mira::subspace::Base2 and you like to register your class for T=int and T=char, the macro should look something like the following: MIRA_TEMPLATE_CLASS_REGISTER((mira)(subspace),MyClass,(int)(char),mira::Base1,mira::subspace::Base2)

◆ MIRA_VARTEMPLATE_CLASS_REGISTER

#define MIRA_VARTEMPLATE_CLASS_REGISTER (   Namespace,
  Class,
  NumTmplPrm,
  TmplSpec,
  ... 
)    MIRA_TEMPLATE_CLASS_REGISTER_IMPL( Namespace, Class, NumTmplPrm, MIRA_MAKE_SEQ(NumTmplPrm,TmplSpec), __VA_ARGS__ )

Use this macro to register your template class at the ClassFactory.

You have to use this function if your template has more than one template parameter. Please note that the syntax is different from the regular MIRA_CLASS_REGISTER. Therefore, you have to pass the Class (without any template arguments and its Parents as well as the Namespace of your class (given as boost preprocessor sequence) and the template specialization parameters. E.g. if your class is defined as mira::subspace::MyClass<T1,T2> : public mira::Base1, public mira::subspace::Base2 and you like to register your class for (T1=int,T2=char) and (T1=char,T2=uint), the macro should look something like the following: MIRA_VARTEMPLATE_CLASS_REGISTER((mira)(subspace),MyClass,2,(int,char)(char,uint),mira::Base1,mira::subspace::Base2)