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

A container of mapped properties objects. More...

#include <bayeux/datatools/multi_properties.h>

Inheritance diagram for datatools::multi_properties:
datatools::i_serializable datatools::i_clear datatools::i_tree_dumpable datatools::i_cloneable

Classes

class  config
 Reader/writer class for multi_properties objects. More...
 
struct  defaults
 Default values. More...
 
class  entry
 Section entry handle internal data stored within the dictionary of the multi_properties class. More...
 

Public Types

typedef std::map< std::string, entryentries_col_type
 Dictionary of section. More...
 
typedef std::list< entry * > entries_ordered_col_type
 List of handles on sections. 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

 multi_properties ()
 Default constructor. More...
 
 multi_properties (const std::string &key_label_, const std::string &meta_label_)
 Constructor specifying key label and meta label. More...
 
 multi_properties (const std::string &key_label_, const std::string &meta_label_, const std::string &description_, bool debug_=false)
 Constructor specifying key label, meta label, description and debug flag. More...
 
virtual ~multi_properties ()
 Destructor. More...
 
 multi_properties (const multi_properties &)
 Copy constructor. More...
 
multi_propertiesoperator= (const multi_properties &)
 Assignment operator. More...
 
bool is_debug () const
 Check the debug flag. More...
 
void set_debug (bool=true)
 Set the debug flag. More...
 
void set_description (const std::string &description_)
 Set the description. More...
 
bool has_description () const
 Check if a description is available. More...
 
const std::string & get_description () const
 Get the description. More...
 
bool has_key_label () const
 Check if the key label is set. More...
 
void set_key_label (const std::string &key_label_)
 Set the key label. More...
 
void clear_key_label ()
 Clear the key label. More...
 
const std::string & get_key_label () const
 Return the key label. More...
 
bool has_meta_label () const
 Check if the meta label is set. More...
 
void set_meta_label (const std::string &meta_label_)
 Set the meta label. More...
 
void clear_meta_label ()
 Clear the meta label. More...
 
const std::string & get_meta_label () const
 Return the meta label. More...
 
uint32_t size () const
 Return the number of entries. More...
 
bool empty () const
 Check if the collection of entries is empty. More...
 
void reset ()
 Reset. More...
 
virtual void clear ()
 Clear the dictionary of sections. More...
 
const entries_col_typeentries () const
 Return the const reference to the collection of entries. More...
 
const entries_ordered_col_typeordered_entries () const
 Return the const reference to the ordered collection of entries. More...
 
const entryget (const std::string &key_) const
 Return a const reference to the stored entry. More...
 
entrygrab (const std::string &key_)
 Return a mutable reference to the stored entry. More...
 
bool has_key (const std::string &key_) const
 Check if a section with a given key exists. More...
 
bool has_key_with_meta (const std::string &key_, const std::string &meta_) const
 Check if a section with given key and meta exists. More...
 
const std::string & key (int) const
 Returns the ith key. More...
 
const std::string & ordered_key (int) const
 Returns the ith ordered key. More...
 
std::vector< std::string > keys () const
 Return an array of keys. More...
 
void keys (std::vector< std::string > &keys_) const
 Build an array of keys. More...
 
std::vector< std::string > ordered_keys () const
 Return an array of orderered keys. More...
 
void ordered_keys (std::vector< std::string > &keys_) const
 Build an array of orderered keys. More...
 
bool has_section (const std::string &key_) const
 Check if a section exists. More...
 
const propertiesget_section (const std::string &key_) const
 Return the const reference to the properties store in a section. More...
 
const propertiesget_section_const (const std::string &key_) const
 Return the const reference to the properties store in a section. More...
 
propertiesgrab_section (const std::string &key_)
 Return the mutable reference to the properties store in a section. More...
 
void add (const std::string &key_, const std::string &meta_, const properties &props_)
 Add a new section with primary key, meta information text and a collection of properties. More...
 
void add (const std::string &key_, const properties &props_)
 Add a new section with primary key and a collection of properties. More...
 
void add (const std::string &key_, const std::string &meta_="")
 Add an empty section with primary key and meta information text. More...
 
propertiesadd_section (const std::string &key_, const std::string &meta_="")
 Add a new section with primary key and meta information text and return a mutable reference to the store collection of properties. More...
 
void remove (const std::string &key_)
 Remove a section. More...
 
void write (const std::string &filename_, uint32_t options_=config::HEADER_FOOTER|config::SKIP_PRIVATE_SECTIONS) const
 Write to a configuration file. More...
 
void read (const std::string &filename_, uint32_t options_=0)
 Read from a configuration file. More...
 
void dump (std::ostream &out_=std::clog) const
 Basic print. More...
 
void print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const override
 Smart print. More...
 
virtual void tree_dump (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
 
- 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_clear
virtual ~i_clear ()
 Destructor. 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
 
- Public Member Functions inherited from datatools::i_cloneable
virtual i_cloneableclone (void) const =0
 
virtual ~i_cloneable ()
 
template<class CandidateType >
bool is_cloneable (const CandidateType &candidate_)
 

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_)
 
- Static Public Member Functions inherited from datatools::i_cloneable
template<class Copyable >
static Copyable * clone_it (const Copyable &a_copyable)
 

Detailed Description

A container of mapped properties objects.

#include <iostream>
int main ()
{
{
datatools::multi_properties multi_parameters ("name", "type",
"Setup parameters of a networked random numbers server");
// Add a section for parameters dedicated to the network interface :
datatools::properties & server_section = multi_parameters.add_section ("server", "server_type");
server_section.store_flag ("verbose", "Verbose mode");
server_section.store ("max_number_of_connexions", 5, "Maximum number of simultaneous connections");
server_section.store ("port", 3456, "Port number");
server_section.store ("protocol", "UDP", "Current protocol");
// Add a section for parameters dedicated to an embedded pseuso-random number generator :
datatools::properties & prng_section = multi_parameters.add_section ("prng", "prng_type");
prng_section.store ("seed", 314159, "initial PRNG seed");
prng_section.store ("buffer_size", 1000, "Size of the buffer for pre-computed random numbers");
// Store all parameters in a ASCII test file :
multi_parameters.write ("prng_server.conf");
}
{
datatools::multi_properties multi_parameters;
multi_parameters.read ("prng_server.conf");
std::cout << "PRNG server configuration : " << std::endl;
multi_parameters.print_tree(std::cout);
// Check if a section with given name exists :
if (multi_parameters.has_section ("server")) {
const datatools::properties & server_section = multi_parameters.get_section ("server");
// Read a setup parameter from the section :
std::cout << "Port number : " << server_section.fetch_integer ("port");
}
}
return 0;
}

Member Typedef Documentation

◆ entries_col_type

typedef std::map<std::string, entry> datatools::multi_properties::entries_col_type

Dictionary of section.

◆ entries_ordered_col_type

List of handles on sections.

Constructor & Destructor Documentation

◆ multi_properties() [1/4]

datatools::multi_properties::multi_properties ( )

Default constructor.

◆ multi_properties() [2/4]

datatools::multi_properties::multi_properties ( const std::string &  key_label_,
const std::string &  meta_label_ 
)

Constructor specifying key label and meta label.

◆ multi_properties() [3/4]

datatools::multi_properties::multi_properties ( const std::string &  key_label_,
const std::string &  meta_label_,
const std::string &  description_,
bool  debug_ = false 
)

Constructor specifying key label, meta label, description and debug flag.

◆ ~multi_properties()

virtual datatools::multi_properties::~multi_properties ( )
virtual

Destructor.

◆ multi_properties() [4/4]

datatools::multi_properties::multi_properties ( const multi_properties )

Copy constructor.

Member Function Documentation

◆ add() [1/3]

void datatools::multi_properties::add ( const std::string &  key_,
const std::string &  meta_,
const properties props_ 
)

Add a new section with primary key, meta information text and a collection of properties.

◆ add() [2/3]

void datatools::multi_properties::add ( const std::string &  key_,
const properties props_ 
)

Add a new section with primary key and a collection of properties.

◆ add() [3/3]

void datatools::multi_properties::add ( const std::string &  key_,
const std::string &  meta_ = "" 
)

Add an empty section with primary key and meta information text.

◆ add_section()

properties& datatools::multi_properties::add_section ( const std::string &  key_,
const std::string &  meta_ = "" 
)

Add a new section with primary key and meta information text and return a mutable reference to the store collection of properties.

◆ clear()

virtual void datatools::multi_properties::clear ( )
virtual

Clear the dictionary of sections.

Implements datatools::i_clear.

◆ clear_key_label()

void datatools::multi_properties::clear_key_label ( )

Clear the key label.

◆ clear_meta_label()

void datatools::multi_properties::clear_meta_label ( )

Clear the meta label.

◆ dump()

void datatools::multi_properties::dump ( std::ostream &  out_ = std::clog) const

Basic print.

◆ empty()

bool datatools::multi_properties::empty ( ) const

Check if the collection of entries is empty.

◆ entries()

const entries_col_type& datatools::multi_properties::entries ( ) const

Return the const reference to the collection of entries.

◆ get()

const entry& datatools::multi_properties::get ( const std::string &  key_) const

Return a const reference to the stored entry.

◆ get_description()

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

Get the description.

◆ get_key_label()

const std::string& datatools::multi_properties::get_key_label ( ) const

Return the key label.

◆ get_meta_label()

const std::string& datatools::multi_properties::get_meta_label ( ) const

Return the meta label.

◆ get_section()

const properties& datatools::multi_properties::get_section ( const std::string &  key_) const

Return the const reference to the properties store in a section.

◆ get_section_const()

const properties& datatools::multi_properties::get_section_const ( const std::string &  key_) const

Return the const reference to the properties store in a section.

◆ grab()

entry& datatools::multi_properties::grab ( const std::string &  key_)

Return a mutable reference to the stored entry.

◆ grab_section()

properties& datatools::multi_properties::grab_section ( const std::string &  key_)

Return the mutable reference to the properties store in a section.

◆ has_description()

bool datatools::multi_properties::has_description ( ) const

Check if a description is available.

◆ has_key()

bool datatools::multi_properties::has_key ( const std::string &  key_) const

Check if a section with a given key exists.

◆ has_key_label()

bool datatools::multi_properties::has_key_label ( ) const

Check if the key label is set.

◆ has_key_with_meta()

bool datatools::multi_properties::has_key_with_meta ( const std::string &  key_,
const std::string &  meta_ 
) const

Check if a section with given key and meta exists.

◆ has_meta_label()

bool datatools::multi_properties::has_meta_label ( ) const

Check if the meta label is set.

◆ has_section()

bool datatools::multi_properties::has_section ( const std::string &  key_) const

Check if a section exists.

◆ is_debug()

bool datatools::multi_properties::is_debug ( ) const

Check the debug flag.

◆ key()

const std::string& datatools::multi_properties::key ( int  ) const

Returns the ith key.

◆ keys() [1/2]

std::vector<std::string> datatools::multi_properties::keys ( ) const

Return an array of keys.

◆ keys() [2/2]

void datatools::multi_properties::keys ( std::vector< std::string > &  keys_) const

Build an array of keys.

◆ operator=()

multi_properties& datatools::multi_properties::operator= ( const multi_properties )

Assignment operator.

◆ ordered_entries()

const entries_ordered_col_type& datatools::multi_properties::ordered_entries ( ) const

Return the const reference to the ordered collection of entries.

◆ ordered_key()

const std::string& datatools::multi_properties::ordered_key ( int  ) const

Returns the ith ordered key.

◆ ordered_keys() [1/2]

std::vector<std::string> datatools::multi_properties::ordered_keys ( ) const

Return an array of orderered keys.

◆ ordered_keys() [2/2]

void datatools::multi_properties::ordered_keys ( std::vector< std::string > &  keys_) const

Build an array of orderered keys.

◆ print_tree()

void datatools::multi_properties::print_tree ( std::ostream &  out_ = std::clog,
const boost::property_tree::ptree &  options_ = empty_options() 
) const
overridevirtual

Smart print.

Reimplemented from datatools::i_tree_dumpable.

◆ read()

void datatools::multi_properties::read ( const std::string &  filename_,
uint32_t  options_ = 0 
)

Read from a configuration file.

◆ remove()

void datatools::multi_properties::remove ( const std::string &  key_)

Remove a section.

◆ reset()

void datatools::multi_properties::reset ( )

Reset.

◆ set_debug()

void datatools::multi_properties::set_debug ( bool  = true)

Set the debug flag.

◆ set_description()

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

Set the description.

◆ set_key_label()

void datatools::multi_properties::set_key_label ( const std::string &  key_label_)

Set the key label.

◆ set_meta_label()

void datatools::multi_properties::set_meta_label ( const std::string &  meta_label_)

Set the meta label.

◆ size()

uint32_t datatools::multi_properties::size ( ) const

Return the number of entries.

◆ tree_dump()

virtual void datatools::multi_properties::tree_dump ( std::ostream &  out_ = std::clog,
const std::string &  title_ = "",
const std::string &  indent_ = "",
bool  inherit_ = false 
) const
virtual

Smart print

Deprecated:

Reimplemented from datatools::i_tree_dumpable.

◆ write()

void datatools::multi_properties::write ( const std::string &  filename_,
uint32_t  options_ = config::HEADER_FOOTER|config::SKIP_PRIVATE_SECTIONS 
) const

Write to a configuration file.


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