SH::MetaObject Class Reference

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

#include <MetaObject.h>

List of all members.

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

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.


Member Enumeration Documentation

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


Constructor & Destructor Documentation

SH::MetaObject::MetaObject (  ) 

standard constructor

Guarantee
strong
Failures
out of memory I
SH::MetaObject::MetaObject ( const MetaObject that  ) 

standard copy constructor

Guarantee
strong
Failures
out of memory II
virtual SH::MetaObject::~MetaObject (  )  [virtual]

standard destructor

Guarantee
no-fail

Member Function Documentation

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
void SH::MetaObject::addReplace ( TNamed *  meta_swallow  ) 

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

Parameters:
meta_swallow the meta-object to add
Precondition:
meta_swallow != 0
Guarantee
basic, may delete some entries without adding the new one
Failures
out of memory II
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:
name the name of the meta-data object
dev_val the 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
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:
name the name of the meta-data object
dev_val the 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
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:
name the name of the meta-data object
dev_val the 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
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:
name the name of the meta-data object
dev_val the 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.
template<class T >
T SH::MetaObject::castT ( const std::string &  name,
T  def_val,
CastMode  mode 
) const [inline]

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:
name the name of the meta-data object
dev_val the 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
virtual void SH::MetaObject::Clear ( Option_t *  option = ""  )  [virtual]

clear out the content of the collection

Guarantee
no-fail
virtual void SH::MetaObject::Delete ( Option_t *  option = ""  )  [virtual]

clear out the content of the collection

Guarantee
no-fail
std::string SH::MetaObject::dumpToString (  ) 

dump the meta-data to a string

string will be suitable for fetchFromString

Guarantee
strong
Failues
no-fail
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.
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
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
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:
name the name of the meta-data object
Guarantee
no-fail
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:
name the name of the meta-data object
dev_val the 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
virtual Int_t SH::MetaObject::GetEntries (  )  const [virtual]

return the number of entries of this collection

Guarantee
no-fail
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
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:
name the name of the meta-data object
dev_val the 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.
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
MetaObject& SH::MetaObject::operator= ( const MetaObject that  ) 

standard assignment operator

Returns
this
Guarantee
strong
Failures
out of memory II
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
void SH::MetaObject::remove ( const std::string &  name  ) 

remove all meta-information with the given name

Parameters:
name the meta-data name to remove
Guarantee
basic, may only delete some entries
Failures
out of memory II
void SH::MetaObject::setBool ( const std::string &  name,
bool  value 
)

set the meta-data boolean with the given name

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II
void SH::MetaObject::setDouble ( const std::string &  name,
double  value 
)

set the meta-data double with the given name

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II
void SH::MetaObject::setInteger ( const std::string &  name,
int  value 
)

set the meta-data integer with the given name

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II
void SH::MetaObject::setString ( const std::string &  name,
const std::string &  value 
)

set the meta-data string with the given name

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II
template<class T >
void SH::MetaObject::setT ( const std::string &  name,
T  value 
) [inline]

set the meta-data element with the given name

Parameters:
name the name of the meta-data
value the value to which it is set
Guarantee
basic, may clear old entry without adding new one
Failures
out of memory II
void SH::MetaObject::swap ( MetaObject that  ) 

standard swap

Guarantee
no-fail
void SH::MetaObject::testInvariant (  )  const

test the invariant of this object

Guarantee
no-fail

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 15 Apr 2017 for RootCore Packages by  doxygen 1.6.1