KaliVeda
Toolkit for HIC analysis
KVEnv Class Reference

Detailed Description

Extension of TEnv to allow the writing of comments in the file.

Created by KVClassFactory on Mon Jan 14 12:23:45 2013 Author: bonnet

Definition at line 18 of file KVEnv.h.

#include <KVEnv.h>

Inheritance diagram for KVEnv:

Classes

class  Value
 

Public Member Functions

 KVEnv (const KVString &name="")
 
 KVEnv (TEnv &)
 
void AddCommentLine (const Char_t *line)
 
void AddComments (const Char_t *comments)
 
void ClearComments ()
 
void CopyTable (TEnv &env)
 Copy table of env to this. More...
 
template<typename... Ts>
Value GetValueOf (Ts... args) const
 
Bool_t HasValue (const KVString &val) const
 
template<typename... Ts>
Bool_t HasValue (Ts... args) const
 
void PrintComments ()
 
Int_t WriteFile (const char *fname, EEnvLevel level=kEnvAll) override
 

Constructor & Destructor Documentation

◆ KVEnv() [1/2]

KVEnv::KVEnv ( const KVString &  name = "")

The TEnv constructor has a major bug: its behaviour changes depending on whether the current working directory is the user's home directory or not. If the two are not the same, i.e. outside the home directory, the constructor will try to read the file using just the name as given, after failing to find it in the home directory: in this case, when an absolute filename is given, the TEnv constructor succeeds in finding and opening the file. However, if the same code is executed while in the user's home directory (e.g. user launches 'kaliveda', or 'KaliVedaGUI' or 'KaliVedaSim' in her home directory), this does not work!

Here we try to correct this madness.

Definition at line 25 of file KVEnv.cpp.

◆ KVEnv() [2/2]

KVEnv::KVEnv ( TEnv &  other)

Copy constructor

Copies all key-value pairs from other to this

Definition at line 50 of file KVEnv.cpp.

Member Function Documentation

◆ AddCommentLine()

void KVEnv::AddCommentLine ( const Char_t *  line)

Add a comment for the current TEnv the line will started with "# " prefix and will be ended with "\n" postfix

Definition at line 87 of file KVEnv.cpp.

◆ AddComments()

void KVEnv::AddComments ( const Char_t *  comments)

Add comments the comments can contains "\n" character each line contained in the comments will begin with "# " prefix and will be ended with "\n" postfix

Definition at line 106 of file KVEnv.cpp.

◆ ClearComments()

void KVEnv::ClearComments ( )

Definition at line 125 of file KVEnv.cpp.

◆ CopyTable()

void KVEnv::CopyTable ( TEnv &  env)

Copy table of env to this.

Definition at line 65 of file KVEnv.cpp.

◆ GetValueOf()

template<typename... Ts>
Value KVEnv::GetValueOf ( Ts...  args) const
inline

Given a list of qualifiers and a default return value/type

GetValueOf("XD", "Moon", "Npart").Default("")
GetValueOf("XD", "Moon", "Npart").Default(0)
GetValueOf("XD", "Moon", "Npart").Default(-1.0)
GetValueOf("XD", "Moon", "Npart").Default<KVString>()
GetValueOf("XD", "Moon", "Npart").Default<int>()
GetValueOf("XD", "Moon", "Npart").Default<double>()
ValueType Default(ValueType v=ValueType{}) const
Definition: KVEnv.h:59
Value GetValueOf(Ts... args) const
Definition: KVEnv.h:70
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73

return the value of

XD.Moon.Npart: [value]

as a const char*, int, double, KVString, int, double, respectively.

Parts of config variable name may be integer values:

GetValueOf("A", 1, "B", 23)

will look for variable

A.1.B.23: [value]

Definition at line 70 of file KVEnv.h.

◆ HasValue() [1/2]

Bool_t KVEnv::HasValue ( const KVString &  val) const
inline

Definition at line 98 of file KVEnv.h.

◆ HasValue() [2/2]

template<typename... Ts>
Bool_t KVEnv::HasValue ( Ts...  args) const
inline

Definition at line 103 of file KVEnv.h.

◆ PrintComments()

void KVEnv::PrintComments ( )

print comments as they will be written in the file

Definition at line 136 of file KVEnv.cpp.

◆ WriteFile()

Int_t KVEnv::WriteFile ( const char *  fname,
EEnvLevel  level = kEnvAll 
)
override

Write first comments associated to the current TEnv Write resourse records to file fname for a certain level. Use level kEnvAll to write all resources. Returns -1 on case of error, 0 in case of success.

Definition at line 157 of file KVEnv.cpp.