TkN 2.1
Toolkit for Nuclei
tkproperty_list.h
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * Normandie Université, ENSICAEN, UNICAEN, CNRS/IN2P3, *
5 * LPC Caen, F-14000 Caen, France *
6 * Contibutor(s) : *
7 * Jérémie Dudouet jeremie.dudouet@cnrs.fr [2020] *
8 * Diego Gruyer diego.gruyer@cnrs.fr [2020] *
9 * *
10 * This software is governed by the CeCILL-B license under French law and *
11 * abiding by the rules of distribution of free software. You can use, *
12 * modify and/ or redistribute the software under the terms of the *
13 * CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
14 * URL \"http://www.cecill.info\". *
15 * *
16 * As a counterpart to the access to the source code and rights to copy, *
17 * modify and redistribute granted by the license, users are provided *
18 * only with a limited warranty and the software's author, the holder of *
19 * the economic rights, and the successive licensors have only limited *
20 * liability. *
21 * *
22 * In this respect, the user's attention is drawn to the risks associated *
23 * with loading, using, modifying and/or developing or reproducing the *
24 * software by the user in light of its specific status of free software, *
25 * that may mean that it is complicated to manipulate, and that also *
26 * therefore means that it is reserved for developers and experienced *
27 * professionals having in-depth computer knowledge. Users are therefore *
28 * encouraged to load and test the software's suitability as regards *
29 * their requirements in conditions enabling the security of their *
30 * systems and/or data to be ensured and, more generally, to use and *
31 * operate it in the same conditions as regards security. *
32 * *
33 * The fact that you are presently reading this means that you have had *
34 * knowledge of the CeCILL-B license and that you accept its terms. *
35 ********************************************************************************/
36
37#ifndef tkproperty_list_H
38#define tkproperty_list_H
39
40#include "tkn_config.h"
41#include "tkmeasure.h"
42
43#include <map>
44#include <memory>
45
46#ifdef HAS_ROOT
47#include "TClass.h"
48#endif
49
50using namespace std;
51
52namespace tkn {
53
54
56{
57protected:
58 struct property_string {
59 tkstring value{};
60 tkstring unit{};
61 tkstring type{};
62 };
63
64 using properties = std::map<tkstring, property_string>;
65
66 tkstring fname{};
67
69 properties fProperties;
71 map <tkstring, shared_ptr<tkmeasure>> fDataProperties;
72
73public:
74 tkproperty_list(tkstring _name) : fname(_name) {;}
75 virtual ~tkproperty_list() = default;
76
78 void list_properties(const tkstring &_opt="*") const;
79
81 void list_data_properties(const tkstring &_opt="*") const;
82
84 bool has_property(const tkstring &_property) const;
85
87 tkstring get_property(const tkstring &_property) const;
88
90 tkstring get_property_unit(const tkstring &_property) const;
91
93 tkstring get_property_type(const tkstring &_property) const;
94
96 shared_ptr<tkmeasure> get(const tkstring &_property) const;
97
99 const std::map<tkstring, property_string> get_properties() {return fProperties;}
100
102 vector<shared_ptr<tkmeasure>> get_data_properties(const tkstring &_opt="*");
103
104protected:
106 virtual void add_property_str(const tkstring &_name, const tkstring &_val, const tkstring &_unit, const tkstring &_type = "TEXT");
107
109 virtual void add_property(const tkstring &_name, const shared_ptr<tkmeasure> &_property, const tkstring &_value_str="", const tkstring &_unit_str="!");
110
111#ifdef HAS_ROOT
113 ClassDef(tkproperty_list,0);
114#endif
115
116};
117}
118
119#endif
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
const std::map< tkstring, property_string > get_properties()
get the properties map
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
tkproperty_list(tkstring _name)
virtual ~tkproperty_list()=default
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....
Definition: tkstring.h:54
Definition: tklog.cpp:39