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

A class documenting an object addressed by its unique URN and linked to other objects (also addressed by URNs).. More...

#include <bayeux/datatools/urn_info.h>

Inheritance diagram for datatools::urn_info:
datatools::i_serializable datatools::i_tree_dumpable

Public Types

typedef std::map< std::string, std::vector< std::string > > component_topic_dict_type
 Dictionary of list of components addressed by topic. 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_info ()
 Default constructor. More...
 
 urn_info (const std::string &urn_, const std::string &category_, const std::string &description_="")
 Constructor with explicit path segments. More...
 
virtual ~urn_info ()
 Destructor. More...
 
bool is_valid () const
 Check validity. More...
 
void initialize (const properties &)
 Initialize. More...
 
void reset ()
 Clear the URN info. More...
 
void set_urn (const std::string &urn_)
 Set the URN. More...
 
const std::string & get_urn () const
 Return the URN. More...
 
bool has_category () const
 Check if category is set. More...
 
void set_category (const std::string &category_)
 Set the category. More...
 
const std::string & get_category () const
 Return the category. More...
 
void set_description (const std::string &description_)
 Set the description. More...
 
bool has_description () const
 Check if the description is set. More...
 
const std::string & get_description () const
 Return the description. More...
 
void lock ()
 Lock the record. More...
 
void unlock ()
 Unlock the record. More...
 
bool is_locked () const
 Check lock flag. More...
 
void remove_all_components ()
 Remove all components. More...
 
bool has_component (const std::string &comp_urn_) const
 Check if a component exists. More...
 
bool has_component_in_topic (const std::string &comp_urn_, const std::string &comp_topic_) const
 Check if a component exists in a given topic. More...
 
void add_component (const std::string &comp_urn_, const std::string &comp_topic_="")
 Add an URN component given its topic. More...
 
void remove_component (const std::string &comp_urn_)
 Remove an URN component. More...
 
bool has_components () const
 Check if URN components are set. More...
 
std::size_t get_number_of_components () const
 Return the total number of URN components. More...
 
std::size_t get_number_of_components_by_topic (const std::string &comp_topic_) const
 Return the number of URN components with given topic. More...
 
std::string get_component (const std::string &comp_topic_, int rank_=0) const
 Return the URN component with given topic at given rank. More...
 
bool has_topic (const std::string &comp_topic_) const
 Check if a given component topic is defined. More...
 
const std::vector< std::string > & get_components_by_topic (const std::string &comp_topic_) const
 Return the components associated to a given topic. More...
 
void build_topics (std::vector< std::string > &) const
 Build the current list of component topics. More...
 
std::vector< std::string > get_topics () const
 Return the current list of component topics. More...
 
virtual void tree_dump (std::ostream &out=std::clog, const std::string &title="", const std::string &indent="", bool inherit=false) const
 Main interface method for smart dump. More...
 
bool operator< (const urn_info &other_) const
 Basic comparison with respect to the URN name. 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...
 
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
 

Static Public Member Functions

static bool validate_urn (const std::string &)
 
static bool validate_category (const std::string &)
 Validate a category name. More...
 
static bool validate_topic (const std::string &)
 Validate a topic name. More...
 
static const std::string & anonymous_topic ()
 Return the anonymous topic. 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_)
 

Detailed Description

A class documenting an object addressed by its unique URN and linked to other objects (also addressed by URNs)..

An object A can be connected to other objects (B, C and D), known as components:

B A D
o <--------o -------> o
|
|
|
v
o
C

The nature of the relationship between the object and its "components" depends on the context. It is represented by a specific "topic" which represents a category of relationship. Example:

topic
A "dependency" B
o -------------------> o
depender dependee

Member Typedef Documentation

◆ component_topic_dict_type

typedef std::map<std::string, std::vector<std::string> > datatools::urn_info::component_topic_dict_type

Dictionary of list of components addressed by topic.

Constructor & Destructor Documentation

◆ urn_info() [1/2]

datatools::urn_info::urn_info ( )

Default constructor.

◆ urn_info() [2/2]

datatools::urn_info::urn_info ( const std::string &  urn_,
const std::string &  category_,
const std::string &  description_ = "" 
)

Constructor with explicit path segments.

◆ ~urn_info()

virtual datatools::urn_info::~urn_info ( )
virtual

Destructor.

Member Function Documentation

◆ add_component()

void datatools::urn_info::add_component ( const std::string &  comp_urn_,
const std::string &  comp_topic_ = "" 
)

Add an URN component given its topic.

◆ anonymous_topic()

static const std::string& datatools::urn_info::anonymous_topic ( )
static

Return the anonymous topic.

◆ build_topics()

void datatools::urn_info::build_topics ( std::vector< std::string > &  ) const

Build the current list of component topics.

◆ get_category()

const std::string& datatools::urn_info::get_category ( ) const

Return the category.

◆ get_component()

std::string datatools::urn_info::get_component ( const std::string &  comp_topic_,
int  rank_ = 0 
) const

Return the URN component with given topic at given rank.

◆ get_components_by_topic()

const std::vector<std::string>& datatools::urn_info::get_components_by_topic ( const std::string &  comp_topic_) const

Return the components associated to a given topic.

◆ get_description()

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

Return the description.

◆ get_number_of_components()

std::size_t datatools::urn_info::get_number_of_components ( ) const

Return the total number of URN components.

◆ get_number_of_components_by_topic()

std::size_t datatools::urn_info::get_number_of_components_by_topic ( const std::string &  comp_topic_) const

Return the number of URN components with given topic.

◆ get_topics()

std::vector<std::string> datatools::urn_info::get_topics ( ) const

Return the current list of component topics.

◆ get_urn()

const std::string& datatools::urn_info::get_urn ( ) const

Return the URN.

◆ has_category()

bool datatools::urn_info::has_category ( ) const

Check if category is set.

◆ has_component()

bool datatools::urn_info::has_component ( const std::string &  comp_urn_) const

Check if a component exists.

◆ has_component_in_topic()

bool datatools::urn_info::has_component_in_topic ( const std::string &  comp_urn_,
const std::string &  comp_topic_ 
) const

Check if a component exists in a given topic.

◆ has_components()

bool datatools::urn_info::has_components ( ) const

Check if URN components are set.

◆ has_description()

bool datatools::urn_info::has_description ( ) const

Check if the description is set.

◆ has_topic()

bool datatools::urn_info::has_topic ( const std::string &  comp_topic_) const

Check if a given component topic is defined.

◆ initialize()

void datatools::urn_info::initialize ( const properties )

Initialize.

Example:

#@description Thr URN identifier
urn : string = "urn:fooexp:analysis:setup:1.0"
#@description Short description text
description : string = "Foo experiment data analysis setup 1.0"
#@description List of topics on which URN info relies/depends on
topics : string[2] = "geometry" "input""
#@description Unique component associated to the 'geometry' topic
topic.geometry.component : string = "urn:fooexp:geometry:setup:1.0"
#@description Several components associated to the 'input' topic
topic.input.components : string[3] = \\
"urn:fooexp:dataset:1" \\
"urn:fooexp:dataset:2" \\
"urn:fooexp:dataset:3"

◆ is_locked()

bool datatools::urn_info::is_locked ( ) const

Check lock flag.

◆ is_valid()

bool datatools::urn_info::is_valid ( ) const

Check validity.

◆ lock()

void datatools::urn_info::lock ( )

Lock the record.

◆ operator<()

bool datatools::urn_info::operator< ( const urn_info other_) const

Basic comparison with respect to the URN name.

◆ remove_all_components()

void datatools::urn_info::remove_all_components ( )

Remove all components.

◆ remove_component()

void datatools::urn_info::remove_component ( const std::string &  comp_urn_)

Remove an URN component.

◆ reset()

void datatools::urn_info::reset ( )

Clear the URN info.

◆ set_category()

void datatools::urn_info::set_category ( const std::string &  category_)

Set the category.

◆ set_description()

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

Set the description.

◆ set_urn()

void datatools::urn_info::set_urn ( const std::string &  urn_)

Set the URN.

◆ tree_dump()

virtual void datatools::urn_info::tree_dump ( std::ostream &  out = std::clog,
const std::string &  title = "",
const std::string &  indent = "",
bool  inherit = false 
) const
virtual

Main interface method for smart dump.

Reimplemented from datatools::i_tree_dumpable.

◆ unlock()

void datatools::urn_info::unlock ( )

Unlock the record.

◆ validate_category()

static bool datatools::urn_info::validate_category ( const std::string &  )
static

Validate a category name.

◆ validate_topic()

static bool datatools::urn_info::validate_topic ( const std::string &  )
static

Validate a topic name.

◆ validate_urn()

static bool datatools::urn_info::validate_urn ( const std::string &  )
static

Validate an URN representation

Format:

urn:namespace:path[:to[:some[:object[:...]]]]

Examples:

urn:snemo
urn:snemo:people:johndoe
urn:snemo:demonstrator:simulation:setup:2.1
urn:snemo:demonstrator:simulation:data:0
urn:snemo:demonstrator:simulation:data:1
urn:snemo:geometry:setup:4.0
urn:bipo:data:raw:run_1:metadata
urn:bipo:data:raw:run_1:logfile
urn:bipo:data:raw:run_1:data:0
urn:bipo:data:raw:run_1:data:1
urn:bipo:data:raw:run_1:data:2

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