|
ATLAS Offline Software
|
Go to the documentation of this file.
41 template<
class T>
struct TypeName
43 static std::string
name () {
return typeid (T).
name();}
46 template<> struct TypeName<X> { \
47 static std::string name () {return #X;}; };
55 template<
class From,
class To>
struct Convert
57 static void convert (
const std::string& , To& ,
const std::string&
field)
72 template<
class To>
struct Convert<std::string,To>
74 static void convert (
const std::string& from, To&
to,
const std::string&
field)
76 std::stringstream
ss (from);
79 if (!(
ss.fail() ||
ss.rdbuf()->in_avail() > 0))
90 template<
class Type>
struct Convert<
Type,
Type>
98 template<
class From>
struct Convert<From,std::string>
100 static void convert (
const From& from, std::string&
to,
const std::string& )
102 std::ostringstream
ss;
108 template<>
struct Convert<
bool,std::string>
110 static void convert (
const bool& from, std::string&
to,
const std::string& )
119 template<>
struct Convert<std::string,
bool>
121 static void convert (
const std::string& from,
bool&
to,
const std::string&
field)
123 if (from ==
"true" || from ==
"True" || from ==
"TRUE" || from ==
"1")
128 if (from ==
"false" || from ==
"False" || from ==
"FALSE" || from ==
"0")
135 RCU_THROW_MSG (
"unable to convert string '" + from +
"' to type bool for field " +
field);
139 #define DEFAULT_CONVERT(FROM,TO) \
140 template<> struct Convert<FROM,TO> { \
141 static void convert (const FROM& from, TO& to, const std::string& ) { \
150 #undef DEFAULT_CONVERT
153 template<
class From,
class To>
bool
154 convertSingle (
const TObject *from, To&
to,
const std::string&
field)
156 const MetaData<From> *myfrom =
157 dynamic_cast<const MetaData<From>*
>(from);
164 template<
class To>
void
167 if (convertSingle<std::string> (from,
to,
field))
return;
168 if (convertSingle<double> (from,
to,
field))
return;
169 if (convertSingle<int> (from,
to,
field))
return;
170 if (convertSingle<bool> (from,
to,
field))
return;
172 RCU_THROW_MSG (
"unkown input type " + std::string (
typeid(*from).name()) +
" for field " +
field);
180 std::string
trim (
const std::string&
str)
182 size_t endpos =
str.find_last_not_of(
" \t");
183 size_t startpos =
str.find_first_not_of(
" \t");
184 if( std::string::npos == endpos )
return "";
185 if(
str[startpos] ==
'"' ||
str[startpos] ==
'\'') startpos++;
186 if(
str[endpos] ==
'"' ||
str[endpos] ==
'\'') endpos--;
187 return str.substr( startpos, endpos+1-startpos );
221 std::string
dbg (
const MetaObject& ,
unsigned )
228 void swap (MetaObject&
a, MetaObject&
b)
245 : m_dataList (
new TList)
247 m_dataList->SetOwner(
true);
255 : TCollection (), m_dataList (
new TList)
257 m_dataList->SetOwner(
true);
260 while ((
object = iter.Next()))
262 m_dataList->Add (
object->Clone());
292 swap (MetaObject& that)
314 std::unique_ptr<TNamed> meta (meta_swallow);
318 remove (meta_swallow->GetName());
334 get (
const std::string&
name)
const
352 getString (
const std::string&
name,
const std::string& def_val)
const
429 while ((
object = iter.Next()))
431 TNamed *
const named =
dynamic_cast<TNamed*
>(
object);
435 }
else if (strncmp (named->GetName(),
"nc_", 3) != 0)
437 addReplace (
dynamic_cast<TNamed*
>(named->Clone ()));
451 while ((
object = iter.Next()))
461 Add (TObject *meta_swallow)
463 std::unique_ptr<TObject> meta (meta_swallow);
472 Clear (Option_t *option)
528 Streamer (TBuffer&
b)
533 TObject::Streamer (
b);
539 TObject::Streamer (
b);
546 castT (
const std::string&
name, T def_val, CastMode
mode)
const
549 const TObject* meta =
get (
name);
552 const MetaData<T> *
const retval =
dynamic_cast<const MetaData<T>*
>(meta);
600 std::stringstream
ss;
603 while( (
obj = itr->Next()) ){
604 Meta*
m =
dynamic_cast<Meta*
>(
obj);
606 if(!
ss.str().empty())
ss <<
", ";
607 ss <<
m->GetName() <<
"=";
608 MetaData<std::string>*
s =
dynamic_cast<MetaData<std::string>*
>(
m);
610 ss <<
"\"" <<
s->value <<
"\"";
612 std::string mystring;
613 convert<std::string> (
m, mystring,
m->GetName());
std::string dbg(const Meta &, unsigned)
#define RCU_PROVIDE2(x, y)
#define RCU_REQUIRE_SOFT(x)
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
#define RCU_DESTROY_INVARIANT(x)
void trim(std::string &input)
#define RCU_CHANGE_INVARIANT(x)
This module provides a lot of global definitions, forward declarations and includes that are used by ...
#define RCU_THROW_MSG(message)
setBGCode setTAP setLVL2ErrorBits bool
#define RCU_READ_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)