StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FwdTrackerConfig Class Reference

Public Member Functions

std::string dump () const
 dump config to a basic string representation - mostly for debugging More...
 
bool exists (std::string path) const
 returns whether or not a path exist Either node or attribute - used to determine if default value is used More...
 
template<typename T >
convert (std::string s) const
 Generic conversion of type T from string override this for special conversions. More...
 
template<typename T >
std::string convertTo (T v) const
 Generic conversion of type T to a string. More...
 
template<typename T >
get (std::string path, T dv) const
 template function for getting any type that can be converted from string via stringstream More...
 
template<typename T >
void set (std::string path, T v)
 Writes a value of type T to the map Uses convertTo<T> to convert type T to a string rep. More...
 
template<typename T >
std::vector< T > getVector (std::string path, std::vector< T > dv) const
 Get a Vector object from config. More...
 
std::vector< std::string > childrenOf (std::string path) const
 list the paths of children nodes for a given node More...
 
 FwdTrackerConfig ()
 Constructor is noop, use load(...)
 
 FwdTrackerConfig (std::string filename)
 Construct a new Fwd Tracker Config object and load a file. More...
 
void load (std::string filename, bool asString=false)
 Main setup routine Loads the given XML file (or string) and maps it. More...
 
template<>
void set (std::string path, std::string v)
 write a value to path More...
 
template<>
void set (std::string path, bool bv)
 write a value to path More...
 
template<>
std::string get (std::string path, std::string dv) const
 Get a value from the path. More...
 
template<>
std::string convert (std::string str) const
 conversion to string is a noop More...
 
template<>
bool convert (std::string str) const
 specialization for bool adds recognition of strings "true" and "false" (lower case) More...
 
template<>
TString convert (std::string str) const
 get as ROOT TString More...
 

Static Public Member Functions

static void canonize (std::string &path)
 Returns a path in its cannonical form. More...
 

Protected Member Functions

size_t pathCount (const std::string path)
 get lowest non-existing path index assumes bare path and adds [i] until DNE starts at 1 since 0 is checked on existance More...
 
void mapFile (TXMLEngine &xml, XMLNodePointer_t node, Int_t level, std::string path="")
 Reads an xml document and writes it into map. More...
 

Protected Attributes

bool mErrorParsing = false
 
std::map< std::string,
std::string > 
mNodes
 

Static Protected Attributes

static const std::string valDNE = std::string( "<DNE/>" )
 
static const std::string pathDelim = std::string( "." )
 
static const std::string attrDelim = std::string( ":" )
 
static std::stringstream sstr
 

Detailed Description

Definition at line 17 of file FwdTrackerConfig.h.

Constructor & Destructor Documentation

FwdTrackerConfig::FwdTrackerConfig ( std::string  filename)
inline

Construct a new Fwd Tracker Config object and load a file.

Parameters
filename

Definition at line 295 of file FwdTrackerConfig.h.

References load().

Member Function Documentation

static void FwdTrackerConfig::canonize ( std::string &  path)
inlinestatic

Returns a path in its cannonical form.

Parameters
pathPath to cannoize, returned in place by reference

Definition at line 103 of file FwdTrackerConfig.h.

Referenced by childrenOf(), exists(), get(), getVector(), and set().

std::vector<std::string> FwdTrackerConfig::childrenOf ( std::string  path) const
inline

list the paths of children nodes for a given node

Parameters
pathpath to search for children
Returns
std::vector<std::string> list of full paths to the children nodes

Definition at line 257 of file FwdTrackerConfig.h.

References canonize().

Referenced by StFwdTrackMaker::Init().

std::string FwdTrackerConfig::convert ( std::string  str) const

conversion to string is a noop

Template Parameters
stringspecialization
Parameters
strinput
Returns
std::string output (unchanged)

Definition at line 72 of file FwdTrackerConfig.cxx.

bool FwdTrackerConfig::convert ( std::string  str) const

specialization for bool adds recognition of strings "true" and "false" (lower case)

Template Parameters
boolspecialization, fallback to int check
Parameters
strinput string
Returns
true for "true"
false for "false"

Definition at line 85 of file FwdTrackerConfig.cxx.

TString FwdTrackerConfig::convert ( std::string  str) const

get as ROOT TString

Template Parameters
TStringspecialization
Parameters
strinput value
Returns
TString output as ROOT TString

Definition at line 104 of file FwdTrackerConfig.cxx.

template<typename T >
T FwdTrackerConfig::convert ( std::string  s) const
inline

Generic conversion of type T from string override this for special conversions.

Template Parameters
T: Type to convert to and return
Parameters
s: input string to use for conversion
Returns
T converted value of type T

Definition at line 156 of file FwdTrackerConfig.h.

template<typename T >
std::string FwdTrackerConfig::convertTo ( v) const
inline

Generic conversion of type T to a string.

Template Parameters
T: type to convert
Parameters
v: value of type T
Returns
std::string output string with representation of T

Definition at line 173 of file FwdTrackerConfig.h.

std::string FwdTrackerConfig::dump ( ) const
inline

dump config to a basic string representation - mostly for debugging

Returns
std::string

Definition at line 122 of file FwdTrackerConfig.h.

bool FwdTrackerConfig::exists ( std::string  path) const
inline

returns whether or not a path exist Either node or attribute - used to determine if default value is used

Parameters
path- the path to check
Returns
true : path exists
false : path DNE

Definition at line 140 of file FwdTrackerConfig.h.

References canonize().

Referenced by get(), and getVector().

std::string FwdTrackerConfig::get ( std::string  path,
std::string  dv 
) const

Get a value from the path.

Template Parameters
Specializationfor string to avoid extra conversions
Parameters
pathpath to lookup
dvdefault value if path DNE
Returns
std::string value at path or default

Definition at line 55 of file FwdTrackerConfig.cxx.

References canonize(), and exists().

template<typename T >
T FwdTrackerConfig::get ( std::string  path,
dv 
) const
inline

template function for getting any type that can be converted from string via stringstream

Template Parameters
Ttype to return
Parameters
pathpath to lookup
dvdefault value to return if the node DNE
Returns
T return value of type T

Definition at line 190 of file FwdTrackerConfig.h.

References canonize(), and exists().

Referenced by StFwdTrackMaker::Finish(), StFwdTrackMaker::Init(), and StFwdTrackMaker::Make().

template<typename T >
std::vector<T> FwdTrackerConfig::getVector ( std::string  path,
std::vector< T >  dv 
) const
inline

Get a Vector object from config.

Template Parameters
Ttype of value for the vector object
Parameters
pathpath to lookup
dvdefault value, can use initializer list
Returns
std::vector<T> vector of type T returned

Definition at line 224 of file FwdTrackerConfig.h.

References canonize(), and exists().

void FwdTrackerConfig::load ( std::string  filename,
bool  asString = false 
)
inline

Main setup routine Loads the given XML file (or string) and maps it.

Parameters
filenamefilename (or xml string) to load. If file the content is loaded as an xml doc
asStringfalse: filename is loaded and contents treated as xml doc, true: treat the string filename directly as an xml doc

Definition at line 305 of file FwdTrackerConfig.h.

References mapFile().

Referenced by FwdTrackerConfig().

void FwdTrackerConfig::mapFile ( TXMLEngine &  xml,
XMLNodePointer_t  node,
Int_t  level,
std::string  path = "" 
)
inlineprotected

Reads an xml document and writes it into map.

Parameters
xmlxml document to map
nodestarting node - allows recursive mapping
levelthe integer index of the level of current parsing
paththe path for the current node

Definition at line 54 of file FwdTrackerConfig.h.

References pathCount().

Referenced by load().

size_t FwdTrackerConfig::pathCount ( const std::string  path)
inlineprotected

get lowest non-existing path index assumes bare path and adds [i] until DNE starts at 1 since 0 is checked on existance

Parameters
pathbase path to check
Returns
size_t index, starts at 1

Definition at line 36 of file FwdTrackerConfig.h.

Referenced by mapFile().

void FwdTrackerConfig::set ( std::string  path,
std::string  v 
)

write a value to path

Template Parameters
templatespecialization for std::string
Parameters
pathpath to write, if it DNE it is created
vvalue (of type string) to write

Definition at line 20 of file FwdTrackerConfig.cxx.

References canonize().

void FwdTrackerConfig::set ( std::string  path,
bool  bv 
)

write a value to path

Template Parameters
templatespecialization for bool
Parameters
pathpath to write, if it DNE it is created
bvboolean to write

Definition at line 35 of file FwdTrackerConfig.cxx.

References canonize().

template<typename T >
void FwdTrackerConfig::set ( std::string  path,
v 
)
inline

The documentation for this class was generated from the following files: