ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
SH::MetaObject Class Reference

A class that manages meta-data to be associated with an object. More...

#include <MetaObject.h>

Inheritance diagram for SH::MetaObject:
Collaboration diagram for SH::MetaObject:

Public Types

enum  CastMode { CAST_ERROR_THROW, CAST_ERROR_DEFAULT, CAST_NOCAST_THROW, CAST_NOCAST_DEFAULT }
 the different modes for casts More...
 

Public Member Functions

void testInvariant () const
 test the invariant of this object More...
 
 MetaObject ()
 standard constructor More...
 
 MetaObject (const MetaObject &that)
 standard copy constructor More...
 
virtual ~MetaObject ()
 standard destructor More...
 
MetaObjectoperator= (const MetaObject &that)
 standard assignment operator More...
 
void swap (MetaObject &that)
 standard swap More...
 
void remove (const std::string &name)
 remove all meta-information with the given name More...
 
void addReplace (TNamed *meta_swallow)
 add a meta-data object and remove any existing meta-data with the same name More...
 
TObject * get (const std::string &name)
 the meta-data object with the given name More...
 
const TObject * get (const std::string &name) const
 
double getDouble (const std::string &name, double def_val=0) const
 the meta-data double with the given name More...
 
std::string getString (const std::string &name, const std::string &def_val="") const
 the meta-data string with the given name More...
 
template<class T >
castT (const std::string &name, T def_val, CastMode mode) const
 the meta-data element with the given name More...
 
double castDouble (const std::string &name, double def_val=0, CastMode mode=CAST_ERROR_THROW) const
 the meta-data double with the given name More...
 
std::string castString (const std::string &name, const std::string &def_val="", CastMode mode=CAST_ERROR_THROW) const
 the meta-data string with the given name More...
 
int castInteger (const std::string &name, int def_val=0, CastMode mode=CAST_ERROR_THROW) const
 the meta-data integer with the given name More...
 
bool castBool (const std::string &name, bool def_val=false, CastMode mode=CAST_ERROR_THROW) const
 the meta-data boolean with the given name More...
 
void setDouble (const std::string &name, double value)
 set the meta-data double with the given name More...
 
void setString (const std::string &name, const std::string &value)
 set the meta-data string with the given name More...
 
void setInteger (const std::string &name, int value)
 set the meta-data integer with the given name More...
 
void setBool (const std::string &name, bool value)
 set the meta-data boolean with the given name More...
 
template<class T >
void setT (const std::string &name, T value)
 set the meta-data element with the given name More...
 
void fetch (const MetaObject &source)
 fetch the meta-data from the given sample. More...
 
void fetchDefaults (const MetaObject &source)
 fetch the meta-data from the given sample not present in this sample. More...
 
void fetchFromString (const std::string &source)
 fetch the meta-data from a given string More...
 
std::string dumpToString ()
 dump the meta-data to a string More...
 
virtual void Add (TObject *meta_swallow)
 add another object to the collection More...
 
virtual void Clear (Option_t *option="")
 clear out the content of the collection More...
 
virtual void Delete (Option_t *option="")
 clear out the content of the collection More...
 
virtual Int_t GetEntries () const
 return the number of entries of this collection More...
 
virtual TObject ** GetObjectRef (const TObject *meta) const
 return pointer to pointer of object meta More...
 
virtual TIterator * MakeIterator (Bool_t dir=kIterForward) const
 make a new iterator for this collection More...
 
virtual TObject * Remove (TObject *meta)
 remove the given object from the list More...
 

Private Member Functions

 ClassDef (MetaObject, 1)
 

Private Attributes

TList * m_dataList
 the actual meta-data list More...
 

Related Functions

(Note that these are not member functions.)

std::string dbg (const MetaObject &obj, unsigned verbosity=0)
 the debugging info of this object More...
 
void swap (MetaObject &a, MetaObject &b)
 standard swap More...
 

Detailed Description

A class that manages meta-data to be associated with an object.

Originally this was just to be used for meta-data of a sample, but it is now also used for specifying the options for an EventLoop job.

Definition at line 55 of file MetaObject.h.

Member Enumeration Documentation

◆ CastMode

the different modes for casts

Enumerator
CAST_ERROR_THROW 

cast and throw if the cast fails (not if the input is not found)

CAST_ERROR_DEFAULT 

cast and return the default value if the cast fails

CAST_NOCAST_THROW 

do not cast and throw if the input has the wrong type (not if the input is not found)

CAST_NOCAST_DEFAULT 

cast and return the default value if the input has the wrong type

Definition at line 63 of file MetaObject.h.

64  {
68 
71 
75 
79  };

Constructor & Destructor Documentation

◆ MetaObject() [1/2]

SH::MetaObject::MetaObject ( )

standard constructor

Guarantee
strong
Failures
out of memory I

◆ MetaObject() [2/2]

SH::MetaObject::MetaObject ( const MetaObject that)

standard copy constructor

Guarantee
strong
Failures
out of memory II

◆ ~MetaObject()

virtual SH::MetaObject::~MetaObject ( )
virtual

standard destructor

Guarantee
no-fail

Member Function Documentation

◆ Add()

virtual void SH::MetaObject::Add ( TObject *  meta_swallow)
virtual

add another object to the collection

Precondition
meta_swallow != 0
Guarantee
basic, argument is always swallowed
Failures
out of memory II

◆ addReplace()

void SH::MetaObject::addReplace ( TNamed *  meta_swallow)

add a meta-data object and remove any existing meta-data with the same name

Parameters
meta_swallowthe meta-object to add
Precondition
meta_swallow != 0
Guarantee
basic, may delete some entries without adding the new one
Failures
out of memory II

◆ castBool()

bool SH::MetaObject::castBool ( const std::string &  name,
bool  def_val = false,
CastMode  mode = CAST_ERROR_THROW 
) const

the meta-data boolean with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail

◆ castDouble()

double SH::MetaObject::castDouble ( const std::string &  name,
double  def_val = 0,
CastMode  mode = CAST_ERROR_THROW 
) const

the meta-data double with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail

◆ castInteger()

int SH::MetaObject::castInteger ( const std::string &  name,
int  def_val = 0,
CastMode  mode = CAST_ERROR_THROW 
) const

the meta-data integer with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail

◆ castString()

std::string SH::MetaObject::castString ( const std::string &  name,
const std::string &  def_val = "",
CastMode  mode = CAST_ERROR_THROW 
) const

the meta-data string with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail
Rationale
I return the string by value, because returning by reference seems to break the python binding.

◆ castT()

template<class T >
T SH::MetaObject::castT ( const std::string &  name,
def_val,
CastMode  mode 
) const

the meta-data element with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail

◆ ClassDef()

SH::MetaObject::ClassDef ( MetaObject  ,
 
)
private

◆ Clear()

virtual void SH::MetaObject::Clear ( Option_t *  option = "")
virtual

clear out the content of the collection

Guarantee
no-fail

◆ Delete()

virtual void SH::MetaObject::Delete ( Option_t *  option = "")
virtual

clear out the content of the collection

Guarantee
no-fail

◆ dumpToString()

std::string SH::MetaObject::dumpToString ( )

dump the meta-data to a string

string will be suitable for fetchFromString

Guarantee
strong
Failues
no-fail

◆ fetch()

void SH::MetaObject::fetch ( const MetaObject source)

fetch the meta-data from the given sample.

fields that have a name that starts with "nc_" are not copied.

Guarantee
basic, may only fetch some meta-data
Failures
out of memory II
Rationale this is used by EventLoop, to copy the
meta-data from the input samples to the output samples. the prefix "nc_" is used to indicate meta-data entries that only apply to the current sample, or are options to the specific EventLoop job.

◆ fetchDefaults()

void SH::MetaObject::fetchDefaults ( const MetaObject source)

fetch the meta-data from the given sample not present in this sample.

ignores any meta-data without name.

Guarantee
basic, may only fetch some meta-data
Failures
out of memory II

◆ fetchFromString()

void SH::MetaObject::fetchFromString ( const std::string &  source)

fetch the meta-data from a given string

individual pieces of data may be given as key=value, key='value', key="value" spurious spaces will be ignored, commas inside values are not allowed

Guarantee
weak, may throw runtime exceptions if string cannot be parsed
Failures
malformed input

◆ get() [1/2]

TObject* SH::MetaObject::get ( const std::string &  name)

the meta-data object with the given name

Returns
the meta-data object with the given name, or NULL if there is no such entry
Parameters
namethe name of the meta-data object
Guarantee
no-fail

◆ get() [2/2]

const TObject* SH::MetaObject::get ( const std::string &  name) const

◆ getDouble()

double SH::MetaObject::getDouble ( const std::string &  name,
double  def_val = 0 
) const

the meta-data double with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail

◆ GetEntries()

virtual Int_t SH::MetaObject::GetEntries ( ) const
virtual

return the number of entries of this collection

Guarantee
no-fail

◆ GetObjectRef()

virtual TObject** SH::MetaObject::GetObjectRef ( const TObject *  meta) const
virtual

return pointer to pointer of object meta

Precondition
meta != 0
Postcondition
result != 0
*result == meta
Guarantee
strong
Failures
meta not in collection

◆ getString()

std::string SH::MetaObject::getString ( const std::string &  name,
const std::string &  def_val = "" 
) const

the meta-data string with the given name

Returns
the meta-data with the given name, or def_value if that meta-data is not available or does not have the right type
Parameters
namethe name of the meta-data object
dev_valthe value to return if no meta-data object of the given name exists, or if it does not have the right type
Guarantee
no-fail
Rationale
I return the string by value, because returning by reference seems to break the python binding.

◆ MakeIterator()

virtual TIterator* SH::MetaObject::MakeIterator ( Bool_t  dir = kIterForward) const
virtual

make a new iterator for this collection

Postcondition
result != 0
Guarantee
strong
Failures
out of memory I

◆ operator=()

MetaObject& SH::MetaObject::operator= ( const MetaObject that)

standard assignment operator

Returns
*this
Guarantee
strong
Failures
out of memory II

◆ remove()

void SH::MetaObject::remove ( const std::string &  name)

remove all meta-information with the given name

Parameters
namethe meta-data name to remove
Guarantee
basic, may only delete some entries
Failures
out of memory II

◆ Remove()

virtual TObject* SH::MetaObject::Remove ( TObject *  meta)
virtual

remove the given object from the list

Precondition
meta != 0
Guarantee
strong
Failures
meta not in list

◆ setBool()

void SH::MetaObject::setBool ( const std::string &  name,
bool  value 
)

set the meta-data boolean with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

◆ setDouble()

void SH::MetaObject::setDouble ( const std::string &  name,
double  value 
)

set the meta-data double with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

◆ setInteger()

void SH::MetaObject::setInteger ( const std::string &  name,
int  value 
)

set the meta-data integer with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

◆ setString()

void SH::MetaObject::setString ( const std::string &  name,
const std::string &  value 
)

set the meta-data string with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

◆ setT()

template<class T >
void SH::MetaObject::setT ( const std::string &  name,
value 
)
inline

set the meta-data element with the given name

Parameters
namethe name of the meta-data
valuethe value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II

Definition at line 339 of file MetaObject.h.

339  {
340  RCU_CHANGE_INVARIANT (this);
341  addReplace (new MetaData<T> (name, value));
342  }

◆ swap()

void SH::MetaObject::swap ( MetaObject that)

standard swap

Guarantee
no-fail

◆ testInvariant()

void SH::MetaObject::testInvariant ( ) const

test the invariant of this object

Guarantee
no-fail

Friends And Related Function Documentation

◆ dbg()

std::string dbg ( const MetaObject obj,
unsigned  verbosity = 0 
)
related

the debugging info of this object

Returns
a string representation of the object content
Parameters
objthe object to be presented
verbositythe level of verbosity (higher number -> more information)
Guarantee
strong
Failures
out of memory II

◆ swap()

void swap ( MetaObject a,
MetaObject b 
)
related

standard swap

Guarantee
no-fail

Member Data Documentation

◆ m_dataList

TList* SH::MetaObject::m_dataList
private

the actual meta-data list

Definition at line 477 of file MetaObject.h.


The documentation for this class was generated from the following file:
SH::MetaObject::CAST_ERROR_DEFAULT
@ CAST_ERROR_DEFAULT
cast and return the default value if the cast fails
Definition: MetaObject.h:70
SH::MetaObject::CAST_NOCAST_DEFAULT
@ CAST_NOCAST_DEFAULT
cast and return the default value if the input has the wrong type
Definition: MetaObject.h:78
SH::MetaObject::CAST_ERROR_THROW
@ CAST_ERROR_THROW
cast and throw if the cast fails (not if the input is not found)
Definition: MetaObject.h:67
athena.value
value
Definition: athena.py:124
SH::MetaObject::CAST_NOCAST_THROW
@ CAST_NOCAST_THROW
do not cast and throw if the input has the wrong type (not if the input is not found)
Definition: MetaObject.h:74
SH::MetaObject::addReplace
void addReplace(TNamed *meta_swallow)
add a meta-data object and remove any existing meta-data with the same name
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231