StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FwdTrackerConfig.cxx
1 #include "FwdTrackerConfig.h"
2 
3 const std::string FwdTrackerConfig::valDNE = std::string( "<DNE/>" );
4 const std::string FwdTrackerConfig::pathDelim = std::string( "." );
5 const std::string FwdTrackerConfig::attrDelim = std::string( ":" );
6 std::stringstream FwdTrackerConfig::sstr;
7 
9 // template specializations
11 
19 template <>
20 void FwdTrackerConfig::set( std::string path, std::string v ) {
21 
23  // convrt from string to type T and return
24  mNodes[ path ] = v;
25 }
26 
34 template <>
35 void FwdTrackerConfig::set( std::string path, bool bv ) {
36 
38  // convrt from string to type T and return
39  std::string v = "false";
40  if (bv)
41  v = "true";
42  mNodes[ path ] = v;
43 }
44 
45 //
54 template <>
55 std::string FwdTrackerConfig::get( std::string path, std::string dv ) const {
56  // return default value if path DNE
57  if ( !exists( path ) )
58  return dv;
60  // directly return string
61  return ( mNodes.at( path ) );
62 }
63 
71 template <>
72 std::string FwdTrackerConfig::convert( std::string str ) const {
73  return str;
74 }
75 
84 template <>
85 bool FwdTrackerConfig::convert( std::string str ) const {
86 
87  if ( str == "false" )
88  return false;
89 
90  if ( str == "true" )
91  return true;
92  // fall back to an int cast
93  return static_cast<bool>(convert<int>( str ));
94 }
95 
103 template <>
104 TString FwdTrackerConfig::convert(std::string str) const {
105  TString r(str);
106  return r;
107 }
bool exists(std::string path) const
returns whether or not a path exist Either node or attribute - used to determine if default value is ...
T convert(std::string s) const
Generic conversion of type T from string override this for special conversions.
void set(std::string path, T v)
Writes a value of type T to the map Uses convertTo&lt;T&gt; to convert type T to a string rep...
T get(std::string path, T dv) const
template function for getting any type that can be converted from string via stringstream ...
static void canonize(std::string &path)
Returns a path in its cannonical form.