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

Unit information associated to a parameter. More...

#include <bayeux/datatools/introspection/unit_support.h>

Inheritance diagram for datatools::introspection::unit_info:
datatools::i_tree_dumpable

Public Types

enum  unit_info_xc_flags {
  UI_XC_CLEAR = bit_mask::bit00, UI_XC_UNIT_SUPPORT = bit_mask::bit01, UI_XC_PREFERRED_UNIT = bit_mask::bit02, UI_XC_DEFAULT,
  DD_XC_LAST = UI_XC_PREFERRED_UNIT
}
 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

 unit_info ()
 Default constructor. More...
 
 unit_info (unit_support_type, const std::string &unit_token_, const std::string &unit_token2_="")
 Constructor. More...
 
virtual ~unit_info ()
 Destructor. More...
 
bool is_valid () const
 Check validity. More...
 
bool has_implicit_unit () const
 Check the implicit unit trait. More...
 
bool has_explicit_unit_dimension () const
 Check the explicit unitdimension trait. More...
 
void set_unit_support (unit_support_type)
 Set the unit support. More...
 
unit_support_type get_unit_support () const
 Return the unit support. More...
 
void set_implicit_unit_symbol (const std::string &)
 Set the implicit unit symbol. More...
 
const std::string & get_implicit_unit_symbol () const
 Return the implicit unit symbol. More...
 
void set_explicit_unit_dimension_label (const std::string &)
 Set the explicit unit dimension label. More...
 
const std::string & get_explicit_unit_dimension_label () const
 Return the explicit unit dimension. More...
 
bool has_preferred_unit_symbol () const
 Check if preferred unit symbol is set. More...
 
void set_preferred_unit_symbol (const std::string &)
 Set the preferred unit symbol. More...
 
const std::string & get_preferred_unit_symbol () const
 Return the preferred unit symbol. More...
 
void make_none ()
 Make the unit info with no unit support. More...
 
void make_implicit_unit (const std::string &unit_symbol_, const std::string &preferred_unit_symbol_="")
 Make the unit info with implicit unit. More...
 
void make_explicit_unit_dimension (const std::string &unit_dimension_label_, const std::string &preferred_unit_symbol_="")
 Make the unit info with explicit unit dimension. More...
 
void initialize (const datatools::properties &)
 
void reset ()
 Reset. More...
 
void export_to_config (datatools::properties &config_, uint32_t flags_=UI_XC_DEFAULT, const std::string &prefix_="") const
 Export to a container of properties. 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...
 
bool operator== (const unit_info &ui_) const
 
- 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
 

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

Unit information associated to a parameter.

Member Enumeration Documentation

◆ unit_info_xc_flags

Flags for export to a container of properties.

Enumerator
UI_XC_CLEAR 
UI_XC_UNIT_SUPPORT 
UI_XC_PREFERRED_UNIT 
UI_XC_DEFAULT 
DD_XC_LAST 

Constructor & Destructor Documentation

◆ unit_info() [1/2]

datatools::introspection::unit_info::unit_info ( )

Default constructor.

◆ unit_info() [2/2]

datatools::introspection::unit_info::unit_info ( unit_support_type  ,
const std::string &  unit_token_,
const std::string &  unit_token2_ = "" 
)

Constructor.

◆ ~unit_info()

virtual datatools::introspection::unit_info::~unit_info ( )
virtual

Destructor.

Member Function Documentation

◆ export_to_config()

void datatools::introspection::unit_info::export_to_config ( datatools::properties config_,
uint32_t  flags_ = UI_XC_DEFAULT,
const std::string &  prefix_ = "" 
) const

Export to a container of properties.

◆ get_explicit_unit_dimension_label()

const std::string& datatools::introspection::unit_info::get_explicit_unit_dimension_label ( ) const

Return the explicit unit dimension.

◆ get_implicit_unit_symbol()

const std::string& datatools::introspection::unit_info::get_implicit_unit_symbol ( ) const

Return the implicit unit symbol.

◆ get_preferred_unit_symbol()

const std::string& datatools::introspection::unit_info::get_preferred_unit_symbol ( ) const

Return the preferred unit symbol.

◆ get_unit_support()

unit_support_type datatools::introspection::unit_info::get_unit_support ( ) const

Return the unit support.

◆ has_explicit_unit_dimension()

bool datatools::introspection::unit_info::has_explicit_unit_dimension ( ) const

Check the explicit unitdimension trait.

◆ has_implicit_unit()

bool datatools::introspection::unit_info::has_implicit_unit ( ) const

Check the implicit unit trait.

◆ has_preferred_unit_symbol()

bool datatools::introspection::unit_info::has_preferred_unit_symbol ( ) const

Check if preferred unit symbol is set.

◆ initialize()

void datatools::introspection::unit_info::initialize ( const datatools::properties )

Initialize from a set of properties

Examples: a) No unit support:

support : string = "none"

b) Implicit unit support:

support : string = "implicit_unit"
implicit_unit : string = "second"

c) Explicit unit dimension support:

support : string = "explicit_unit_dimension"
explicit_unit_dimension : string = "time"
preferred_unit : string = "ms"

◆ is_valid()

bool datatools::introspection::unit_info::is_valid ( ) const

Check validity.

◆ make_explicit_unit_dimension()

void datatools::introspection::unit_info::make_explicit_unit_dimension ( const std::string &  unit_dimension_label_,
const std::string &  preferred_unit_symbol_ = "" 
)

Make the unit info with explicit unit dimension.

◆ make_implicit_unit()

void datatools::introspection::unit_info::make_implicit_unit ( const std::string &  unit_symbol_,
const std::string &  preferred_unit_symbol_ = "" 
)

Make the unit info with implicit unit.

◆ make_none()

void datatools::introspection::unit_info::make_none ( )

Make the unit info with no unit support.

◆ operator==()

bool datatools::introspection::unit_info::operator== ( const unit_info ui_) const

Make the class "equality comparable" (needed by Boost/optional for some reason...) Do not understand why (see also the "data_description::has_unit_info()" method) In order to use the "boost::none" semantic, I had to add the "unit_info::operator==(...)" operator despite what is written at: http://www.boost.org/doc/libs/1_59_0/libs/optional/doc/html/boost_optional/tutorial/relational_operators.html

Remarks
In case where optional<T> is compared to none, it is not required that T be EqualityComparable.

That's fine but is not true with Boost 1.55.

The use of "boost::none" semantic was introduced to prepare the support for recent C++ compilers (with C++11 support) that seems to not support anymore the following semantics:

boost::optional<unit_info> opt;
...
if (opt) { /* do something */ }

but require:

boost::optional<unit_info> opt;
...
if (opt != boost::none) { /* do something */ }

However, for builtin types (int, float...), it works. This must be clarified in the future.

◆ reset()

void datatools::introspection::unit_info::reset ( )

Reset.

◆ set_explicit_unit_dimension_label()

void datatools::introspection::unit_info::set_explicit_unit_dimension_label ( const std::string &  )

Set the explicit unit dimension label.

◆ set_implicit_unit_symbol()

void datatools::introspection::unit_info::set_implicit_unit_symbol ( const std::string &  )

Set the implicit unit symbol.

◆ set_preferred_unit_symbol()

void datatools::introspection::unit_info::set_preferred_unit_symbol ( const std::string &  )

Set the preferred unit symbol.

◆ set_unit_support()

void datatools::introspection::unit_info::set_unit_support ( unit_support_type  )

Set the unit support.

◆ tree_dump()

virtual void datatools::introspection::unit_info::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.


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