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

A generic serializable and noncopyable container for arbitrary serializable objects. More...

#include <bayeux/datatools/things.h>

Inheritance diagram for datatools::things:
datatools::i_serializable datatools::i_tree_dumpable datatools::i_clear

Classes

struct  entry_type
 Internal entry for serializable object stored in the thing class. More...
 

Public Types

typedef std::map< std::string, entry_typedict_type
 Embedded dictionary of arbitrary serializable objects. 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

 things ()
 Default constructor. More...
 
 things (const std::string &name_, const std::string &description_="")
 Constructor with name and description. More...
 
virtual ~things ()
 
const std::string & get_name () const
 Return the name of the container. More...
 
thingsset_name (const std::string &)
 Set the name of the container. More...
 
const std::string & get_name_impl () const
 Return the name of the container (low-level implementation) More...
 
void set_name_impl (const std::string &)
 Set the name of the container (low-level implementation) More...
 
bool has_name () const
 Check if the container has a name. More...
 
bool has_name_impl () const
 Check if the container has a name (low-level implementation) More...
 
const std::string & get_description () const
 Return the description of the container. More...
 
thingsset_description (const std::string &)
 Set the description of the container. More...
 
void set_description_impl (const std::string &)
 Set the description of the container (low-level implementation) More...
 
const std::string & get_description_impl () const
 Return the description of the container (low-level implementation) More...
 
bool has_description_impl () const
 Check if the container has a description (low-level implementation) More...
 
void reset ()
 Reset the container. More...
 
virtual void clear ()
 Clear the container. More...
 
unsigned int size () const
 Return the number of objects stored in the container. More...
 
bool empty () const
 Check if the container is empty. More...
 
bool has (const std::string &name_) const
 Check if the container stores an object with a given name. More...
 
bool has_serial_tag (const std::string &name_, const std::string &serial_tag_) const
 Check if the container stores an object with a given name and a given serial tag. More...
 
bool is_constant (const std::string &name_) const
 Check if the object stored is the container with a given name is constant. More...
 
bool is_mutable (const std::string &name_) const
 Check if the object stored is the container with a given name is mutable. More...
 
void set_constant (const std::string &name_, bool const_=true)
 not implemented : More...
 
const std::string & get_description (const std::string &name_) const
 Return the description of the object stored with a given name. More...
 
const std::string & get_entry_description (const std::string &name_) const
 Return the description of the object stored with a given name. More...
 
void set_description (const std::string &name_, const std::string &desc_)
 Set the description of the object stored with a given name. More...
 
void set_entry_description (const std::string &name_, const std::string &desc_)
 Set the description of the object stored with a given name. More...
 
void get_names (std::vector< std::string > &names_) const
 Build the list of names of all objects stored in the container. More...
 
const std::string & get_entry_name (int index_) const
 Return the name of the object stored at a given index. More...
 
void remove (const std::string &name_)
 Remove the object stored in the container with a given name. More...
 
void erase (const std::string &name_)
 Remove the object stored in the container with a given name. More...
 
template<class T >
T & add (const std::string &name_, const std::string &desc_="", bool const_=false)
 Instantiate and add an object of given type and name. More...
 
template<class T >
T * pop (const std::string &name_)
 
template<class T >
T & grab (const std::string &name_)
 Return a reference to a mutable object of given type and name. More...
 
template<class T >
bool is_a (const std::string &name_) const
 Check if a stored object with given name is of given type. More...
 
template<class T >
const T & get (const std::string &name_) const
 Return a reference to a non mutable object of given type and name. More...
 
const datatools::i_serializableget_entry (const std::string &name_) const
 Return a reference to a non mutable stored object of given name. More...
 
datatools::i_serializablegrab_entry (const std::string &name_)
 Return a reference to a mutable stored object of given name. More...
 
datatools::i_serializableadd_entry (const std::string &name_, const std::string &serial_tag_, const std::string &description_="", bool const_=false)
 Instantiate and add an object of given type id with given name, description and constness flag. More...
 
datatools::i_serializableadd_entry_impl (const std::string &name_, const std::string &serial_tag_, const std::string &description_, bool const_)
 Instantiate and add an object of given type id with given name, description and constness flag (implementation) More...
 
bool entry_is_a (const std::string &name_, const std::string &) const
 Check if a stored object with given name has a type with given type id. More...
 
bool entry_is_introspectable (const std::string &name_) const
 Check if a stored object with given name is introspectable through CAMP interface. More...
 
std::string get_entry_serial_tag (const std::string &name_) const
 Return the serial tag of a stored object with given name. More...
 
std::string get_entry_introspection_id (const std::string &name_) const
 Return the introspection id of a stored object with given name. 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 dump (std::ostream &out_=std::clog) const
 Basic print. More...
 
datatools::i_serializablegrab (const std::string &name_, const std::string &serial_tag_="")
 Return a mutable reference to an object of given name and optional type id. More...
 
const datatools::i_serializableget (const std::string &name_, const std::string &serial_tag_="") const
 Return a non mutable reference to an object of given name and optional type id. 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
 
- Public Member Functions inherited from datatools::i_clear
virtual ~i_clear ()
 Destructor. More...
 

Static Public Attributes

static const bool constant
 
static const bool non_constant
 
static const bool copyable
 
static const bool noncopyable
 

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_)
 

Detailed Description

A generic serializable and noncopyable container for arbitrary serializable objects.

Member Typedef Documentation

◆ dict_type

typedef std::map<std::string, entry_type> datatools::things::dict_type

Embedded dictionary of arbitrary serializable objects.

Constructor & Destructor Documentation

◆ things() [1/2]

datatools::things::things ( )

Default constructor.

◆ things() [2/2]

datatools::things::things ( const std::string &  name_,
const std::string &  description_ = "" 
)

Constructor with name and description.

◆ ~things()

virtual datatools::things::~things ( )
virtual

Member Function Documentation

◆ add()

template<class T >
T & datatools::things::add ( const std::string &  name_,
const std::string &  desc_ = "",
bool  const_ = false 
)

Instantiate and add an object of given type and name.

◆ add_entry()

datatools::i_serializable& datatools::things::add_entry ( const std::string &  name_,
const std::string &  serial_tag_,
const std::string &  description_ = "",
bool  const_ = false 
)

Instantiate and add an object of given type id with given name, description and constness flag.

◆ add_entry_impl()

datatools::i_serializable& datatools::things::add_entry_impl ( const std::string &  name_,
const std::string &  serial_tag_,
const std::string &  description_,
bool  const_ 
)

Instantiate and add an object of given type id with given name, description and constness flag (implementation)

◆ clear()

virtual void datatools::things::clear ( )
virtual

Clear the container.

Implements datatools::i_clear.

◆ dump()

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

Basic print.

◆ empty()

bool datatools::things::empty ( ) const

Check if the container is empty.

◆ entry_is_a()

bool datatools::things::entry_is_a ( const std::string &  name_,
const std::string &   
) const

Check if a stored object with given name has a type with given type id.

◆ entry_is_introspectable()

bool datatools::things::entry_is_introspectable ( const std::string &  name_) const

Check if a stored object with given name is introspectable through CAMP interface.

◆ erase()

void datatools::things::erase ( const std::string &  name_)

Remove the object stored in the container with a given name.

◆ get() [1/2]

template<class T >
const T & datatools::things::get ( const std::string &  name_) const

Return a reference to a non mutable object of given type and name.

◆ get() [2/2]

const datatools::i_serializable& datatools::things::get ( const std::string &  name_,
const std::string &  serial_tag_ = "" 
) const

Return a non mutable reference to an object of given name and optional type id.

◆ get_description() [1/2]

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

Return the description of the container.

◆ get_description() [2/2]

const std::string& datatools::things::get_description ( const std::string &  name_) const

Return the description of the object stored with a given name.

◆ get_description_impl()

const std::string& datatools::things::get_description_impl ( ) const

Return the description of the container (low-level implementation)

◆ get_entry()

const datatools::i_serializable& datatools::things::get_entry ( const std::string &  name_) const

Return a reference to a non mutable stored object of given name.

◆ get_entry_description()

const std::string& datatools::things::get_entry_description ( const std::string &  name_) const

Return the description of the object stored with a given name.

◆ get_entry_introspection_id()

std::string datatools::things::get_entry_introspection_id ( const std::string &  name_) const

Return the introspection id of a stored object with given name.

◆ get_entry_name()

const std::string& datatools::things::get_entry_name ( int  index_) const

Return the name of the object stored at a given index.

◆ get_entry_serial_tag()

std::string datatools::things::get_entry_serial_tag ( const std::string &  name_) const

Return the serial tag of a stored object with given name.

◆ get_name()

const std::string& datatools::things::get_name ( ) const

Return the name of the container.

◆ get_name_impl()

const std::string& datatools::things::get_name_impl ( ) const

Return the name of the container (low-level implementation)

◆ get_names()

void datatools::things::get_names ( std::vector< std::string > &  names_) const

Build the list of names of all objects stored in the container.

◆ grab() [1/2]

template<class T >
T & datatools::things::grab ( const std::string &  name_)

Return a reference to a mutable object of given type and name.

◆ grab() [2/2]

datatools::i_serializable& datatools::things::grab ( const std::string &  name_,
const std::string &  serial_tag_ = "" 
)

Return a mutable reference to an object of given name and optional type id.

◆ grab_entry()

datatools::i_serializable& datatools::things::grab_entry ( const std::string &  name_)

Return a reference to a mutable stored object of given name.

◆ has()

bool datatools::things::has ( const std::string &  name_) const

Check if the container stores an object with a given name.

◆ has_description_impl()

bool datatools::things::has_description_impl ( ) const

Check if the container has a description (low-level implementation)

◆ has_name()

bool datatools::things::has_name ( ) const

Check if the container has a name.

◆ has_name_impl()

bool datatools::things::has_name_impl ( ) const

Check if the container has a name (low-level implementation)

◆ has_serial_tag()

bool datatools::things::has_serial_tag ( const std::string &  name_,
const std::string &  serial_tag_ 
) const

Check if the container stores an object with a given name and a given serial tag.

◆ is_a()

template<class T >
bool datatools::things::is_a ( const std::string &  name_) const

Check if a stored object with given name is of given type.

◆ is_constant()

bool datatools::things::is_constant ( const std::string &  name_) const

Check if the object stored is the container with a given name is constant.

◆ is_mutable()

bool datatools::things::is_mutable ( const std::string &  name_) const

Check if the object stored is the container with a given name is mutable.

◆ pop()

template<class T >
T * datatools::things::pop ( const std::string &  name_)

Extract the object of given type and name and remove the corresponding entry from the container

◆ remove()

void datatools::things::remove ( const std::string &  name_)

Remove the object stored in the container with a given name.

◆ reset()

void datatools::things::reset ( )

Reset the container.

◆ set_constant()

void datatools::things::set_constant ( const std::string &  name_,
bool  const_ = true 
)

not implemented :

◆ set_description() [1/2]

things& datatools::things::set_description ( const std::string &  )

Set the description of the container.

◆ set_description() [2/2]

void datatools::things::set_description ( const std::string &  name_,
const std::string &  desc_ 
)

Set the description of the object stored with a given name.

◆ set_description_impl()

void datatools::things::set_description_impl ( const std::string &  )

Set the description of the container (low-level implementation)

◆ set_entry_description()

void datatools::things::set_entry_description ( const std::string &  name_,
const std::string &  desc_ 
)

Set the description of the object stored with a given name.

◆ set_name()

things& datatools::things::set_name ( const std::string &  )

Set the name of the container.

◆ set_name_impl()

void datatools::things::set_name_impl ( const std::string &  )

Set the name of the container (low-level implementation)

◆ size()

unsigned int datatools::things::size ( ) const

Return the number of objects stored in the container.

◆ tree_dump()

virtual void datatools::things::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::i_tree_dumpable.

Member Data Documentation

◆ constant

const bool datatools::things::constant
static

◆ copyable

const bool datatools::things::copyable
static

◆ non_constant

const bool datatools::things::non_constant
static

◆ noncopyable

const bool datatools::things::noncopyable
static

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