Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes | Public Types | Public Member Functions | List of all members
datatools::factory_register< BaseType > Class Template Reference

Template factory registration class. More...

#include <bayeux/datatools/factory.h>

Inheritance diagram for datatools::factory_register< BaseType >:
datatools::base_factory_register datatools::i_tree_dumpable

Classes

struct  factory_record_type
 

Public Types

typedef BaseType base_type
 
typedef boost::function< base_type *() > factory_type
 
typedef std::map< std::string, factory_record_typefactory_map_type
 Dictionary of object factories. More...
 
- Public Types inherited from datatools::base_factory_register
enum  flag_type { verbose = 0x1 }
 
- Public Types inherited from datatools::i_tree_dumpable
enum  ostream_type { OSTREAM_COUT = 1, OSTREAM_CERR = 2, OSTREAM_CLOG = 3 }
 Enumeration for standard output streams. More...
 

Public Member Functions

 factory_register ()
 Constructor. More...
 
 factory_register (const std::string &label_, unsigned int flags_=0x0)
 Constructor. More...
 
virtual ~factory_register ()
 Destructor. More...
 
datatools::logger::priority get_logging_priority () const
 Returns logging priority. More...
 
void set_logging_priority (datatools::logger::priority logging_)
 Set logging priority. More...
 
const std::string & get_label () const
 Get the label associated to the factory. More...
 
void set_label (const std::string &label_)
 Set the label associated to the factory. More...
 
void list_of_factories (std::vector< std::string > &ids_) const
 Copy factory IDs into supplied vector. More...
 
bool has (const std::string &id_) const
 Return true if factory with given ID is registered. More...
 
bool is_group (const std::string &id_) const
 Return true if factory with given ID is registered with given group. More...
 
void clear ()
 Clear all registered factories. More...
 
void reset ()
 Reset. More...
 
factory_typegrab (const std::string &id_)
 Return a mutable reference to a factory given by registration ID. More...
 
const factory_typeget (const std::string &id_) const
 Return a const reference to a factory given by registration ID. More...
 
const factory_record_typeget_record (const std::string &id_) const
 Return a const reference to a factory record given by registration ID. More...
 
void registration (const std::string &id_, const factory_type &factory_, const std::type_info &tinfo_, const std::string &description_="", const std::string &category_="")
 Register the supplied factory under the given ID. More...
 
template<class DerivedType >
void registration (const std::string &id_, const std::string &description_="", const std::string &category_="")
 Register the supplied factory under the given ID. More...
 
template<class DerivedType >
bool fetch_type_id (std::string &id_) const
 Fetch the registration type ID associated to a given class. More...
 
bool fetch_type_id (const std::type_info &tinfo_, std::string &id_) const
 Fetch the registration type ID associated to a given type_info. More...
 
void unregistration (const std::string &id_)
 
void import (const factory_register &factory_register_)
 Import all registered factories from another factory register. More...
 
void import_some (const factory_register &factory_register_, const std::vector< std::string > &imported_factories_)
 
void print (std::ostream &out_, const std::string &indent_="") const
 Simple print. More...
 
virtual void tree_dump (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
 Smart print. More...
 
- Public Member Functions inherited from datatools::base_factory_register
 base_factory_register ()
 Default constructor. More...
 
virtual ~base_factory_register ()
 Destructor. More...
 
- Public Member Functions inherited from datatools::i_tree_dumpable
 i_tree_dumpable ()
 Constructor. More...
 
virtual ~i_tree_dumpable ()
 Destructor. More...
 
virtual void print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const
 Main new interface method for printing. More...
 
void print_tree_json (std::ostream &out_=std::clog, const std::string &json_options_="") const
 Printing with jsonized options. More...
 
void print_tree_json (std::ostream &out_=std::clog, const char *json_options_=nullptr) const
 Printing with jsonized options. More...
 
void tree_dump_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="", const bool inherit_=false) const
 
void tree_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="") const
 
void smart_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="") const
 

Additional Inherited Members

- Static Public Member Functions inherited from datatools::i_tree_dumpable
static const boost::property_tree::ptree & empty_options ()
 
static boost::property_tree::ptree make_base_print_options (const std::string &title_, const std::string &indent_="", const bool inherit_=false)
 
static std::ostream & last_skip_tag (std::ostream &out_)
 
static std::ostream & skip_tag (std::ostream &out_)
 
static std::ostream & last_tag (std::ostream &out_)
 
static std::ostream & tag (std::ostream &out_)
 

Detailed Description

template<class BaseType>
class datatools::factory_register< BaseType >

Template factory registration class.

Member Typedef Documentation

◆ base_type

template<class BaseType>
typedef BaseType datatools::factory_register< BaseType >::base_type

◆ factory_map_type

template<class BaseType>
typedef std::map<std::string, factory_record_type> datatools::factory_register< BaseType >::factory_map_type

Dictionary of object factories.

◆ factory_type

template<class BaseType>
typedef boost::function<base_type*() > datatools::factory_register< BaseType >::factory_type

Constructor & Destructor Documentation

◆ factory_register() [1/2]

template<typename BaseType >
datatools::factory_register< BaseType >::factory_register ( )

Constructor.

◆ factory_register() [2/2]

template<typename BaseType >
datatools::factory_register< BaseType >::factory_register ( const std::string &  label_,
unsigned int  flags_ = 0x0 
)

Constructor.

◆ ~factory_register()

template<typename BaseType >
datatools::factory_register< BaseType >::~factory_register ( )
virtual

Destructor.

Member Function Documentation

◆ clear()

template<typename BaseType >
void datatools::factory_register< BaseType >::clear ( )

Clear all registered factories.

◆ fetch_type_id() [1/2]

template<typename BaseType >
template<class DerivedType >
bool datatools::factory_register< BaseType >::fetch_type_id ( std::string &  id_) const

Fetch the registration type ID associated to a given class.

◆ fetch_type_id() [2/2]

template<typename BaseType >
bool datatools::factory_register< BaseType >::fetch_type_id ( const std::type_info &  tinfo_,
std::string &  id_ 
) const

Fetch the registration type ID associated to a given type_info.

◆ get()

template<typename BaseType >
const factory_register< BaseType >::factory_type & datatools::factory_register< BaseType >::get ( const std::string &  id_) const

Return a const reference to a factory given by registration ID.

◆ get_label()

template<typename BaseType >
const std::string & datatools::factory_register< BaseType >::get_label ( ) const

Get the label associated to the factory.

◆ get_logging_priority()

template<typename BaseType >
datatools::logger::priority datatools::factory_register< BaseType >::get_logging_priority ( ) const

Returns logging priority.

◆ get_record()

template<typename BaseType >
const factory_register< BaseType >::factory_record_type & datatools::factory_register< BaseType >::get_record ( const std::string &  id_) const

Return a const reference to a factory record given by registration ID.

◆ grab()

template<typename BaseType >
factory_register< BaseType >::factory_type & datatools::factory_register< BaseType >::grab ( const std::string &  id_)

Return a mutable reference to a factory given by registration ID.

◆ has()

template<typename BaseType >
bool datatools::factory_register< BaseType >::has ( const std::string &  id_) const

Return true if factory with given ID is registered.

◆ import()

template<typename BaseType >
void datatools::factory_register< BaseType >::import ( const factory_register< BaseType > &  factory_register_)

Import all registered factories from another factory register.

◆ import_some()

template<typename BaseType >
void datatools::factory_register< BaseType >::import_some ( const factory_register< BaseType > &  factory_register_,
const std::vector< std::string > &  imported_factories_ 
)

Import only registered factories addressed by their registration names from another factory register

◆ is_group()

template<class BaseType>
bool datatools::factory_register< BaseType >::is_group ( const std::string &  id_) const

Return true if factory with given ID is registered with given group.

◆ list_of_factories()

template<typename BaseType >
void datatools::factory_register< BaseType >::list_of_factories ( std::vector< std::string > &  ids_) const

Copy factory IDs into supplied vector.

◆ print()

template<typename BaseType >
void datatools::factory_register< BaseType >::print ( std::ostream &  out_,
const std::string &  indent_ = "" 
) const

Simple print.

◆ registration() [1/2]

template<typename BaseType >
void datatools::factory_register< BaseType >::registration ( const std::string &  id_,
const factory_type factory_,
const std::type_info &  tinfo_,
const std::string &  description_ = "",
const std::string &  category_ = "" 
)

Register the supplied factory under the given ID.

◆ registration() [2/2]

template<typename BaseType >
template<typename DerivedType >
void datatools::factory_register< BaseType >::registration ( const std::string &  id_,
const std::string &  description_ = "",
const std::string &  category_ = "" 
)

Register the supplied factory under the given ID.

◆ reset()

template<typename BaseType >
void datatools::factory_register< BaseType >::reset ( )

Reset.

◆ set_label()

template<typename BaseType >
void datatools::factory_register< BaseType >::set_label ( const std::string &  label_)

Set the label associated to the factory.

◆ set_logging_priority()

template<typename BaseType >
void datatools::factory_register< BaseType >::set_logging_priority ( datatools::logger::priority  logging_)

Set logging priority.

◆ tree_dump()

template<typename BaseType >
void datatools::factory_register< BaseType >::tree_dump ( std::ostream &  out_ = std::clog,
const std::string &  title_ = "",
const std::string &  indent_ = "",
bool  inherit_ = false 
) const
virtual

Smart print.

Reimplemented from datatools::i_tree_dumpable.

◆ unregistration()

template<typename BaseType >
void datatools::factory_register< BaseType >::unregistration ( const std::string &  id_)

Remove registration of the factory stored under supplied ID TODO : better naming "unregister" for example COMMENT: "register"/"unregister" would be fine names but "register" is a reserved word


The documentation for this class was generated from the following files: