Bayeux  3.4.1
Core Foundation library for SuperNEMO
Macros
factory_macros.h File Reference
#include <boost/preprocessor/stringize.hpp>
#include <datatools/factory.h>

Go to the source code of this file.

Macros

#define DATATOOLS_FACTORY_INTERFACE(BaseType)
 Alias for a factory register associated to a base class. More...
 
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
 Declaration of a system (allocator/functor) factory register as a static member of a base class and static accessor methods. More...
 
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_IMPLEMENTATION(BaseType, RegisterLabel)
 Instantiate the system (allocator/functor) factory register and its associated accessors. More...
 
#define DATATOOLS_FACTORY_GRAB_SYSTEM_REGISTER(BaseType)   BaseType::grab_system_factory_register() \
 
#define DATATOOLS_FACTORY_GET_SYSTEM_REGISTER(BaseType)   BaseType::get_system_factory_register() \
 
#define DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(BaseType, DerivedType)
 Interface macro of the automated registration for derived classes. More...
 
#define DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(BaseType, DerivedType, DerivedTypeId)
 Implementation macro of the automated registration for derived classes. More...
 

Macro Definition Documentation

◆ DATATOOLS_FACTORY_GET_SYSTEM_REGISTER

#define DATATOOLS_FACTORY_GET_SYSTEM_REGISTER (   BaseType)    BaseType::get_system_factory_register() \

◆ DATATOOLS_FACTORY_GRAB_SYSTEM_REGISTER

#define DATATOOLS_FACTORY_GRAB_SYSTEM_REGISTER (   BaseType)    BaseType::grab_system_factory_register() \

◆ DATATOOLS_FACTORY_INTERFACE

#define DATATOOLS_FACTORY_INTERFACE (   BaseType)
Value:
public: \
typedef ::datatools::factory_register< BaseType > factory_register_type; \

Alias for a factory register associated to a base class.

These macros provide some automated mechanisms to :

  • setup a global factory register associated to a given base class
  • automate the registration of the factory associated to any daughter class in the global factory register associated to the mother base class

◆ DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION

#define DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION (   BaseType,
  DerivedType,
  DerivedTypeId 
)
Value:
::datatools::_system_factory_registrator< BaseType , DerivedType > DerivedType::_g_system_factory_auto_registration_(DerivedTypeId); \
const std::string & DerivedType::system_factory_auto_registration_id() \
{ \
static const std::string _id(DerivedTypeId); \
return _id; \
} \
Utility template class to enable auto-(un)registration of a derived class in a system factory registe...
Definition: factory.h:180

Implementation macro of the automated registration for derived classes.

◆ DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE

#define DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE (   BaseType,
  DerivedType 
)
Value:
private: \
static ::datatools::_system_factory_registrator< BaseType , DerivedType > _g_system_factory_auto_registration_; \
public: \
static const std::string & system_factory_auto_registration_id(); \

Interface macro of the automated registration for derived classes.

◆ DATATOOLS_FACTORY_SYSTEM_REGISTER_IMPLEMENTATION

#define DATATOOLS_FACTORY_SYSTEM_REGISTER_IMPLEMENTATION (   BaseType,
  RegisterLabel 
)
Value:
BaseType::factory_register_type& BaseType::grab_system_factory_register() \
{ \
static scoped_factory_register_type _system_factory_register; \
if (!_system_factory_register) { \
_system_factory_register.reset(new BaseType::factory_register_type(RegisterLabel, 0)); \
} \
return *_system_factory_register.get(); \
} \
const BaseType::factory_register_type& BaseType::get_system_factory_register() \
{ \
BaseType::factory_register_type& fr = BaseType::grab_system_factory_register(); \
return const_cast< BaseType::factory_register_type& >(fr); \
} \

Instantiate the system (allocator/functor) factory register and its associated accessors.

◆ DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE

#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE (   BaseType)
Value:
public: \
typedef ::boost::scoped_ptr< factory_register_type > scoped_factory_register_type; \
static factory_register_type& grab_system_factory_register(); \
static const factory_register_type& get_system_factory_register(); \
#define DATATOOLS_FACTORY_INTERFACE(BaseType)
Alias for a factory register associated to a base class.
Definition: factory_macros.h:46

Declaration of a system (allocator/functor) factory register as a static member of a base class and static accessor methods.