Bayeux
3.4.1
Core Foundation library for SuperNEMO
|
Service management class. More...
#include <bayeux/datatools/service_manager.h>
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_service & | grab_service (const std::string &name_) |
const base_service & | get_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_service & | load_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_type & | get_local_services () const |
Return the list of services locally hosted by this manager. More... | |
const service_dict_type & | get_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_) |
Service management class.
Special flag to build the list of service names.
datatools::service_manager::service_manager | ( | const std::string & | name_ = "" , |
const std::string & | description_ = "" , |
||
uint32_t | flag_ = BLANK |
||
) |
Constructor.
|
virtual |
Destructor.
|
protected |
Action done at service creation.
|
protected |
Action done at service drop.
|
protected |
Action done at service initialization.
|
protected |
Action done at service reset.
void datatools::service_manager::build_list_of_services | ( | std::vector< std::string > & | list_, |
uint32_t | flags_ = 0 |
||
) |
Build the list of services names.
bool datatools::service_manager::can_drop | ( | const std::string & | name_ | ) | const |
Check if a service with given name can be dropped.
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.
|
protected |
Instantiate a service from its entry.
|
protected |
Destroy a service from its entry.
void datatools::service_manager::drop | ( | const std::string & | name_ | ) |
Drop a service given its name.
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.
name_ | The name of the service to be checked |
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.
const std::string& datatools::service_manager::get_description | ( | ) | const |
Get the description of the service.
const service_dict_type& datatools::service_manager::get_local_services | ( | ) | const |
Return the list of services locally hosted by this manager.
datatools::logger::priority datatools::service_manager::get_logging_priority | ( | ) | const |
Return the logging priority threshold.
const std::string& datatools::service_manager::get_name | ( | ) | const |
Get the name of the service.
const base_service& datatools::service_manager::get_service | ( | const std::string & | name_ | ) | const |
name_ | The name of the service to be checked |
T & datatools::service_manager::grab | ( | const std::string & | name_ | ) |
Same as the mutable 'get' method
name_ | The name of the service to be checked |
base_service& datatools::service_manager::grab_service | ( | const std::string & | name_ | ) |
name_ | The name of the service to be checked |
bool datatools::service_manager::has | ( | const std::string & | name_ | ) | const |
name_ | The name of the service to be checked |
bool datatools::service_manager::has_service_type | ( | const std::string & | id_ | ) | const |
Check if a service identifier/type is supported.
void datatools::service_manager::initialize | ( | ) |
Initialize the manager.
void datatools::service_manager::initialize | ( | const datatools::properties & | config_ | ) |
Initialize the manager from a container of properties.
|
protected |
Initialize a service from its entry.
bool datatools::service_manager::is_a | ( | const std::string & | name_ | ) | const |
name_ | The name of the service to be checked |
bool datatools::service_manager::is_allow_dynamic_services | ( | ) | const |
Check if dynamic services are allowed.
bool datatools::service_manager::is_debug | ( | ) | const |
Check the debug flag.
bool datatools::service_manager::is_force_initialization_at_load | ( | ) | const |
Check if the flag to force initialization of services at load is set.
bool datatools::service_manager::is_initialized | ( | ) | const |
Check the initialization flag.
bool datatools::service_manager::is_initialized | ( | const std::string & | name_ | ) | const |
name_ | The name of the service to be checked |
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.
void datatools::service_manager::load | ( | const datatools::multi_properties & | config_ | ) |
Load a set of services from a multi-service configuration.
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.
|
protected |
Load a service.
|
protected |
Load a service with or without initialization.
|
protected |
Preload the factory register from service factory system register.
void datatools::service_manager::register_service_type | ( | const std::string & | id_ | ) |
Register a service factory.
void datatools::service_manager::reset | ( | ) |
Reset the manager.
|
protected |
Reset a service from its entry.
void datatools::service_manager::set_allow_dynamic_services | ( | bool | ) |
Set the flag to allow_dynamic_services.
void datatools::service_manager::set_debug | ( | bool | debug_ = true | ) |
Set the debug flag.
void datatools::service_manager::set_description | ( | const std::string & | description_ | ) |
Set the description of the service.
void datatools::service_manager::set_force_initialization_at_load | ( | bool | ) |
Set the flag to force initialization of services at load.
void datatools::service_manager::set_logging_priority | ( | datatools::logger::priority | ) |
Set the logging priority threshold.
void datatools::service_manager::set_name | ( | const std::string & | name_ | ) |
Set the name of the service.
void datatools::service_manager::sync | ( | ) |
Synchronize internal data (expert only)
|
virtual |
Smart print.
Reimplemented from datatools::i_tree_dumpable.
void datatools::service_manager::unregister_service_type | ( | const std::string & | id_ | ) |
Unregister a service factory.
void datatools::service_manager::update_service_bus | ( | ) |
Update the bus of services (expert only)
|
friend |