17#include "tkn_config.h"
48 as,
fs,
ps,
ns,
us,
ms,
s,
min,
h,
d,
y,
58 static std::vector<tkstring> funits_name;
59 static std::vector<units_type> funits_type;
60 static std::vector<double> fcoeffs;
62 std::map<units_keys, tkstring> funits_map_id_to_string;
63 std::map<tkstring,units_keys> funits_map_string_to_id;
64 std::map<tkstring,units_keys> funits_map_string_to_id_low;
65 std::map<units_keys,double> funits_map_conv_coeffs;
66 std::map<units_keys,units_type> funits_map_types;
74 if(funits_map_id_to_string.count(_key))
return funits_map_id_to_string.at(_key);
75 else glog <<
warning_o <<
"data_units_manager::get_name(" << _key <<
"): unkown key " <<
do_endl;
81 if(funits_map_string_to_id_low.count(tmp))
return funits_map_string_to_id_low.at(tmp);
83 int i = funits_map_id_to_string.size();
84 funits_map_id_to_string[(
units_keys)i] = _name;
85 funits_map_string_to_id[_name] = (
units_keys)i;
86 funits_map_string_to_id_low[tmp] = (
units_keys)i;
89 return funits_map_string_to_id_low.at(tmp);
96 if(funits_map_types.count(_key))
return funits_map_types.at(_key);
97 else glog <<
warning_o <<
"data_units_manager::get_type(" << _key <<
"): unkown key " <<
do_endl;
106 if(funits_map_conv_coeffs.count(_key))
return funits_map_conv_coeffs.at(_key);
107 else glog <<
warning_o <<
"data_units_manager::get_factor(" << _key <<
"): unkown key " <<
do_endl;
117#define gunits (tkn::tkunit_manager::the_unit_manager())
123 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)