![]() |
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 *, Double_t) | |
KVNamedParameter (const char *, Int_t) | |
virtual | ~KVNamedParameter () |
Destructor. More... | |
void | Add (const KVNamedParameter &p) |
virtual void | Clear (Option_t *="") |
Removes the name and any assigned value. More... | |
Int_t | Compare (const TObject *obj) const |
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 |
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". More... | |
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&); More... | |
void | WriteToEnv (TEnv *, const TString &p="") |
Write parameter in TEnv, using optional prefix p as "p.[name]". More... | |
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 () |
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 |
|
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.
|
virtual |
Removes the name and any assigned value.
Definition at line 259 of file KVNamedParameter.cpp.
Int_t KVNamedParameter::Compare | ( | const TObject * | obj | ) | const |
Compares numerical parameters for sorting lists (such as KVNameValueList)
Definition at line 501 of file KVNamedParameter.cpp.
|
static |
|
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.
|
inline |
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.
|
inline |
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.
Bool_t KVNamedParameter::IsEqual | ( | const TObject * | obj | ) | 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 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.
|
virtual |
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
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.
|
virtual |
Definition at line 433 of file KVNamedParameter.cpp.
|
inlineprivate |
Definition at line 106 of file KVNamedParameter.h.
void KVNamedParameter::Set | ( | Bool_t | val | ) |
Definition at line 216 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | val | ) |
Definition at line 68 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | name, |
Bool_t | val | ||
) |
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.
void KVNamedParameter::Set | ( | const char * | name, |
Double_t | val | ||
) |
Definition at line 89 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | const char * | name, |
Int_t | val | ||
) |
Definition at line 143 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | Double_t | val | ) |
Definition at line 100 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | Int_t | val | ) |
Definition at line 205 of file KVNamedParameter.cpp.
void KVNamedParameter::Set | ( | TEnv * | e, |
const TString & | p = "" |
||
) |
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.
|
inlineprivate |
Definition at line 117 of file KVNamedParameter.h.
void KVNamedParameter::WriteToEnv | ( | TEnv * | e, |
const TString & | p = "" |
||
) |
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.