14#include "tkproperty_list.h"
36 return fProperties.find(_property) != fProperties.end();
41 const auto property = fProperties.find(_property);
42 return property == fProperties.end() ?
tkstring(
"") :
property->second.value;
47 const auto property = fProperties.find(_property);
48 return property == fProperties.end() ?
tkstring(
"") :
property->second.unit;
53 const auto property = fProperties.find(_property);
54 return property == fProperties.end() ?
tkstring(
"") :
property->second.type;
60 for(
const auto &prop : fProperties)
61 if (prop.first.match(_opt))
62 glog <<
info << left << setw(35) << prop.first << setw(35) << prop.second.value +
" " + prop.second.unit <<
"[" << prop.second.type<<
"]" <<
do_endl;
67 glog <<
info << fname <<
" data properties:" <<
do_endl;
68 for(
const auto &prop : fDataProperties)
69 if (prop.first.match(_opt))
70 glog <<
info << left << setw(35) << prop.first << prop.second <<
do_endl;
75 vector<shared_ptr<tkmeasure>> list;
76 for (
auto &data : fDataProperties) {
77 if (data.first.match(_opt)) list.push_back(data.second);
84 const auto property = fDataProperties.find(_property);
85 return property == fDataProperties.end() ? nullptr :
property->second;
90 const auto property = fProperties.try_emplace(_name).first;
91 property->second.value = _val;
92 property->second.unit = _unit;
93 property->second.type = _type;
96void tkproperty_list::add_property(
const tkstring &_name,
const shared_ptr<tkmeasure> &_property,
const tkstring &_value_str,
const tkstring &_unit_str)
98 std::array<char, 64> buffer{};
99 const auto conversion = std::to_chars(
100 buffer.data(), buffer.data() + buffer.size(), _property->get_value(),
101 std::chars_format::fixed, 6);
103 if (conversion.ec == std::errc())
104 val.assign(buffer.data(), conversion.ptr);
107 tkstring unit = _property->get_unit();
108 if(!_value_str.
is_empty()) val = _value_str;
109 if(_unit_str!=
"!") unit = _unit_str;
110 add_property_str(_name,val,unit,
"FLOAT");
111 fDataProperties.insert_or_assign(_name, _property);
Contains list of properties.
tkstring get_property_unit(const tkstring &_property) const
get the property unnit as a string
void list_data_properties(const tkstring &_opt="*") const
list the available tkmeasure properties
bool has_property(const tkstring &_property) const
to check if the property is available
shared_ptr< tkmeasure > get(const tkstring &_property) const
get the property as tkmeasure
tkstring get_property_type(const tkstring &_property) const
get the property type as a string
tkstring get_property(const tkstring &_property) const
get the property value as a string
vector< shared_ptr< tkmeasure > > get_data_properties(const tkstring &_opt="*")
get a vector of data properties according to a regular expression
void list_properties(const tkstring &_opt="*") const
list the available properties
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
static const char * form(const char *_format,...)
tklog & do_endl(tklog &log)