KaliVeda
Toolkit for HIC analysis
|
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
You can create and initialise a list of parameters with the constructor:
Parameters are dynamically added or modified by calling SetValue():
Before trying to retrieve a parameter from the list, it is advisable to test if a parameter with the correct name and type exists in the list:
Values can then be retrieved with the following methods:
Some conversions between different types will work implicitly, however be aware that any attempt to convert a non-numeric string parameter into a numerical value will result in zero:
Another method allows to test whether a parameter with a given name exists and has a specific value (including of the right type):
In addition to the four types handled by KVNamedParameter, KVNameValueList adds the possibility to store (unsigned) 64-bit integers using SetValue64bit():
The 64-bit value is stored as 2 32-bit integers with suffixes "hi" and "lo". Dedicated methods must be used to test for the presence or retrieve the value of a 64-bit parameter:
Definition at line 116 of file KVNameValueList.h.
#include <KVNameValueList.h>
Classes | |
class | Iterator |
Public Member Functions | |
KVNameValueList () | |
Default constructor. | |
KVNameValueList (const Char_t *name, const Char_t *title="") | |
KVNameValueList (const KVNameValueList &) | |
Copy constructor. | |
KVNameValueList (std::initializer_list< KVNamedParameter >) | |
virtual | ~KVNameValueList () |
Destructor. | |
void | AddValue (const KVNamedParameter &p) |
Iterator | begin () const |
virtual void | Clear (Option_t *opt="") |
virtual void | ClearSelection (TRegexp &) |
Int_t | Compare (const TObject *nvl) const |
void | Copy (TObject &nvl) const |
Iterator | end () const |
KVNamedParameter * | FindParameter (const Char_t *name) const |
return the parameter object with the asking name | |
KVString | Get () const |
Bool_t | GetBoolValue (const Char_t *name) const |
Bool_t | GetBoolValue (Int_t idx) const |
Double_t | GetDoubleValue (const Char_t *name) const |
Double_t | GetDoubleValue (Int_t idx) const |
Int_t | GetEntries () const |
Int_t | GetIntValue (const Char_t *name) const |
Int_t | GetIntValue (Int_t idx) const |
KVHashList * | GetList () const |
const Char_t * | GetNameAt (Int_t idx) const |
Int_t | GetNameIndex (const Char_t *name) const |
Int_t | GetNpar () const |
return the number of stored parameters | |
KVNamedParameter * | GetParameter (Int_t idx) const |
return the parameter object with index idx | |
const Char_t * | GetStringValue (const Char_t *name) const |
const Char_t * | GetStringValue (Int_t idx) const |
TString | GetTStringValue (const Char_t *name) const |
TString | GetTStringValue (Int_t idx) const |
template<typename value_type > | |
value_type | GetValue (const Char_t *name) const |
template<typename value_type > | |
value_type | GetValue (Int_t idx) const |
ULong64_t | GetValue64bit (const Char_t *name) const |
Bool_t | HasBoolParameter (const Char_t *name) const |
Bool_t | HasDoubleParameter (const Char_t *name) const |
Bool_t | HasIntParameter (const Char_t *name) const |
Bool_t | HasNumericParameter (const Char_t *name) const |
Bool_t | HasParameter (const Char_t *name) const |
template<typename value_type > | |
Bool_t | HasParameter (const Char_t *name) const |
Bool_t | HasStringParameter (const Char_t *name) const |
Bool_t | HasValue64bit (const Char_t *name) const |
template<typename value_type > | |
void | IncrementValue (const Char_t *name, value_type value) |
Bool_t | IsEmpty () const |
Bool_t | IsOwner () const |
template<typename value_type > | |
Bool_t | IsValue (const Char_t *name, value_type value) const |
virtual void | ls (Option_t *opt="") const |
void | Merge (const KVNameValueList &) |
KVNameValueList | operator+= (const KVNameValueList &nvl) |
KVNameValueList & | operator= (const KVNameValueList &) |
virtual void | Print (Option_t *opt="") const |
virtual KVEnv * | ProduceEnvFile () |
virtual void | ReadEnvFile (const Char_t *filename) |
void | RemoveParameter (const Char_t *name) |
bool | Set (const KVString &) |
template<typename value_type > | |
void | SetFirstValue (const Char_t *name, value_type value) |
void | SetFromEnv (TEnv *tenv, const TString &prefix="") |
void | SetIgnoreBool (Bool_t ignore=kTRUE) |
template<typename value_type > | |
void | SetLastValue (const Char_t *name, value_type value) |
void | SetOwner (Bool_t enable=kTRUE) |
template<typename value_type > | |
void | SetValue (const Char_t *name, value_type value) |
void | SetValue (const KVNamedParameter &) |
add (or replace) a parameter with the same name, type & value as 'p' | |
void | SetValue64bit (const Char_t *name, ULong64_t) |
template<typename value_type > | |
void | SetValueAt (const Char_t *name, value_type value, Int_t idx) |
void | Sort (Bool_t order=kSortAscending) |
void | WriteClass (const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="") |
virtual void | WriteEnvFile (const Char_t *filename) |
Write all name-value pairs in this list as a TEnv format file. | |
void | WriteToEnv (TEnv *tenv, const TString &prefix="") |
Public Member Functions inherited from TNamed | |
TNamed () | |
TNamed (const char *name, const char *title) | |
TNamed (const TNamed &named) | |
TNamed (const TString &name, const TString &title) | |
virtual | ~TNamed () |
void | Clear (Option_t *option="") override |
TObject * | Clone (const char *newname="") const override |
Int_t | Compare (const TObject *obj) const override |
void | Copy (TObject &named) const override |
virtual void | FillBuffer (char *&buffer) |
const char * | GetName () const override |
const char * | GetTitle () const override |
ULong_t | Hash () const override |
TClass * | IsA () const override |
Bool_t | IsSortable () const override |
void | ls (Option_t *option="") const override |
TNamed & | operator= (const TNamed &rhs) |
void | Print (Option_t *option="") const override |
virtual void | SetName (const char *name) |
virtual void | SetNameTitle (const char *name, const char *title) |
virtual void | SetTitle (const char *title="") |
virtual Int_t | Sizeof () const |
void | Streamer (TBuffer &) override |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Public Member Functions inherited from TObject | |
TObject () | |
TObject (const TObject &object) | |
virtual | ~TObject () |
void | AbstractMethod (const char *method) const |
virtual void | AppendPad (Option_t *option="") |
virtual void | Browse (TBrowser *b) |
ULong_t | CheckedHash () |
virtual const char * | ClassName () const |
virtual void | Delete (Option_t *option="") |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
virtual void | Draw (Option_t *option="") |
virtual void | DrawClass () const |
virtual TObject * | DrawClone (Option_t *option="") const |
virtual void | Dump () const |
virtual void | Error (const char *method, const char *msgfmt,...) const |
virtual void | Execute (const char *method, const char *params, Int_t *error=nullptr) |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr) |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
virtual TObject * | FindObject (const char *name) const |
virtual TObject * | FindObject (const TObject *obj) const |
virtual Option_t * | GetDrawOption () const |
virtual const char * | GetIconName () const |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
virtual Option_t * | GetOption () const |
virtual UInt_t | GetUniqueID () const |
virtual Bool_t | HandleTimer (TTimer *timer) |
Bool_t | HasInconsistentHash () const |
virtual void | Info (const char *method, const char *msgfmt,...) const |
virtual Bool_t | InheritsFrom (const char *classname) const |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
virtual void | Inspect () const |
void | InvertBit (UInt_t f) |
Bool_t | IsDestructed () const |
virtual Bool_t | IsEqual (const TObject *obj) const |
virtual Bool_t | IsFolder () const |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
void | MayNotUse (const char *method) const |
virtual Bool_t | Notify () |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, void *vp) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, void *vp) |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
virtual void | Paint (Option_t *option="") |
virtual void | Pop () |
virtual Int_t | Read (const char *name) |
virtual void | RecursiveRemove (TObject *obj) |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
virtual void | SetDrawOption (Option_t *option="") |
virtual void | SetUniqueID (UInt_t uid) |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const |
Private Attributes | |
Bool_t | fIgnoreBool |
do not convert "yes", "false", "on", etc. in TEnv file to boolean | |
KVHashList | fList |
list of KVNamedParameter objects | |
Additional Inherited Members | |
Public Types inherited from TObject | |
enum | EDeprecatedStatusBits |
enum | EStatusBits |
Static Public Member Functions inherited from TNamed | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
Static Public Member Functions inherited from TObject | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static Longptr_t | GetDtorOnly () |
static Bool_t | GetObjectStat () |
static void | SetDtorOnly (void *obj) |
static void | SetObjectStat (Bool_t stat) |
Public Attributes inherited from TObject | |
kBitMask | |
kCanDelete | |
kCannotPick | |
kHasUUID | |
kInconsistent | |
kInvalidObject | |
kIsOnHeap | |
kIsReferenced | |
kMustCleanup | |
kNoContextMenu | |
kNotDeleted | |
kObjInCanvas | |
kOverwrite | |
kSingleKey | |
kWriteDelete | |
kZombie | |
Protected Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
void | MakeZombie () |
Protected Attributes inherited from TNamed | |
TString | fName |
TString | fTitle |
Protected Attributes inherited from TObject | |
kOnlyPrepStep | |
KVNameValueList::KVNameValueList | ( | ) |
Default constructor.
Definition at line 19 of file KVNameValueList.cpp.
KVNameValueList::KVNameValueList | ( | std::initializer_list< KVNamedParameter > | l | ) |
Constructor using an initializer list for a given set of KVNamedParameter objects, i.e. this contructor makes it possible to do:
Definition at line 38 of file KVNameValueList.cpp.
Ctor with name & title
if name contains a comma-separated list of parameter/value pairs, it will be used to initialise the list (no name set)
Definition at line 60 of file KVNameValueList.cpp.
KVNameValueList::KVNameValueList | ( | const KVNameValueList & | NVL | ) |
Copy constructor.
Definition at line 77 of file KVNameValueList.cpp.
|
virtual |
Destructor.
Definition at line 89 of file KVNameValueList.cpp.
void KVNameValueList::AddValue | ( | const KVNamedParameter & | p | ) |
if a parameter with the same name & type as 'p' exists, add numerical value of p to value of parameter in list, or for strings we add to a comma-separated list of strings. otherwise, add a copy of p to list
Definition at line 480 of file KVNameValueList.cpp.
|
inline |
return iterator to beginning of list
Definition at line 207 of file KVNameValueList.h.
Clear all the stored parameters Deletes the parameter objects if owner & opt!="nodelete"
Reimplemented from TObject.
Reimplemented in KVValues.
Definition at line 258 of file KVNameValueList.cpp.
Remove from list all parameters whose name matches the regular expression Examples: remove all parameters starting with "toto": TRegexp sel("^toto") remove all parameters with "toto" in name: TRegexp sel("toto")
Definition at line 273 of file KVNameValueList.cpp.
Compare the contents of two KVNameValueList Returns the number of same parameters (name and value)
Reimplemented from TObject.
Definition at line 380 of file KVNameValueList.cpp.
Copy this to the nvl object. Any existing parameters will be destroyed
Reimplemented from TObject.
Definition at line 241 of file KVNameValueList.cpp.
|
inline |
return iterator to end of list (a nullptr)
Definition at line 212 of file KVNameValueList.h.
KVNamedParameter * KVNameValueList::FindParameter | ( | const Char_t * | name | ) | const |
return the parameter object with the asking name
Definition at line 496 of file KVNameValueList.cpp.
KVString KVNameValueList::Get | ( | ) | const |
Fill and return a string containing a comma-separated list of the parameter/value pairs
Such a string can be used with method Set() in order to initialize a copy of this list.
Definition at line 198 of file KVNameValueList.cpp.
Definition at line 403 of file KVNameValueList.h.
Definition at line 431 of file KVNameValueList.h.
Definition at line 407 of file KVNameValueList.h.
Definition at line 435 of file KVNameValueList.h.
|
inline |
Definition at line 379 of file KVNameValueList.h.
Definition at line 399 of file KVNameValueList.h.
Definition at line 427 of file KVNameValueList.h.
KVHashList * KVNameValueList::GetList | ( | ) | const |
return the pointeur of the KVHashList where parameters are stored with their values
Definition at line 228 of file KVNameValueList.cpp.
return the name of the parameter store at the idx position in the list if the idx is greater than the number of stored parameters return empty string
Definition at line 580 of file KVNameValueList.cpp.
return the position in the list of a given parameter using its name return -1 if no parameter with such name are present
Definition at line 555 of file KVNameValueList.cpp.
Int_t KVNameValueList::GetNpar | ( | ) | const |
return the number of stored parameters
Definition at line 620 of file KVNameValueList.cpp.
KVNamedParameter * KVNameValueList::GetParameter | ( | Int_t | idx | ) | const |
return the parameter object with index idx
Definition at line 507 of file KVNameValueList.cpp.
Definition at line 411 of file KVNameValueList.h.
Definition at line 439 of file KVNameValueList.h.
return the value in TString format for a parameter using its name return string "-1" if no parameter with such name are present
Definition at line 601 of file KVNameValueList.cpp.
return the value in string format for a parameter using its position return -1 idx is greater than the number of stored parameters
Definition at line 633 of file KVNameValueList.cpp.
|
inline |
return the value of named parameter returns a default value (-1, false or "-1") if no parameter with such a name is present
Definition at line 389 of file KVNameValueList.h.
|
inline |
return the value of parameter at position idx returns a default value (-1, false or "-1") if idx is greater than the number of stored parameters
Definition at line 418 of file KVNameValueList.h.
Return a 64-bit integer stored as two 32-bit parameters with names 'name_up' and 'name_lo'
Definition at line 438 of file KVNameValueList.cpp.
Definition at line 348 of file KVNameValueList.h.
Returns kTRUE if the list contains a parameter with given name and type Double.
WARNING: only returns kTRUE if parameter is STRICTLY of type Double, will return false for Int parameter.
Definition at line 352 of file KVNameValueList.h.
Returns kTRUE if the list contains a parameter with given name and type Int.
WARNING: only returns kTRUE if paramete is STRICTLY of type Int, will return false for Double parameter.
Definition at line 338 of file KVNameValueList.h.
Returns kTRUE if the list contains a parameter with given name and it is of numeric type, i.e. either Int or Double. Even if the parameter is actually of String type, if the string it contains corresponds to a numeric value, this method returns kTRUE.
This is to avoid ambiguity with HasDoubleParameter() and HasIntParameter() which only return kTRUE if the parameter is strictly of the given type.
Definition at line 366 of file KVNameValueList.h.
Check if there is a parameter with the asked name in the list kTRUE, parameter already present kFALSE, if not
Definition at line 539 of file KVNameValueList.cpp.
|
inline |
Return kTRUE if list has parameter called 'name' and it is of given type
Definition at line 331 of file KVNameValueList.h.
Definition at line 362 of file KVNameValueList.h.
Returns kTRUE if 'name' is stored as a 64-bit value i.e. if integer parameters 'name_lo' and 'name_hi' are defined
Definition at line 460 of file KVNameValueList.cpp.
|
inline |
increment a parameter (define by its name) by a value if the parameter is not in the list, it is added if it's in the list increment its value
Definition at line 305 of file KVNameValueList.h.
|
inline |
Definition at line 383 of file KVNameValueList.h.
Bool_t KVNameValueList::IsOwner | ( | ) | const |
return kTRUE if the list owns its objects kFALSE if not
Definition at line 367 of file KVNameValueList.cpp.
|
inline |
Returns kTRUE if parameter with given name exists and is equal to given value
Definition at line 315 of file KVNameValueList.h.
Reimplemented from TObject.
Definition at line 322 of file KVNameValueList.cpp.
void KVNameValueList::Merge | ( | const KVNameValueList & | other | ) |
Merge other list into this one. Any parameters in 'other' which do not exist in this one are added. Any parameters which exist in both have their values summed.
Definition at line 816 of file KVNameValueList.cpp.
KVNameValueList KVNameValueList::operator+= | ( | const KVNameValueList & | nvl | ) |
Definition at line 750 of file KVNameValueList.cpp.
KVNameValueList & KVNameValueList::operator= | ( | const KVNameValueList & | o | ) |
Definition at line 99 of file KVNameValueList.cpp.
Print stored parameters (name, and value) Option can be used to select type of parameters to print: option = "int", "double", or "string"
Reimplemented from TObject.
Reimplemented in KVValues.
Definition at line 301 of file KVNameValueList.cpp.
|
virtual |
Put all name-value pairs in this list as a TEnv format. delete after use
Definition at line 720 of file KVNameValueList.cpp.
Read all name-value pairs in the TEnv format file and store in list. Clears any previously stored values.
values are read as strings from the TEnv and we use TString::IsDigit, TString::IsFloat to decide whether to store them as integers, floats, or strings. booleans are recognized as: TRUE, FALSE, ON, OFF, YES, NO, OK, NOT (to disable this feature and read such values as strings, call SetIgnoreBool(kTRUE))
Special case: if the parameter name contains the string NumberList then we store the value string as is, as in this case it is assumed to be the string representation of a KVNumberList (easily confused with floating point numbers)
Definition at line 665 of file KVNameValueList.cpp.
remove parameter from the list, Warning the TNamed object associated is deleted
Definition at line 519 of file KVNameValueList.cpp.
bool KVNameValueList::Set | ( | const KVString & | list | ) |
If list contains a comma-separated list of parameter/value pairs
then use it to initialise the parameters of the list, and return true (any existing parameters will be removed).
If list does not contain at least one '=' character, do nothing and return false.
The type of each parameter is deduced from the given values, using the following methods in the following order:
Note that in the case of the quoted string, the parameter is stored without the enclosing quotes (i.e. for val="'7 9'" the stored string is "7 9")
Definition at line 131 of file KVNameValueList.cpp.
|
inline |
associate a parameter (define by its name) and a value if the parameter is not in the list, it is inserted at the begining of the list. if it's in the list replace its value and move it at the begining of the list.
Definition at line 267 of file KVNameValueList.h.
Update the values of any parameters in the KVNameValueList which are found in the TEnv, optionally using the given prefix. Example: if KVNameValueList contains a parameter "Legs" and if prefix="Large", then if the TEnv contains a value "Large.Legs", it will be used to update "Legs"
Definition at line 784 of file KVNameValueList.cpp.
When reading a list from a file using ReadEnvFile(), any string values matching TRUE, FALSE, ON, OFF, YES, NO, OK, NOT are automatically converted to boolean parameters. If you want to disable this and keep such strings as strings, call this method first.
Definition at line 460 of file KVNameValueList.h.
|
inline |
associate a parameter (define by its name) and a value if the parameter is not in the list, it is inserted at the end of the list. if it's in the list replace its value and move it at the end of the list.
Definition at line 286 of file KVNameValueList.h.
set if the KVNameValueList owns its objects or not by default it is owner
Definition at line 354 of file KVNameValueList.cpp.
|
inline |
associate a parameter (define by its name) and a value if the parameter is not in the list, it is added if it's in the list replace its value
Definition at line 234 of file KVNameValueList.h.
void KVNameValueList::SetValue | ( | const KVNamedParameter & | p | ) |
add (or replace) a parameter with the same name, type & value as 'p'
Definition at line 404 of file KVNameValueList.cpp.
Store a 64-bit integer in the list as two 32-bit parameters with names 'name_up' and 'name_lo'
Definition at line 419 of file KVNameValueList.cpp.
|
inline |
associate a parameter (define by its name) and a value if the parameter is not in the list, it is inserted at location idx in the list. if it's in the list replace its value and move it at location idx in the list.
Definition at line 248 of file KVNameValueList.h.
|
inline |
Sort a list of numerical values into ascending order (by default). Use order = kSortDescending to reverse order.
Definition at line 449 of file KVNameValueList.h.
void KVNameValueList::WriteClass | ( | const Char_t * | classname, |
const Char_t * | classdesc, | ||
const Char_t * | base_class = "" |
||
) |
Generate a class with member variables and Get/Set methods corresponding to the names and types of the parameters in the list For booleans we use Isxxxx/SetIsxxx
Definition at line 765 of file KVNameValueList.cpp.
Write all name-value pairs in this list as a TEnv format file.
Definition at line 736 of file KVNameValueList.cpp.
Write the values of all parameters in the KVNameValueList in the TEnv, optionally using the given prefix.
Definition at line 801 of file KVNameValueList.cpp.
|
private |
do not convert "yes", "false", "on", etc. in TEnv file to boolean
Definition at line 119 of file KVNameValueList.h.
|
private |
list of KVNamedParameter objects
Definition at line 118 of file KVNameValueList.h.