40#include "tkn_config.h"
71 as,
fs,
ps,
ns,
us,
ms,
s,
min,
h,
d,
y,
81 static std::vector<tkstring> funits_name;
82 static std::vector<units_type> funits_type;
83 static std::vector<double> fcoeffs;
85 std::map<units_keys, tkstring> funits_map_id_to_string;
86 std::map<tkstring,units_keys> funits_map_string_to_id;
87 std::map<tkstring,units_keys> funits_map_string_to_id_low;
88 std::map<units_keys,double> funits_map_conv_coeffs;
89 std::map<units_keys,units_type> funits_map_types;
97 if(funits_map_id_to_string.count(_key))
return funits_map_id_to_string.at(_key);
98 else glog <<
warning_o <<
"data_units_manager::get_name(" << _key <<
"): unkown key " <<
do_endl;
104 if(funits_map_string_to_id_low.count(tmp))
return funits_map_string_to_id_low.at(tmp);
106 int i = funits_map_id_to_string.size();
107 funits_map_id_to_string[(
units_keys)i] = _name;
108 funits_map_string_to_id[_name] = (
units_keys)i;
109 funits_map_string_to_id_low[tmp] = (
units_keys)i;
112 return funits_map_string_to_id_low.at(tmp);
119 if(funits_map_types.count(_key))
return funits_map_types.at(_key);
120 else glog <<
warning_o <<
"data_units_manager::get_type(" << _key <<
"): unkown key " <<
do_endl;
129 if(funits_map_conv_coeffs.count(_key))
return funits_map_conv_coeffs.at(_key);
130 else glog <<
warning_o <<
"data_units_manager::get_factor(" << _key <<
"): unkown key " <<
do_endl;
140#define gunits (tkn::tkunit_manager::the_unit_manager())
146 double fFactor = std::nan(
"0");
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
tkstring copy() const
Returns a copy of this string.
tkstring & to_lower()
Change all letters to lower case.
Manages the different units.
units_keys
units identifiers
units_keys get_key(const tkstring &_name)
retuns unit key
static std::vector< std::tuple< tkstring, units_type, double > > funits_properties
virtual ~tkunit_manager()=default
units_type
flags that qualify the unit type
units_type get_type(const units_keys &_key)
retuns unit type
tkstring get_name(const units_keys &_key)
retuns unit name
static tkunit_manager * the_unit_manager()
db_manager is a singleton
A measured value associated to its unit.
tkunit_manager::units_keys get_unit_key() const
returns the unit key
double get_value() const
get the value in the current unit
tkunit(double _value, const tkstring &_unit)
void set_value(const double &_val, const tkstring &_unit="")
set the value and unit from string, if _unit not defined, let in the current unit
tkstring get_unit_name() const
returns the unit name
bool set_unit(const tkstring &_unit)
set the unit from a string
void clear()
reset the data_unit
tklog & warning_o(tklog &log)
tklog & do_endl(tklog &log)