KaliVeda
Toolkit for HIC analysis
|
A generic named parameter storing values of different types.
The four different types which are handled are: int
, double
, bool
, TString
:
The same parameter can be reused to store a value with a different type:
To retrieve the value of the parameter, its type must be given. This need not be the original type of the parameter, some common sense transformations are allowed:
Two types of comparison are possible. The ==
operator or member function IsEqual() test for strict equality between two parameters, i.e. they must have the same type, value, and name:
On the other hand, HasTheSameValueAs() returns true
as long as both parameters have the same type and value:
The methods WriteToEnv(TEnv*, const TString &) and Set(TEnv*, const TString &) can be used to read/write parameter lists from/to ROOT resource files (.rootrc
-style files).
Add(const KVNamedParameter &) will sum the values of two numerical parameters or concatenate two string parameters with a separating comma.
Definition at line 90 of file KVNamedParameter.h.
#include <KVNamedParameter.h>
Classes | |
struct | typecode |
struct | typecode< bool > |
struct | typecode< cstring > |
struct | typecode< double > |
struct | typecode< int > |
struct | typecode< KVString > |
struct | typecode< std::string > |
struct | typecode< TString > |
Public Member Functions | |
KVNamedParameter () | |
Default constructor. | |
KVNamedParameter (const char *) | |
KVNamedParameter (const char *, Bool_t) | |
KVNamedParameter (const char *, const char *) | |
KVNamedParameter (const char *, const KVNamedParameter &) | |
Create parameter with given name "nom", and the type & value of "p". | |
KVNamedParameter (const char *, Double_t) | |
KVNamedParameter (const char *, Int_t) | |
virtual | ~KVNamedParameter () |
Destructor. | |
void | Add (const KVNamedParameter &p) |
virtual void | Clear (Option_t *="") |
Removes the name and any assigned value. | |
Int_t | Compare (const TObject *obj) const |
Compares numerical parameters for sorting lists (such as KVNameValueList) | |
template<typename T > | |
T | Get () const |
template<> | |
int | Get () const |
template<> | |
double | Get () const |
template<> | |
bool | Get () const |
template<> | |
KVString | Get () const |
template<> | |
TString | Get () const |
template<> | |
cstring | Get () const |
Bool_t | GetBool () const |
Double_t | GetDouble () const |
Int_t | GetInt () const |
const Char_t * | GetSQLType () const |
const Char_t * | GetString () const |
TString | GetTString () const |
Bool_t | HasSameValueAs (const KVNamedParameter &) const |
template<typename T > | |
Bool_t | Is () const |
Bool_t | IsBool () const |
Bool_t | IsDouble () const |
Bool_t | IsEqual (const TObject *obj) const |
Bool_t | IsInt () const |
Bool_t | IsNumber () const |
Bool_t | IsString () const |
virtual void | ls (Option_t *opt="") const |
Bool_t | operator== (const KVNamedParameter &) const |
virtual void | Print (Option_t *opt="") const |
void | Set (Bool_t) |
void | Set (const char *) |
void | Set (const char *, Bool_t) |
void | Set (const char *, const char *) |
void | Set (const char *, const KVNamedParameter &) |
Set parameter name "nom" with the type & value of "p". | |
void | Set (const char *, Double_t) |
void | Set (const char *, Int_t) |
void | Set (Double_t) |
void | Set (Int_t) |
void | Set (TEnv *, const TString &p="") |
void Set(const KVNamedParameter&); | |
void | WriteToEnv (TEnv *, const TString &p="") |
Write parameter in TEnv, using optional prefix p as "p.[name]". | |
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 | 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 |
Static Public Member Functions | |
template<typename T > | |
static T | DefaultValue () |
template<> | |
int | DefaultValue () |
template<> | |
double | DefaultValue () |
template<> | |
bool | DefaultValue () |
template<> | |
TString | DefaultValue () |
template<> | |
KVString | DefaultValue () |
template<> | |
cstring | DefaultValue () |
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) |
Private Types | |
enum | { kIsString = BIT(14) , kIsDouble = BIT(15) , kIsInt = BIT(16) , kIsBool = BIT(17) } |
enum | { kBitMask = 0x0003c000 } |
Private Member Functions | |
Int_t | GetType () const |
void | ResetBits () |
void | SetType (UInt_t f) |
Private Attributes | |
Double_t | fNumber |
used to store numerical (integer or floating-point) values | |
Friends | |
class | KVNameValueList |
Additional Inherited Members | |
Public Types inherited from TObject | |
enum | EDeprecatedStatusBits |
enum | EStatusBits |
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 | |
|
private |
Enumerator | |
---|---|
kIsString | |
kIsDouble | |
kIsInt | |
kIsBool |
Definition at line 94 of file KVNamedParameter.h.
|
private |
Enumerator | |
---|---|
kBitMask |
Definition at line 103 of file KVNamedParameter.h.
KVNamedParameter::KVNamedParameter | ( | ) |
Default constructor.
Definition at line 17 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom | ) |
Definition at line 37 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
const char * | val | ||
) |
Definition at line 47 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
Double_t | val | ||
) |
Definition at line 79 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
Int_t | val | ||
) |
Definition at line 111 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
Bool_t | val | ||
) |
Definition at line 121 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
const KVNamedParameter & | p | ||
) |
Create parameter with given name "nom", and the type & value of "p".
Definition at line 132 of file KVNamedParameter.cpp.
|
virtual |
Destructor.
Definition at line 28 of file KVNamedParameter.cpp.
void KVNamedParameter::Add | ( | const KVNamedParameter & | p | ) |
Numerical values: Add the numerical value of "p" to this parameter Strings: add string to comma-separated list of values If parameters are not same type, print warning and do nothing
Definition at line 181 of file KVNamedParameter.cpp.
Removes the name and any assigned value.
Reimplemented from TObject.
Definition at line 259 of file KVNamedParameter.cpp.
Compares numerical parameters for sorting lists (such as KVNameValueList)
Reimplemented from TObject.
Definition at line 501 of file KVNamedParameter.cpp.
|
inlinestatic |
Definition at line 231 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 235 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 239 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 243 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 247 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 251 of file KVNamedParameter.h.
compile-time error if one of allowed specializations not used
Definition at line 155 of file KVNamedParameter.h.
|
inline |
Definition at line 203 of file KVNamedParameter.h.
|
inline |
Definition at line 207 of file KVNamedParameter.h.
|
inline |
Definition at line 211 of file KVNamedParameter.h.
|
inline |
Definition at line 215 of file KVNamedParameter.h.
|
inline |
Definition at line 219 of file KVNamedParameter.h.
|
inline |
Definition at line 223 of file KVNamedParameter.h.
Bool_t KVNamedParameter::GetBool | ( | ) | const |
returns boolean if parameter value is of boolean type if string, conversion to integer is attempted
Definition at line 353 of file KVNamedParameter.cpp.
Double_t KVNamedParameter::GetDouble | ( | ) | const |
returns double if parameter value is of numerical type if string, conversion to floating point is attempted
Definition at line 319 of file KVNamedParameter.cpp.
Int_t KVNamedParameter::GetInt | ( | ) | const |
returns integer if parameter value is of numerical type if string, conversion to integer is attempted
Definition at line 336 of file KVNamedParameter.cpp.
const Char_t * KVNamedParameter::GetSQLType | ( | ) | const |
Returns type of parameter for use in SQLite database "INTEGER", "REAL", or "TEXT"
Definition at line 535 of file KVNamedParameter.cpp.
const Char_t * KVNamedParameter::GetString | ( | ) | const |
Returns value of parameter as a string, whatever the type (integer or floating values are converted to a string, booleans are "true" or "false")
Definition at line 274 of file KVNamedParameter.cpp.
TString KVNamedParameter::GetTString | ( | ) | const |
Returns value of parameter as a TString, whatever the type (integer or floating values are converted to a string)
Definition at line 297 of file KVNamedParameter.cpp.
|
inlineprivate |
compare this value with the values kIsString, kIsDouble, etc.
Definition at line 111 of file KVNamedParameter.h.
Bool_t KVNamedParameter::HasSameValueAs | ( | const KVNamedParameter & | other | ) | const |
Returns kTRUF if the two parameters have the same type and the same value (don't care about parameter names)
Definition at line 401 of file KVNamedParameter.cpp.
Definition at line 283 of file KVNamedParameter.h.
|
inline |
Definition at line 179 of file KVNamedParameter.h.
|
inline |
Definition at line 171 of file KVNamedParameter.h.
Test for equality between two parameters Returns kTRUE if both the name, the type, and the value of the parameters are identical
Reimplemented from TObject.
Definition at line 370 of file KVNamedParameter.cpp.
|
inline |
Definition at line 175 of file KVNamedParameter.h.
|
inline |
Definition at line 183 of file KVNamedParameter.h.
|
inline |
Definition at line 167 of file KVNamedParameter.h.
compact listing of parameter name & value, used by KVNameValueList::Print option controls what is printed: "" (default) : all parameters "int" : only integer parameters "bool" : only boolean parameters "double" : only double parameters "string" : only string parameters
Reimplemented from TObject.
Definition at line 453 of file KVNamedParameter.cpp.
Bool_t KVNamedParameter::operator== | ( | const KVNamedParameter & | other | ) | const |
Test for equality between two parameters Returns kTRUE if both the name, the type, and the value of the parameters are identical
Definition at line 386 of file KVNamedParameter.cpp.
Reimplemented from TObject.
Definition at line 433 of file KVNamedParameter.cpp.
|
inlineprivate |
Definition at line 106 of file KVNamedParameter.h.
Definition at line 216 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | val | ) |
Definition at line 68 of file KVNamedParameter.cpp.
Definition at line 154 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | name, |
const char * | val | ||
) |
Definition at line 57 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | nom, |
const KVNamedParameter & | p | ||
) |
Set parameter name "nom" with the type & value of "p".
Definition at line 166 of file KVNamedParameter.cpp.
Definition at line 89 of file KVNamedParameter.cpp.
Definition at line 143 of file KVNamedParameter.cpp.
Definition at line 100 of file KVNamedParameter.cpp.
Definition at line 205 of file KVNamedParameter.cpp.
void Set(const KVNamedParameter&);
Look for value in TEnv with same name as this parameter, or prefixed with "p." If found, set value according to TEnv
Definition at line 240 of file KVNamedParameter.cpp.
Definition at line 117 of file KVNamedParameter.h.
Write parameter in TEnv, using optional prefix p as "p.[name]".
Definition at line 517 of file KVNamedParameter.cpp.
|
friend |
Definition at line 92 of file KVNamedParameter.h.
|
private |
used to store numerical (integer or floating-point) values
Definition at line 124 of file KVNamedParameter.h.