![]() |
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. More... | |
KVNameValueList (const Char_t *name, const Char_t *title="") | |
KVNameValueList (const KVNameValueList &) | |
Copy constructor. More... | |
KVNameValueList (std::initializer_list< KVNamedParameter >) | |
virtual | ~KVNameValueList () |
Destructor. More... | |
void | AddValue (const KVNamedParameter &p) |
Iterator | begin () const |
void | Clear (Option_t *opt="") override |
virtual void | ClearSelection (TRegexp &) |
Int_t | Compare (const TObject *nvl) const override |
void | Concatenate (const KVNameValueList &nvl) |
void | Copy (TObject &nvl) const override |
Iterator | end () const |
KVNamedParameter * | FindParameter (const Char_t *name) const |
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 |
KVNamedParameter * | GetParameter (Int_t idx) const |
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 |
TString | List (Option_t *opt="") const |
void | ls (Option_t *opt="") const override |
void | Merge (const KVNameValueList &) |
KVNameValueList & | operator= (const KVNameValueList &) |
void | Print (Option_t *opt="") const override |
virtual KVEnv * | ProduceEnvFile () |
virtual void | ReadEnv (const TEnv &) |
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 &) |
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) |
void | WriteToEnv (TEnv *tenv, const TString &prefix="") |
![]() | |
TNamed () | |
TNamed (const char *name, const char *title) | |
TNamed (const TNamed &named) | |
TNamed (const TString &name, const TString &title) | |
virtual | ~TNamed () |
TObject * | Clone (const char *newname="") 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 |
TNamed & | operator= (const TNamed &rhs) |
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) |
![]() | |
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 More... | |
KVHashList | fList |
list of KVNamedParameter objects More... | |
Additional Inherited Members | |
![]() | |
enum | EDeprecatedStatusBits |
enum | EStatusBits |
![]() | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
![]() | |
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) |
![]() | |
kBitMask | |
kCanDelete | |
kCannotPick | |
kHasUUID | |
kInconsistent | |
kInvalidObject | |
kIsOnHeap | |
kIsReferenced | |
kMustCleanup | |
kNoContextMenu | |
kNotDeleted | |
kObjInCanvas | |
kOverwrite | |
kSingleKey | |
kWriteDelete | |
kZombie | |
![]() | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
void | MakeZombie () |
![]() | |
TString | fName |
TString | fTitle |
![]() | |
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 | ) |
Definition at line 512 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 TNamed.
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.
Reimplemented from TNamed.
Definition at line 443 of file KVNameValueList.cpp.
void KVNameValueList::Concatenate | ( | const KVNameValueList & | nvl | ) |
Definition at line 719 of file KVNameValueList.cpp.
Copy this to the nvl object. Any existing parameters will be destroyed
Reimplemented from TNamed.
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 |
Definition at line 523 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 404 of file KVNameValueList.h.
Definition at line 432 of file KVNameValueList.h.
Definition at line 408 of file KVNameValueList.h.
Definition at line 436 of file KVNameValueList.h.
|
inline |
Definition at line 380 of file KVNameValueList.h.
Definition at line 400 of file KVNameValueList.h.
Definition at line 428 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.
Definition at line 577 of file KVNameValueList.cpp.
Definition at line 559 of file KVNameValueList.cpp.
Definition at line 607 of file KVNameValueList.cpp.
KVNamedParameter * KVNameValueList::GetParameter | ( | Int_t | idx | ) | const |
Definition at line 529 of file KVNameValueList.cpp.
Definition at line 412 of file KVNameValueList.h.
Definition at line 440 of file KVNameValueList.h.
Definition at line 592 of file KVNameValueList.cpp.
Definition at line 614 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 390 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 419 of file KVNameValueList.h.
Definition at line 484 of file KVNameValueList.cpp.
Definition at line 349 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 353 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 339 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 367 of file KVNameValueList.h.
Definition at line 549 of file KVNameValueList.cpp.
|
inline |
Return kTRUE if list has parameter called 'name' and it is of given type
Definition at line 332 of file KVNameValueList.h.
Definition at line 363 of file KVNameValueList.h.
Definition at line 500 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 306 of file KVNameValueList.h.
|
inline |
Definition at line 384 of file KVNameValueList.h.
Bool_t KVNameValueList::IsOwner | ( | ) | const |
Definition at line 435 of file KVNameValueList.cpp.
|
inline |
Returns kTRUE if parameter with given name exists and is equal to given value
Definition at line 316 of file KVNameValueList.h.
Definition at line 353 of file KVNameValueList.cpp.
Reimplemented from TNamed.
Definition at line 400 of file KVNameValueList.cpp.
void KVNameValueList::Merge | ( | const KVNameValueList & | other | ) |
Definition at line 760 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:
If you want to exclude 1 or more parameters, add "|name1,name2,..." after the option
Reimplemented from TNamed.
Reimplemented in KVValues.
Definition at line 305 of file KVNameValueList.cpp.
|
virtual |
Definition at line 698 of file KVNameValueList.cpp.
Definition at line 655 of file KVNameValueList.cpp.
Definition at line 627 of file KVNameValueList.cpp.
Definition at line 536 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 268 of file KVNameValueList.h.
Definition at line 741 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 462 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 287 of file KVNameValueList.h.
Definition at line 427 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 235 of file KVNameValueList.h.
void KVNameValueList::SetValue | ( | const KVNamedParameter & | p | ) |
Definition at line 462 of file KVNameValueList.cpp.
Definition at line 471 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 249 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 451 of file KVNameValueList.h.
void KVNameValueList::WriteClass | ( | const Char_t * | classname, |
const Char_t * | classdesc, | ||
const Char_t * | base_class = "" |
||
) |
Definition at line 730 of file KVNameValueList.cpp.
Definition at line 709 of file KVNameValueList.cpp.
Definition at line 752 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.