Bayeux
3.4.1
Core Foundation library for SuperNEMO
|
A service with a dictionary of URN informations. More...
#include <bayeux/datatools/urn_db_service.h>
Classes | |
struct | backward_links |
List of [from] URN node backward pointing links associated to a [to] URN node. More... | |
struct | dependee_db_entry |
External dependee URN database service. More... | |
struct | dependency_graph_builder |
Populated a dependency graph. More... | |
struct | urn_record |
URN record. More... | |
Public Types | |
enum | urn_select_flag { SELECT_NOCLEAR = bit_mask::bit00, SELECT_LOCAL = bit_mask::bit01, SELECT_MOUNTED = bit_mask::bit02, SELECT_REMOVABLE = bit_mask::bit03, SELECT_LINKED = bit_mask::bit04 } |
URN record selection flags. More... | |
typedef std::map< std::string, dependee_db_entry > | dependee_db_dict_type |
Dictionary of external dependee URN database services. More... | |
typedef std::map< std::string, urn_record > | urn_record_dict_type |
URN record dictionary. More... | |
typedef std::map< std::string, backward_links > | backward_links_dict_type |
Dictionary of backward links. More... | |
Public Types inherited from datatools::enriched_base | |
enum | export_config_flags { EXPORT_CONFIG_CLEAR = bit_mask::bit00, EXPORT_CONFIG_NAME = bit_mask::bit01, EXPORT_CONFIG_DISPLAY_NAME = bit_mask::bit02, EXPORT_CONFIG_TERSE_DESCRIPTION = bit_mask::bit03, EXPORT_CONFIG_LOGGING_PRIORITY = bit_mask::bit04, EXPORT_CONFIG_AUXILIARIES = bit_mask::bit05, EXPORT_CONFIG_DEFAULT, EXPORT_CONFIG_LAST = EXPORT_CONFIG_AUXILIARIES } |
Flags for export to a container of properties. 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 | |
urn_db_service () | |
Default constructor. More... | |
virtual | ~urn_db_service () |
Destructor. More... | |
bool | is_allow_mounted () const |
Check if mounted URN are allowed. More... | |
void | set_allow_mounted (bool m_) |
Set allowed mounted flag. More... | |
bool | has_explicit_allowed_categories () const |
Check if explicit allowed categories are defined. More... | |
bool | has_allowed_category (const std::string &category_) const |
Check if a category is a allowed. More... | |
void | add_allowed_category (const std::string &category_) |
Add an allowed category. More... | |
void | remove_allowed_category (const std::string &category_) |
Remove an allowed category. More... | |
const std::set< std::string > & | get_allowed_categories () const |
Return allowed categories. More... | |
bool | check_category (const std::string &category_) const |
Check if a category is allowed. More... | |
bool | has_allowed_link_topic (const std::string &link_topic_) const |
Check if a link topic is a allowed. More... | |
bool | has_explicit_allowed_link_topics () const |
Check if explicit allowed link topics are defined. More... | |
void | add_allowed_link_topic (const std::string &link_topic_) |
Add an allowed link topic. More... | |
void | remove_allowed_link_topic (const std::string &link_topic_) |
Remove an allowed link topic. More... | |
const std::set< std::string > & | get_allowed_link_topics () const |
Return allowed link topics. More... | |
bool | check_link_topic (const std::string &link_topic_) const |
Check if a link topic is allowed. More... | |
void | connect_db (const urn_db_service &db_) |
Connect to an external URN database dependee service. More... | |
bool | has_dependees () const |
Check if the db has dependees. More... | |
std::set< std::string > | get_dependees () const |
Return the list of dependees. More... | |
virtual bool | is_initialized () const |
Check initialization status. More... | |
virtual int | initialize (const datatools::properties &config_, datatools::service_dict_type &services_) |
Initialize the service from a list of properties. More... | |
virtual int | reset () |
Reset. 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 | load (const std::string &filename_) |
Load an URN info definition file. More... | |
void | load_csv (const std::string &filename_) |
Load a list of URN records without components from a CSV file. More... | |
bool | is_mounted (const std::string &urn_) const |
Check if an URN is mounted. More... | |
bool | is_local (const std::string &urn_) const |
Check if an URN is local. More... | |
void | add_mounted (const std::string &external_db_, const std::string &mounted_urn_) |
Add a mounted URN. More... | |
const urn_info & | add (const std::string &urn_, const std::string &category_, const std::string &description_="") |
Add a new URN info. More... | |
void | remove (const std::string &urn_) |
Remove an URN info. More... | |
bool | add_link (const std::string &urn_from_, const std::string &urn_to_, const std::string &forward_topic_, std::string &errmsg_) |
void | add_link (const std::string &urn_from_, const std::string &urn_to_, const std::string &forward_topic_) |
Add a forward link with given topic from one [from] URN record to another [to]. More... | |
bool | remove_link (const std::string &urn_from_, const std::string &urn_to_, std::string &errmsg_) |
Remove a link between two URN info records. More... | |
void | remove_link (const std::string &urn_from_, const std::string &urn_to_) |
Remove a link between two URN info records. More... | |
void | remove_all_links (const std::string &urn_from_) |
Remove all links from a URN record. More... | |
bool | is_linked_to (const std::string &urn_, const std::string &other_urn_, const std::string &topic_="") const |
Check if an URN record is linked to another one through a certain topic. More... | |
bool | has_links (const std::string &urn_) const |
Check if an URN record is linked to some other ones (forward links only) More... | |
bool | has (const std::string &urn_) const |
Check if URN info exists. More... | |
const urn_info & | get (const std::string &) const |
Return the URN info. More... | |
std::size_t | get_number_of_urn_records () const |
Return the number of URN records. More... | |
void | build_list_of_urns (std::vector< std::string > &urns_, const uint32_t flags_) const |
Build the list of registered URNs. More... | |
bool | has_backward_links (const std::string &urn_) const |
Check if a URN record has backward links. More... | |
bool | is_removable (const std::string &urn_) const |
Check if a URN record can be removed. More... | |
bool | is_locked () const |
Check if the service is locked. More... | |
void | lock () |
Lock the service. More... | |
void | unlock () |
Unlock the service. More... | |
void | kernel_push (const std::string &name_="") |
Add to system. More... | |
void | kernel_pop () |
Remove from system. More... | |
bool | is_kernel_pushed () const |
Check if the service is pushed (registered) in the kernel. More... | |
Public Member Functions inherited from datatools::base_service | |
base_service () | |
Default constructor. More... | |
base_service (const std::string &name_, const std::string &display_name_="", const std::string &description_="", logger::priority lp_=logger::PRIO_FATAL) | |
Constructor. More... | |
virtual | ~base_service () |
Destructor. More... | |
virtual void | fetch_dependencies (service_dependency_dict_type &) const |
Undocumented unused/unimplemented method. More... | |
virtual int | initialize_simple () |
Initialize the service without a list of properties nor other services. More... | |
virtual int | initialize_standalone (const datatools::properties &config_) |
Initialize the service using only a list of properties without the needs of other services. More... | |
virtual int | initialize_with_services (service_dict_type &service_dict_) |
Initialize the service using with access to a dictionary of other services. More... | |
virtual std::string | service_class_id () const =0 |
Return the service class. More... | |
void | print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const override |
Smart print. More... | |
Public Member Functions inherited from datatools::enriched_base | |
virtual bool | is_name_valid (const std::string &name_) const |
Check if a name is valid. More... | |
enriched_base () | |
Default constructor. More... | |
enriched_base (const std::string &name_, const std::string &display_name_="", const std::string &terse_description_="", logger::priority lp_=logger::PRIO_FATAL) | |
Constructor. More... | |
virtual | ~enriched_base () |
Destructor. More... | |
bool | has_name () const |
Check if the name is not empty. More... | |
void | set_name (const std::string &name_) |
Set the name. More... | |
enriched_base & | set_name_c (const std::string &name_) |
Set the name. More... | |
const std::string & | get_name () const |
Return the name. More... | |
void | reset_name () |
Reset the name. More... | |
bool | has_display_name () const |
Check if the display name is empty. More... | |
void | set_display_name (const std::string &display_name_) |
Set the display name. More... | |
enriched_base & | set_display_name_c (const std::string &display_name_) |
Set the display name. More... | |
const std::string & | get_display_name () const |
Return the display name. More... | |
bool | has_terse_description () const |
Check if the description is empty. More... | |
void | set_terse_description (const std::string &terse_description_) |
Set the description. More... | |
enriched_base & | set_terse_description_c (const std::string &terse_description_) |
Set the description. More... | |
const std::string & | get_terse_description () const |
Return the description. More... | |
bool | has_auxiliaries () const |
Check if the container of auxiliary properties is empty. More... | |
const datatools::properties & | get_auxiliaries () const |
Return a reference to the non mutable container of auxiliary properties. More... | |
datatools::properties & | grab_auxiliaries () |
Return a reference to the mutable container of auxiliary properties. More... | |
void | reset_auxiliaries () |
Remove all auxiliary properties. More... | |
bool | is_debug () const |
Check the debug status. More... | |
void | set_logging_priority (logger::priority lp_) |
Set the logging priority threshold. More... | |
enriched_base & | set_logging_priority_c (logger::priority lp_) |
Set the logging priority threshold. More... | |
void | set_logging (const std::string &label_) |
Set the logging priority threshold from a string. More... | |
logger::priority | get_logging_priority () const |
Return the logging priority threshold. More... | |
void | clear () |
Clear. More... | |
void | reset () |
Clear. More... | |
void | print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const override |
Smart print. More... | |
void | initialize (const datatools::properties &config_, bool clear_=false) |
Initialization from a container of properties. More... | |
void | export_to_config (datatools::properties &config_, uint32_t flags_=EXPORT_CONFIG_DEFAULT, const std::string &prefix_="") const |
Export to a container of properties. More... | |
Public Member Functions inherited from datatools::i_serializable | |
i_serializable () | |
Default constructor. More... | |
virtual | ~i_serializable () |
Destructor. More... | |
virtual const std::string & | get_serial_tag () const =0 |
Return the serialization string identifier of the class. More... | |
Public Member Functions inherited from datatools::i_tree_dumpable | |
i_tree_dumpable () | |
Constructor. More... | |
virtual | ~i_tree_dumpable () |
Destructor. 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 |
Static Public Member Functions | |
static bool | parse_mount_rule (const std::string &rule_, std::string &external_db_, std::string &mounted_urn_) |
Parse mount rule. More... | |
Static Public Member Functions inherited from datatools::base_service | |
static void | common_ocd (datatools::object_configuration_description &ocd_) |
Basic OCD support shared by all inherited modules. More... | |
Static Public Member Functions inherited from datatools::enriched_base | |
static bool | validate_name (const std::string &candidate_name_) |
Validate a name. More... | |
static logger::priority | default_logging_priority () |
Return the default logging priority threshold. More... | |
static void | init_ocd (datatools::object_configuration_description &) |
OCD support. More... | |
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_) |
Additional Inherited Members | |
Protected Member Functions inherited from datatools::base_service | |
void | _common_initialize (const datatools::properties &config_) |
Common initialization of services. More... | |
void | common_initialize (const datatools::properties &config_) |
A service with a dictionary of URN informations.
This service describes not only a collection of objects addresses by their unique URNs but also the relationships between these objects.
Objects addresses through their URN are connected via "links". A link represents an unidirectional relationship between two nodes conventionaly labelled [from] and [to]. The [from] node can be considered as the client which explicitely depends on the [to] node, considered as the server. The exact nature of the relationship depends on the context. For example, it may express a dependency:
or a composition:
or a service:
or a subscription:
or a usage:
A link is always defined on the [from] node's side, i.e. from the object which explicitly depends on the object pointed by the link (forward link), because such an object cannot exist or work without the explicit knowledge of the objects to which it is connected. The service keeps also records about the backward links, i.e. links pointing from [to] to [from] nodes. This way, it is possible to know whether or not a node can be safely removed because no other node points to it.
It is forbidden to create cycles of links between nodes:
In terms of the Boost Graph Library, URN nodes are "vertices", forward links are "out-edges". Backward links are "in-edges".
typedef std::map<std::string, backward_links> datatools::urn_db_service::backward_links_dict_type |
Dictionary of backward links.
typedef std::map<std::string, dependee_db_entry> datatools::urn_db_service::dependee_db_dict_type |
Dictionary of external dependee URN database services.
typedef std::map<std::string, urn_record> datatools::urn_db_service::urn_record_dict_type |
URN record dictionary.
datatools::urn_db_service::urn_db_service | ( | ) |
Default constructor.
|
virtual |
Destructor.
const urn_info& datatools::urn_db_service::add | ( | const std::string & | urn_, |
const std::string & | category_, | ||
const std::string & | description_ = "" |
||
) |
Add a new URN info.
void datatools::urn_db_service::add_allowed_category | ( | const std::string & | category_ | ) |
Add an allowed category.
void datatools::urn_db_service::add_allowed_link_topic | ( | const std::string & | link_topic_ | ) |
Add an allowed link topic.
bool datatools::urn_db_service::add_link | ( | const std::string & | urn_from_, |
const std::string & | urn_to_, | ||
const std::string & | forward_topic_, | ||
std::string & | errmsg_ | ||
) |
Add a forward link with given topic from one [from] URN record to another [to]
void datatools::urn_db_service::add_link | ( | const std::string & | urn_from_, |
const std::string & | urn_to_, | ||
const std::string & | forward_topic_ | ||
) |
Add a forward link with given topic from one [from] URN record to another [to].
void datatools::urn_db_service::add_mounted | ( | const std::string & | external_db_, |
const std::string & | mounted_urn_ | ||
) |
Add a mounted URN.
void datatools::urn_db_service::build_list_of_urns | ( | std::vector< std::string > & | urns_, |
const uint32_t | flags_ | ||
) | const |
Build the list of registered URNs.
bool datatools::urn_db_service::check_category | ( | const std::string & | category_ | ) | const |
Check if a category is allowed.
bool datatools::urn_db_service::check_link_topic | ( | const std::string & | link_topic_ | ) | const |
Check if a link topic is allowed.
void datatools::urn_db_service::connect_db | ( | const urn_db_service & | db_ | ) |
Connect to an external URN database dependee service.
const std::set<std::string>& datatools::urn_db_service::get_allowed_categories | ( | ) | const |
Return allowed categories.
const std::set<std::string>& datatools::urn_db_service::get_allowed_link_topics | ( | ) | const |
Return allowed link topics.
std::set<std::string> datatools::urn_db_service::get_dependees | ( | ) | const |
Return the list of dependees.
std::size_t datatools::urn_db_service::get_number_of_urn_records | ( | ) | const |
Return the number of URN records.
bool datatools::urn_db_service::has | ( | const std::string & | urn_ | ) | const |
Check if URN info exists.
bool datatools::urn_db_service::has_allowed_category | ( | const std::string & | category_ | ) | const |
Check if a category is a allowed.
bool datatools::urn_db_service::has_allowed_link_topic | ( | const std::string & | link_topic_ | ) | const |
Check if a link topic is a allowed.
bool datatools::urn_db_service::has_backward_links | ( | const std::string & | urn_ | ) | const |
Check if a URN record has backward links.
bool datatools::urn_db_service::has_dependees | ( | ) | const |
Check if the db has dependees.
bool datatools::urn_db_service::has_explicit_allowed_categories | ( | ) | const |
Check if explicit allowed categories are defined.
bool datatools::urn_db_service::has_explicit_allowed_link_topics | ( | ) | const |
Check if explicit allowed link topics are defined.
bool datatools::urn_db_service::has_links | ( | const std::string & | urn_ | ) | const |
Check if an URN record is linked to some other ones (forward links only)
|
virtual |
Initialize the service from a list of properties.
Implements datatools::base_service.
bool datatools::urn_db_service::is_allow_mounted | ( | ) | const |
Check if mounted URN are allowed.
|
virtual |
Check initialization status.
Implements datatools::base_service.
bool datatools::urn_db_service::is_kernel_pushed | ( | ) | const |
Check if the service is pushed (registered) in the kernel.
bool datatools::urn_db_service::is_linked_to | ( | const std::string & | urn_, |
const std::string & | other_urn_, | ||
const std::string & | topic_ = "" |
||
) | const |
Check if an URN record is linked to another one through a certain topic.
bool datatools::urn_db_service::is_local | ( | const std::string & | urn_ | ) | const |
Check if an URN is local.
bool datatools::urn_db_service::is_locked | ( | ) | const |
Check if the service is locked.
bool datatools::urn_db_service::is_mounted | ( | const std::string & | urn_ | ) | const |
Check if an URN is mounted.
bool datatools::urn_db_service::is_removable | ( | const std::string & | urn_ | ) | const |
Check if a URN record can be removed.
void datatools::urn_db_service::kernel_pop | ( | ) |
Remove from system.
void datatools::urn_db_service::kernel_push | ( | const std::string & | name_ = "" | ) |
Add to system.
void datatools::urn_db_service::load | ( | const std::string & | filename_ | ) |
Load an URN info definition file.
void datatools::urn_db_service::load_csv | ( | const std::string & | filename_ | ) |
Load a list of URN records without components from a CSV file.
void datatools::urn_db_service::lock | ( | ) |
Lock the service.
|
static |
Parse mount rule.
void datatools::urn_db_service::remove | ( | const std::string & | urn_ | ) |
Remove an URN info.
void datatools::urn_db_service::remove_all_links | ( | const std::string & | urn_from_ | ) |
Remove all links from a URN record.
void datatools::urn_db_service::remove_allowed_category | ( | const std::string & | category_ | ) |
Remove an allowed category.
void datatools::urn_db_service::remove_allowed_link_topic | ( | const std::string & | link_topic_ | ) |
Remove an allowed link topic.
bool datatools::urn_db_service::remove_link | ( | const std::string & | urn_from_, |
const std::string & | urn_to_, | ||
std::string & | errmsg_ | ||
) |
Remove a link between two URN info records.
void datatools::urn_db_service::remove_link | ( | const std::string & | urn_from_, |
const std::string & | urn_to_ | ||
) |
Remove a link between two URN info records.
|
virtual |
Reset.
Implements datatools::base_service.
void datatools::urn_db_service::set_allow_mounted | ( | bool | m_ | ) |
Set allowed mounted flag.
|
virtual |
Smart print.
Reimplemented from datatools::base_service.
void datatools::urn_db_service::unlock | ( | ) |
Unlock the service.