TkN 2.4
Toolkit for Nuclei
Loading...
Searching...
No Matches
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 * Licensed under the MIT License <http://opensource.org/licenses/MIT>. *
11 * SPDX-License-Identifier: MIT *
12 ********************************************************************************/
13
14#ifndef tkproperty_list_H
15#define tkproperty_list_H
16
17#include "tkn_config.h"
18#include "tkmeasure.h"
19
20#include <map>
21#include <memory>
22
23#ifdef HAS_ROOT
24#include "TClass.h"
25#endif
26
27using namespace std;
28
29namespace tkn {
30
31
33{
34protected:
35 struct property_string {
36 tkstring value{};
37 tkstring unit{};
38 tkstring type{};
39 };
40
41 using properties = std::map<tkstring, property_string>;
42
43 tkstring fname{};
44
46 properties fProperties;
48 map <tkstring, shared_ptr<tkmeasure>> fDataProperties;
49
50public:
51 tkproperty_list(tkstring _name) : fname(_name) {;}
52 virtual ~tkproperty_list() = default;
53
55 void list_properties(const tkstring &_opt="*") const;
56
58 void list_data_properties(const tkstring &_opt="*") const;
59
61 bool has_property(const tkstring &_property) const;
62
64 tkstring get_property(const tkstring &_property) const;
65
67 tkstring get_property_unit(const tkstring &_property) const;
68
70 tkstring get_property_type(const tkstring &_property) const;
71
73 shared_ptr<tkmeasure> get(const tkstring &_property) const;
74
76 const auto& get_properties() const { return fProperties; }
77
79 vector<shared_ptr<tkmeasure>> get_data_properties(const tkstring &_opt="*");
80
81protected:
83 virtual void add_property_str(const tkstring &_name, const tkstring &_val, const tkstring &_unit, const tkstring &_type = "TEXT");
84
86 virtual void add_property(const tkstring &_name, const shared_ptr<tkmeasure> &_property, const tkstring &_value_str="", const tkstring &_unit_str="!");
87
88#ifdef HAS_ROOT
90 ClassDef(tkproperty_list,0);
91#endif
92
93};
94}
95
96#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
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
const auto & get_properties() const
get the properties map
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition tkstring.h:31
Definition tklog.cpp:16