@@ -29,17 +29,21 @@ namespace conf
2929//
3030// A configurable parameter is a simple class, defining
3131// a few (pod) properties/members which are registered
32- // in a global (boost) property tree.
32+ // in a global (boost) property tree / structure .
3333//
3434// The features that we provide here are:
35- // a ) Automatic translation from C++ data description to INI/JSON/XML
35+ // * ) Automatic translation from C++ data description to INI/JSON/XML
3636// format via ROOT introspection and boost property trees and
3737// the possibility to readably save the configuration
38- // b) Automatic integration of sub-classes into a common configuration
39- // c) Be able to query properties from high level interfaces (just knowing
40- // d) Be able to set properties from high-level interfaces (and modifying the underlying
38+ // *) Serialization/Deserialization into ROOT binary blobs (for the purpose
39+ // of writing/retrieving parameters from CCDB)
40+ // *) Automatic integration of sub-classes into a common configuration
41+ // *) Be able to query properties from high level interfaces (just knowing
42+ // *) Be able to set properties from high-level interfaces (and modifying the underlying
4143// C++ object)
42- // e) Automatic ability to modify parameters from the command-line
44+ // *) Automatic ability to modify parameters from the command-line
45+ // *) Keeping track of the provenance of individual parameter values; The user is able
46+ // to see whether is parameter is defaulted-code-value/coming-from-CCDB/coming-from-comandline
4347//
4448// Note that concrete parameter sub-classes **must** be implemented
4549// by inheriting from ConfigurableParamHelper and not from this class.
@@ -79,11 +83,23 @@ namespace conf
7983class ConfigurableParam
8084{
8185 public:
86+ enum EParamProvenance {
87+ kCODE /* from default code initialization */ ,
88+ kCCDB /* overwritten from CCDB */ ,
89+ kRT /* changed during runtime via API call setValue (for example command line) */
90+ /* can add more modes here */
91+ };
92+ static std::string toString (EParamProvenance p)
93+ {
94+ static std::array<std::string, 3 > names = { " CODE" , " CCDB" , " RT" };
95+ return names[(int )p];
96+ }
97+
8298 //
8399 virtual std::string getName () const = 0; // print the name of the configurable Parameter
84100
85- // print the current keys and values to screen
86- virtual void printKeyValues () = 0;
101+ // print the current keys and values to screen (optionally with provenance information)
102+ virtual void printKeyValues (bool showprov = true ) const = 0;
87103
88104 static void printAllRegisteredParamNames ();
89105 static void printAllKeyValuePairs ();
@@ -107,7 +123,10 @@ class ConfigurableParam
107123 auto key = mainkey + " ." + subkey;
108124 if (sPtree ->get_optional <std::string>(key).is_initialized ()) {
109125 sPtree ->put (key, x);
110- updateThroughStorageMap (mainkey, subkey, typeid (T), (void *)&x);
126+ auto changed = updateThroughStorageMap (mainkey, subkey, typeid (T), (void *)&x);
127+ if (changed) {
128+ sValueProvenanceMap ->find (key)->second = kRT ; // set to runtime
129+ }
111130 }
112131 }
113132
@@ -117,7 +136,10 @@ class ConfigurableParam
117136 {
118137 if (sPtree ->get_optional <std::string>(key).is_initialized ()) {
119138 sPtree ->put (key, valuestring);
120- updateThroughStorageMapWithConversion (key, valuestring);
139+ auto changed = updateThroughStorageMapWithConversion (key, valuestring);
140+ if (changed) {
141+ sValueProvenanceMap ->find (key)->second = kRT ; // set to runtime
142+ }
121143 }
122144 }
123145
@@ -144,9 +166,9 @@ class ConfigurableParam
144166 // registering the concrete parameters
145167 ConfigurableParam ();
146168
147- static void updatePropertyTree ();
148- static void updateThroughStorageMap (std::string, std::string, std::type_info const &, void *);
149- static void updateThroughStorageMapWithConversion (std::string, std::string);
169+ static void initPropertyTree ();
170+ static bool updateThroughStorageMap (std::string, std::string, std::type_info const &, void *);
171+ static bool updateThroughStorageMapWithConversion (std::string, std::string);
150172
151173 virtual ~ConfigurableParam () = default ;
152174
@@ -157,6 +179,9 @@ class ConfigurableParam
157179 // (internal use to easily sync updates, this is ok since parameter classes are singletons)
158180 static std::map<std::string, std::pair<int , void *>>* sKeyToStorageMap ;
159181
182+ // keep track of provenance of parameters and values
183+ static std::map<std::string, ConfigurableParam::EParamProvenance>* sValueProvenanceMap ;
184+
160185 void setRegisterMode (bool b) { sRegisterMode = b; }
161186
162187 private:
@@ -174,7 +199,7 @@ class ConfigurableParam
174199// a helper macro for boilerplate code in parameter classes
175200#define O2ParamDef (classname, key ) \
176201 public: \
177- classname (TRootIOCtor *) {} \
202+ classname (TRootIOCtor*) {} \
178203 private: \
179204 static constexpr char const * const sKey = key; \
180205 static classname sInstance ; \
0 commit comments