Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
datatools::urn_db_service Class Reference

A service with a dictionary of URN informations. More...

#include <bayeux/datatools/urn_db_service.h>

Inheritance diagram for datatools::urn_db_service:
datatools::base_service datatools::enriched_base datatools::i_serializable datatools::i_tree_dumpable

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_entrydependee_db_dict_type
 Dictionary of external dependee URN database services. More...
 
typedef std::map< std::string, urn_recordurn_record_dict_type
 URN record dictionary. More...
 
typedef std::map< std::string, backward_linksbackward_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_infoadd (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_infoget (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_baseset_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_baseset_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_baseset_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::propertiesget_auxiliaries () const
 Return a reference to the non mutable container of auxiliary properties. More...
 
datatools::propertiesgrab_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_baseset_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_)
 

Detailed Description

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:

[from] "dependency" [to]
o --------------------> o
"depender" "dependee"

or a composition:

[from] "composition" [to]
o --------------------> o
"composite" "element"

or a service:

[from] "service" [to]
o --------------------> o
"client" "server"

or a subscription:

[from] "subscription" [to]
o --------------------> o
"subscriber" "service"

or a usage:

[from] "usage" [to]
o --------------------> o
"application" "data"

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.

/*
* urn1
* [to]...o
* /|\ \
* ^ / | \ \ backward
* / / | \ \ links
* forward / / | \ \
* links / / | \ \
* / / | \ \
* / / | \ v
* [from]...o.......o.......o
* urn2 urn3 urn4
*

It is forbidden to create cycles of links between nodes:

urn1 o <-----------------.
\ \
\ \
`-----------------> o urn2
urn1
.o
/ ^
/ \
/ \
/ \
/ \
/ \
v \
o ------------> o
urn2 urn3

In terms of the Boost Graph Library, URN nodes are "vertices", forward links are "out-edges". Backward links are "in-edges".

Member Typedef Documentation

◆ backward_links_dict_type

Dictionary of backward links.

◆ dependee_db_dict_type

Dictionary of external dependee URN database services.

◆ urn_record_dict_type

URN record dictionary.

Member Enumeration Documentation

◆ urn_select_flag

URN record selection flags.

Enumerator
SELECT_NOCLEAR 
SELECT_LOCAL 
SELECT_MOUNTED 
SELECT_REMOVABLE 
SELECT_LINKED 

Constructor & Destructor Documentation

◆ urn_db_service()

datatools::urn_db_service::urn_db_service ( )

Default constructor.

◆ ~urn_db_service()

virtual datatools::urn_db_service::~urn_db_service ( )
virtual

Destructor.

Member Function Documentation

◆ add()

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.

◆ add_allowed_category()

void datatools::urn_db_service::add_allowed_category ( const std::string &  category_)

Add an allowed category.

◆ add_allowed_link_topic()

void datatools::urn_db_service::add_allowed_link_topic ( const std::string &  link_topic_)

Add an allowed link topic.

◆ add_link() [1/2]

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]

URN-from "forward topic >" URN-to
o ----------------------> o

◆ add_link() [2/2]

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].

◆ add_mounted()

void datatools::urn_db_service::add_mounted ( const std::string &  external_db_,
const std::string &  mounted_urn_ 
)

Add a mounted URN.

◆ build_list_of_urns()

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.

◆ check_category()

bool datatools::urn_db_service::check_category ( const std::string &  category_) const

Check if a category is allowed.

◆ check_link_topic()

bool datatools::urn_db_service::check_link_topic ( const std::string &  link_topic_) const

Check if a link topic is allowed.

◆ connect_db()

void datatools::urn_db_service::connect_db ( const urn_db_service db_)

Connect to an external URN database dependee service.

◆ get()

const urn_info& datatools::urn_db_service::get ( const std::string &  ) const

Return the URN info.

◆ get_allowed_categories()

const std::set<std::string>& datatools::urn_db_service::get_allowed_categories ( ) const

Return allowed categories.

◆ get_allowed_link_topics()

const std::set<std::string>& datatools::urn_db_service::get_allowed_link_topics ( ) const

Return allowed link topics.

◆ get_dependees()

std::set<std::string> datatools::urn_db_service::get_dependees ( ) const

Return the list of dependees.

◆ get_number_of_urn_records()

std::size_t datatools::urn_db_service::get_number_of_urn_records ( ) const

Return the number of URN records.

◆ has()

bool datatools::urn_db_service::has ( const std::string &  urn_) const

Check if URN info exists.

◆ has_allowed_category()

bool datatools::urn_db_service::has_allowed_category ( const std::string &  category_) const

Check if a category is a allowed.

◆ has_allowed_link_topic()

bool datatools::urn_db_service::has_allowed_link_topic ( const std::string &  link_topic_) const

Check if a link topic is a allowed.

◆ has_backward_links()

bool datatools::urn_db_service::has_backward_links ( const std::string &  urn_) const

Check if a URN record has backward links.

◆ has_dependees()

bool datatools::urn_db_service::has_dependees ( ) const

Check if the db has dependees.

◆ has_explicit_allowed_categories()

bool datatools::urn_db_service::has_explicit_allowed_categories ( ) const

Check if explicit allowed categories are defined.

◆ has_explicit_allowed_link_topics()

bool datatools::urn_db_service::has_explicit_allowed_link_topics ( ) const

Check if explicit allowed link topics are defined.

◆ has_links()

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)

◆ initialize()

virtual int datatools::urn_db_service::initialize ( const datatools::properties config_,
datatools::service_dict_type services_ 
)
virtual

Initialize the service from a list of properties.

Implements datatools::base_service.

◆ is_allow_mounted()

bool datatools::urn_db_service::is_allow_mounted ( ) const

Check if mounted URN are allowed.

◆ is_initialized()

virtual bool datatools::urn_db_service::is_initialized ( ) const
virtual

Check initialization status.

Implements datatools::base_service.

◆ is_kernel_pushed()

bool datatools::urn_db_service::is_kernel_pushed ( ) const

Check if the service is pushed (registered) in the kernel.

◆ is_linked_to()

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.

◆ is_local()

bool datatools::urn_db_service::is_local ( const std::string &  urn_) const

Check if an URN is local.

◆ is_locked()

bool datatools::urn_db_service::is_locked ( ) const

Check if the service is locked.

◆ is_mounted()

bool datatools::urn_db_service::is_mounted ( const std::string &  urn_) const

Check if an URN is mounted.

◆ is_removable()

bool datatools::urn_db_service::is_removable ( const std::string &  urn_) const

Check if a URN record can be removed.

◆ kernel_pop()

void datatools::urn_db_service::kernel_pop ( )

Remove from system.

◆ kernel_push()

void datatools::urn_db_service::kernel_push ( const std::string &  name_ = "")

Add to system.

◆ load()

void datatools::urn_db_service::load ( const std::string &  filename_)

Load an URN info definition file.

◆ load_csv()

void datatools::urn_db_service::load_csv ( const std::string &  filename_)

Load a list of URN records without components from a CSV file.

◆ lock()

void datatools::urn_db_service::lock ( )

Lock the service.

◆ parse_mount_rule()

static bool datatools::urn_db_service::parse_mount_rule ( const std::string &  rule_,
std::string &  external_db_,
std::string &  mounted_urn_ 
)
static

Parse mount rule.

◆ remove()

void datatools::urn_db_service::remove ( const std::string &  urn_)

Remove an URN info.

◆ remove_all_links()

void datatools::urn_db_service::remove_all_links ( const std::string &  urn_from_)

Remove all links from a URN record.

◆ remove_allowed_category()

void datatools::urn_db_service::remove_allowed_category ( const std::string &  category_)

Remove an allowed category.

◆ remove_allowed_link_topic()

void datatools::urn_db_service::remove_allowed_link_topic ( const std::string &  link_topic_)

Remove an allowed link topic.

◆ remove_link() [1/2]

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.

◆ remove_link() [2/2]

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.

◆ reset()

virtual int datatools::urn_db_service::reset ( )
virtual

Reset.

Implements datatools::base_service.

◆ set_allow_mounted()

void datatools::urn_db_service::set_allow_mounted ( bool  m_)

Set allowed mounted flag.

◆ tree_dump()

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

◆ unlock()

void datatools::urn_db_service::unlock ( )

Unlock the service.


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