![]() |
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. More... | |
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". More... | |
KVNamedParameter (const char *, const std::string &) | |
KVNamedParameter (const char *, Double_t) | |
KVNamedParameter (const char *, Int_t) | |
virtual | ~KVNamedParameter () |
Destructor. More... | |
void | Add (const KVNamedParameter &p) |
void | Clear (Option_t *="") override |
Removes the name and any assigned value. More... | |
Int_t | Compare (const TObject *obj) const override |
Compares numerical parameters for sorting lists (such as KVNameValueList) More... | |
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 override |
Bool_t | IsInt () const |
Bool_t | IsNumber () const |
Bool_t | IsString () const |
void | ls (Option_t *opt="") const override |
Bool_t | operator== (const KVNamedParameter &) const |
void | Print (Option_t *opt="") const override |
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". More... | |
void | Set (const char *, const std::string &) |
void | Set (const char *, Double_t) |
void | Set (const char *, Int_t) |
void | Set (const std::string &) |
void | Set (Double_t) |
void | Set (Int_t) |
void | Set (TEnv *, const TString &p="") |
void Set(const KVNamedParameter&); More... | |
void | WriteToEnv (TEnv *, const TString &p="") |
Write parameter in TEnv, using optional prefix p as "p.[name]". More... | |
![]() | |
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 |
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 |
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 | 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 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) |
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 More... | |
Friends | |
class | KVNameValueList |
Additional Inherited Members | |
![]() | |
enum | EDeprecatedStatusBits |
enum | EStatusBits |
![]() | |
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 | |
|
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, |
const std::string & | val | ||
) |
Definition at line 79 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
Double_t | val | ||
) |
Definition at line 111 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
Int_t | val | ||
) |
Definition at line 143 of file KVNamedParameter.cpp.
KVNamedParameter::KVNamedParameter | ( | const char * | nom, |
Bool_t | val | ||
) |
Definition at line 153 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 164 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 213 of file KVNamedParameter.cpp.
Removes the name and any assigned value.
Reimplemented from TNamed.
Definition at line 290 of file KVNamedParameter.cpp.
Compares numerical parameters for sorting lists (such as KVNameValueList)
Reimplemented from TNamed.
Definition at line 532 of file KVNamedParameter.cpp.
|
static |
|
inlinestatic |
Definition at line 234 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 238 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 242 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 246 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 250 of file KVNamedParameter.h.
|
inlinestatic |
Definition at line 254 of file KVNamedParameter.h.
|
inline |
compile-time error if one of allowed specializations not used
Definition at line 158 of file KVNamedParameter.h.
|
inline |
Definition at line 206 of file KVNamedParameter.h.
|
inline |
Definition at line 210 of file KVNamedParameter.h.
|
inline |
Definition at line 214 of file KVNamedParameter.h.
|
inline |
Definition at line 218 of file KVNamedParameter.h.
|
inline |
Definition at line 222 of file KVNamedParameter.h.
|
inline |
Definition at line 226 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 384 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 350 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 367 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 566 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 305 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 328 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 432 of file KVNamedParameter.cpp.
|
inline |
Definition at line 286 of file KVNamedParameter.h.
|
inline |
Definition at line 182 of file KVNamedParameter.h.
|
inline |
Definition at line 174 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 401 of file KVNamedParameter.cpp.
|
inline |
Definition at line 178 of file KVNamedParameter.h.
|
inline |
Definition at line 186 of file KVNamedParameter.h.
|
inline |
Definition at line 170 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 TNamed.
Definition at line 484 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 417 of file KVNamedParameter.cpp.
Reimplemented from TNamed.
Definition at line 464 of file KVNamedParameter.cpp.
|
inlineprivate |
Definition at line 106 of file KVNamedParameter.h.
Definition at line 247 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | val | ) |
Definition at line 68 of file KVNamedParameter.cpp.
Definition at line 186 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 198 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | name, |
const std::string & | val | ||
) |
Definition at line 89 of file KVNamedParameter.cpp.
Definition at line 121 of file KVNamedParameter.cpp.
Definition at line 175 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const std::string & | val | ) |
Definition at line 100 of file KVNamedParameter.cpp.
Definition at line 132 of file KVNamedParameter.cpp.
Definition at line 236 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 271 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 548 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.