Bayeux  3.4.1
Core Foundation library for SuperNEMO
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
datatools::service_manager Class Reference

Service management class. More...

#include <bayeux/datatools/service_manager.h>

Inheritance diagram for datatools::service_manager:
datatools::i_tree_dumpable

Public Types

enum  flag_type {
  BLANK = 0, NO_PRELOAD = datatools::bit_mask::bit00, FORCE_INITIALIZATION_AT_LOAD = datatools::bit_mask::bit01, FACTORY_VERBOSE = datatools::bit_mask::bit02,
  ALLOW_DYNAMIC_SERVICES = datatools::bit_mask::bit03
}
 
enum  service_filter_flag {
  FILTER_NONE = 0, FILTER_NO_INITIALIZED = datatools::bit_mask::bit00, FILTER_NO_UNINITIALIZED = datatools::bit_mask::bit01, FILTER_NO_CLEAR = datatools::bit_mask::bit02,
  FILTER_FROM_BUS = datatools::bit_mask::bit03
}
 Special flag to build the list of service names. More...
 
- 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

 service_manager (const std::string &name_="", const std::string &description_="", uint32_t flag_=BLANK)
 Constructor. More...
 
virtual ~service_manager ()
 Destructor. More...
 
void set_name (const std::string &name_)
 Set the name of the service. More...
 
void set_description (const std::string &description_)
 Set the description of the service. More...
 
const std::string & get_name () const
 Get the name of the service. More...
 
const std::string & get_description () const
 Get the description of the service. More...
 
bool is_debug () const
 Check the debug flag. More...
 
void set_debug (bool debug_=true)
 Set the debug flag. More...
 
void set_allow_dynamic_services (bool)
 Set the flag to allow_dynamic_services. More...
 
bool is_allow_dynamic_services () const
 Check if dynamic services are allowed. More...
 
void set_force_initialization_at_load (bool)
 Set the flag to force initialization of services at load. More...
 
bool is_force_initialization_at_load () const
 Check if the flag to force initialization of services at load is set. More...
 
bool is_initialized () const
 Check the initialization flag. More...
 
void initialize ()
 Initialize the manager. More...
 
void initialize (const datatools::properties &config_)
 Initialize the manager from a container of properties. More...
 
void reset ()
 Reset the manager. More...
 
bool has_service_type (const std::string &id_) const
 Check if a service identifier/type is supported. More...
 
template<class ServiceClass >
void register_service_type (const std::string &id_)
 Register a service factory. More...
 
void unregister_service_type (const std::string &id_)
 Unregister a service factory. More...
 
void build_list_of_services (std::vector< std::string > &list_, uint32_t flags_=0)
 Build the list of services names. More...
 
bool has (const std::string &name_) const
 
bool is_initialized (const std::string &name_) const
 
template<class T >
bool is_a (const std::string &name_) const
 
template<class T >
T & grab (const std::string &name_)
 
template<class T >
const T & get (const std::string &name_) const
 
base_servicegrab_service (const std::string &name_)
 
const base_serviceget_service (const std::string &name_) const
 
bool can_drop (const std::string &name_) const
 Check if a service with given name can be dropped. More...
 
void drop (const std::string &name_)
 Drop a service given its name. More...
 
void load (const std::string &name_, const std::string &id_, const datatools::properties &config_)
 Load a service with given name, identifier and configuration. More...
 
base_serviceload_no_init (const std::string &name_, const std::string &id_)
 
void configure_no_init (const std::string &name_, const datatools::properties &config_)
 
void load (const datatools::multi_properties &config_)
 Load a set of services from a multi-service configuration. More...
 
const service_dict_typeget_local_services () const
 Return the list of services locally hosted by this manager. More...
 
const service_dict_typeget_bus_of_services (const bool update_=false) const
 Return the bus of services known in the context of this manager. More...
 
void dump_services (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="") const
 Basic print of embedded services. 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...
 
void set_logging_priority (datatools::logger::priority)
 Set the logging priority threshold. More...
 
datatools::logger::priority get_logging_priority () const
 Return the logging priority threshold. More...
 
void update_service_bus ()
 Update the bus of services (expert only) More...
 
void sync ()
 Synchronize internal data (expert only) 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
 

Protected Member Functions

void load_service (const std::string &name_, const std::string &id_, const datatools::properties &config_)
 Load a service. More...
 
void load_service (const std::string &name_, const std::string &id_, const datatools::properties *config_ptr_)
 Load a service with or without initialization. More...
 
void preload_global_dict ()
 Preload the factory register from service factory system register. More...
 
void create_service (service_entry &entry_)
 Instantiate a service from its entry. More...
 
void initialize_service (service_entry &entry_)
 Initialize a service from its entry. More...
 
void reset_service (service_entry &entry_)
 Reset a service from its entry. More...
 
void destroy_service (service_entry &entry_)
 Destroy a service from its entry. More...
 
void at_service_creation (const std::string &service_name_, const std::string &service_type_id_)
 Action done at service creation. More...
 
void at_service_initialization (const std::string &service_name_)
 Action done at service initialization. More...
 
void at_service_reset (const std::string &service_name_)
 Action done at service reset. More...
 
void at_service_drop (const std::string &service_name_)
 Action done at service drop. More...
 

Friends

class service_entry
 

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

Service management class.

Member Enumeration Documentation

◆ flag_type

Enumerator
BLANK 

No special configuration flags.

NO_PRELOAD 

Do not preload service types from the system register.

FORCE_INITIALIZATION_AT_LOAD 

Force initialization of service instance at load rather than at first use.

FACTORY_VERBOSE 

Activate factory verbosity (debug)

ALLOW_DYNAMIC_SERVICES 

Allow dynamic services.

◆ service_filter_flag

Special flag to build the list of service names.

Enumerator
FILTER_NONE 

No special filter flags.

FILTER_NO_INITIALIZED 

Flag to skip initialized services.

FILTER_NO_UNINITIALIZED 

Flag to skip uninitialized services.

FILTER_NO_CLEAR 

Flag to skip clear the list.

FILTER_FROM_BUS 

Flag to take into account services from the bus.

Constructor & Destructor Documentation

◆ service_manager()

datatools::service_manager::service_manager ( const std::string &  name_ = "",
const std::string &  description_ = "",
uint32_t  flag_ = BLANK 
)

Constructor.

◆ ~service_manager()

virtual datatools::service_manager::~service_manager ( )
virtual

Destructor.

Member Function Documentation

◆ at_service_creation()

void datatools::service_manager::at_service_creation ( const std::string &  service_name_,
const std::string &  service_type_id_ 
)
protected

Action done at service creation.

◆ at_service_drop()

void datatools::service_manager::at_service_drop ( const std::string &  service_name_)
protected

Action done at service drop.

◆ at_service_initialization()

void datatools::service_manager::at_service_initialization ( const std::string &  service_name_)
protected

Action done at service initialization.

◆ at_service_reset()

void datatools::service_manager::at_service_reset ( const std::string &  service_name_)
protected

Action done at service reset.

◆ build_list_of_services()

void datatools::service_manager::build_list_of_services ( std::vector< std::string > &  list_,
uint32_t  flags_ = 0 
)

Build the list of services names.

◆ can_drop()

bool datatools::service_manager::can_drop ( const std::string &  name_) const

Check if a service with given name can be dropped.

◆ configure_no_init()

void datatools::service_manager::configure_no_init ( const std::string &  name_,
const datatools::properties config_ 
)

Configure an uninitialized service

This method is reserved for experts only because it uses the interface of the service manager in a very special way.

◆ create_service()

void datatools::service_manager::create_service ( service_entry entry_)
protected

Instantiate a service from its entry.

◆ destroy_service()

void datatools::service_manager::destroy_service ( service_entry entry_)
protected

Destroy a service from its entry.

◆ drop()

void datatools::service_manager::drop ( const std::string &  name_)

Drop a service given its name.

◆ dump_services()

void datatools::service_manager::dump_services ( std::ostream &  out_ = std::clog,
const std::string &  title_ = "",
const std::string &  indent_ = "" 
) const

Basic print of embedded services.

◆ get()

template<class T >
const T & datatools::service_manager::get ( const std::string &  name_) const
Parameters
name_The name of the service to be checked
Returns
a const reference to the service instance requested by name and type

◆ get_bus_of_services()

const service_dict_type& datatools::service_manager::get_bus_of_services ( const bool  update_ = false) const

Return the bus of services known in the context of this manager.

◆ get_description()

const std::string& datatools::service_manager::get_description ( ) const

Get the description of the service.

◆ get_local_services()

const service_dict_type& datatools::service_manager::get_local_services ( ) const

Return the list of services locally hosted by this manager.

◆ get_logging_priority()

datatools::logger::priority datatools::service_manager::get_logging_priority ( ) const

Return the logging priority threshold.

◆ get_name()

const std::string& datatools::service_manager::get_name ( ) const

Get the name of the service.

◆ get_service()

const base_service& datatools::service_manager::get_service ( const std::string &  name_) const
Parameters
name_The name of the service to be checked
Returns
a const reference to the service instance requested by name

◆ grab()

template<class T >
T & datatools::service_manager::grab ( const std::string &  name_)

Same as the mutable 'get' method

Parameters
name_The name of the service to be checked
Returns
a mutable reference to the service instance requested by name and type

◆ grab_service()

base_service& datatools::service_manager::grab_service ( const std::string &  name_)
Parameters
name_The name of the service to be checked
Returns
a mutable reference to the service instance requested by name

◆ has()

bool datatools::service_manager::has ( const std::string &  name_) const
Parameters
name_The name of the service to be checked
Returns
true if the manager hosts the service requested by name

◆ has_service_type()

bool datatools::service_manager::has_service_type ( const std::string &  id_) const

Check if a service identifier/type is supported.

◆ initialize() [1/2]

void datatools::service_manager::initialize ( )

Initialize the manager.

◆ initialize() [2/2]

void datatools::service_manager::initialize ( const datatools::properties config_)

Initialize the manager from a container of properties.

◆ initialize_service()

void datatools::service_manager::initialize_service ( service_entry entry_)
protected

Initialize a service from its entry.

◆ is_a()

template<class T >
bool datatools::service_manager::is_a ( const std::string &  name_) const
Parameters
name_The name of the service to be checked
Returns
true if the service is of the requested type

◆ is_allow_dynamic_services()

bool datatools::service_manager::is_allow_dynamic_services ( ) const

Check if dynamic services are allowed.

◆ is_debug()

bool datatools::service_manager::is_debug ( ) const

Check the debug flag.

◆ is_force_initialization_at_load()

bool datatools::service_manager::is_force_initialization_at_load ( ) const

Check if the flag to force initialization of services at load is set.

◆ is_initialized() [1/2]

bool datatools::service_manager::is_initialized ( ) const

Check the initialization flag.

◆ is_initialized() [2/2]

bool datatools::service_manager::is_initialized ( const std::string &  name_) const
Parameters
name_The name of the service to be checked
Returns
true if the service is initialized

◆ load() [1/2]

void datatools::service_manager::load ( const std::string &  name_,
const std::string &  id_,
const datatools::properties config_ 
)

Load a service with given name, identifier and configuration.

◆ load() [2/2]

void datatools::service_manager::load ( const datatools::multi_properties config_)

Load a set of services from a multi-service configuration.

◆ load_no_init()

base_service& datatools::service_manager::load_no_init ( const std::string &  name_,
const std::string &  id_ 
)

Load a service with given name and identifier and without initialization

Initialization must be manually done later through the returned reference This method is reserved for experts only because it uses the interface of the service manager in a very special way.

◆ load_service() [1/2]

void datatools::service_manager::load_service ( const std::string &  name_,
const std::string &  id_,
const datatools::properties config_ 
)
protected

Load a service.

◆ load_service() [2/2]

void datatools::service_manager::load_service ( const std::string &  name_,
const std::string &  id_,
const datatools::properties config_ptr_ 
)
protected

Load a service with or without initialization.

◆ preload_global_dict()

void datatools::service_manager::preload_global_dict ( )
protected

Preload the factory register from service factory system register.

◆ register_service_type()

template<class ServiceClass >
void datatools::service_manager::register_service_type ( const std::string &  id_)

Register a service factory.

◆ reset()

void datatools::service_manager::reset ( )

Reset the manager.

◆ reset_service()

void datatools::service_manager::reset_service ( service_entry entry_)
protected

Reset a service from its entry.

◆ set_allow_dynamic_services()

void datatools::service_manager::set_allow_dynamic_services ( bool  )

Set the flag to allow_dynamic_services.

◆ set_debug()

void datatools::service_manager::set_debug ( bool  debug_ = true)

Set the debug flag.

◆ set_description()

void datatools::service_manager::set_description ( const std::string &  description_)

Set the description of the service.

◆ set_force_initialization_at_load()

void datatools::service_manager::set_force_initialization_at_load ( bool  )

Set the flag to force initialization of services at load.

◆ set_logging_priority()

void datatools::service_manager::set_logging_priority ( datatools::logger::priority  )

Set the logging priority threshold.

◆ set_name()

void datatools::service_manager::set_name ( const std::string &  name_)

Set the name of the service.

◆ sync()

void datatools::service_manager::sync ( )

Synchronize internal data (expert only)

◆ tree_dump()

virtual void datatools::service_manager::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.

◆ unregister_service_type()

void datatools::service_manager::unregister_service_type ( const std::string &  id_)

Unregister a service factory.

◆ update_service_bus()

void datatools::service_manager::update_service_bus ( )

Update the bus of services (expert only)

Friends And Related Function Documentation

◆ service_entry

friend class service_entry
friend

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