ATLAS Offline Software
|
D3PD variable metadata handling class. More...
#include <ObjectMetadata.h>
Classes | |
class | Variable |
Internal class keeping track of a single variable. More... | |
Public Member Functions | |
ObjectMetadata () | |
Default constructor. More... | |
ObjectMetadata (const ObjectMetadata &parent) | |
Copy constructor. More... | |
ObjectMetadata & | operator= (const ObjectMetadata &parent) |
Assignment operator. More... | |
bool | operator== (const ObjectMetadata &rhs) const |
Equality operator. More... | |
bool | operator< (const ObjectMetadata &rhs) const |
Operator needed to use such objects in ordered STL containers. More... | |
virtual StatusCode | addVariable (const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0) |
This function can be used to save the metadata about a D3PD variable. More... | |
virtual StatusCode | addDimensionedVariable (const std::string &name, const std::type_info &ti, void *&ptr, const std::string &dim, const std::string &docstring="", const void *defval=0) |
The object doesn't support dimensioned variables at the moment, like most of the D3PDMaker code doesn't. More... | |
const std::string & | name () const |
Get the name of the D3PDObject that this object describes. More... | |
void | setName (const std::string &name) |
Set the name of the D3PDObject that this object describes. More... | |
std::string metadataName | ATLAS_NOT_THREAD_SAFE () const |
Get the name for the metadata object that should be created. More... | |
const std::string & | prefix () const |
Get the prefix given to variables in this D3PDObject. More... | |
void | setPrefix (const std::string &prefix) |
Set the prefix given to variables in this D3PDObject. More... | |
bool | container () const |
Get whether the D3PDObject describes a container or not. More... | |
void | setContainer (bool container) |
Set whether the D3PDObject describes a container or not. More... | |
std::string | toString () const |
Function "serializing" the stored information into a string. More... | |
StatusCode | read (const std::string &data) |
Function "de-serializing" the stored information from a string. More... | |
void | clear () |
Function clearing the object. More... | |
ObjectMetadata & | operator+= (const ObjectMetadata &obj) |
Operator merging the contents of two objects. More... | |
ObjectMetadata & | merge (const ObjectMetadata &obj) |
Function merging the contents of two objects. More... | |
const std::set< Variable > & | variables () const |
Function for accessing all the variables of the D3PDObject. More... | |
template<class T > | |
StatusCode | addVariable (const std::string &name, T *&ptr, const std::string &docstring="") |
Make the template implementation from IAddVariable visible. More... | |
template<class T , class U > | |
StatusCode | addVariable (const std::string &name, T *&ptr, const std::string &docstring, const U &defval) |
Make the template implementation from IAddVariable visible. More... | |
virtual StatusCode | addVariable (const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)=0 |
Make the template implementation from IAddVariable visible. More... | |
template<class T > | |
StatusCode | addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring="") |
Add a variable to the tuple. More... | |
template<class T , class U > | |
StatusCode | addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring, const U &defval) |
Add a variable to the tuple. More... | |
virtual StatusCode | addDimensionedVariable (const std::string &name, const std::type_info &ti, void *&ptr, const std::string &dim, const std::string &docstring="", const void *defval=0)=0 |
Add a variable to the tuple. More... | |
template<class T > | |
StatusCode | addVariable (const std::string &name, T *&ptr, const std::string &docstring="") |
Add a variable to the tuple. More... | |
template<class T , class U > | |
StatusCode | addVariable (const std::string &name, T *&ptr, const std::string &docstring, const U &defval) |
Add a variable to the tuple. More... | |
template<class T > | |
StatusCode | addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring="") |
Add a variable to the tuple. More... | |
template<class T , class U > | |
StatusCode | addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring, const U &defval) |
Add a variable to the tuple. More... | |
Static Public Member Functions | |
static std::string | objectName (const std::string &metaName) |
Get the D3PDObject's name from the name of the metadata object. More... | |
Static Public Attributes | |
static const size_t | RANDOM_NAME_POSTFIX_LENGTH = 6 |
Length of the random string appended to the object name. More... | |
static const char *const | STRING_SEPARATOR = "@" |
Character separating parts of the object's metadata. More... | |
static const unsigned int | SERIALIZER_VERSION = 1 |
"Version number" of the serialized information More... | |
Protected Attributes | |
std::set< Variable > | m_variables |
The list of variables created by a D3PDObject. More... | |
std::string | m_name |
Name of the D3PDObject that this object describes. More... | |
std::string | m_prefix |
Prefix used by the D3PDObject. More... | |
bool | m_container |
The D3PDObject describes a container. More... | |
Static Private Member Functions | |
static std::string genSuffix | ATLAS_NOT_THREAD_SAFE (const std::string &name, size_t length) |
Generate a unique suffix for a metadata object name. More... | |
D3PD variable metadata handling class.
This class is used to store information in D3PD files about the variables that were created using a single D3PDObject in the job. The created metadata can be used to create D3PDReader classes later on, independent of the storage technology and the language used.
Definition at line 36 of file ObjectMetadata.h.
D3PD::ObjectMetadata::ObjectMetadata | ( | ) |
Default constructor.
Definition at line 61 of file ObjectMetadata.cxx.
D3PD::ObjectMetadata::ObjectMetadata | ( | const ObjectMetadata & | parent | ) |
|
virtual |
The object doesn't support dimensioned variables at the moment, like most of the D3PDMaker code doesn't.
Still, we might implement something like this later on.
Implements D3PD::IAddVariable.
Definition at line 157 of file ObjectMetadata.cxx.
virtual StatusCode D3PD::IAddVariable::addDimensionedVariable |
Add a variable to the tuple.
name | The name of the variable. |
type | The type of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
dim | Dimension for the variable. (Presently unimplemented!) |
docstring | Documentation string for this variable. |
defval | Pointer to the default value to use for this variable. Null for no default (generally means to fill with zeros). Of the type given by ti . Only works for basic types. |
If called from the constructor, the only effect is to clear ptr
.
StatusCode D3PD::IAddVariable::addDimensionedVariable | ( | class T | , |
class U | |||
) |
Add a variable to the tuple.
name | The name of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
dim | Dimension for the variable. (Presently unimplemented!) |
docstring | Documentation string for this variable. |
defval | Pointer to the default value to use for this variable. Only works for basic types. |
If called from the constructor, the only effect is to clear ptr
.
|
inherited |
Add a variable to the tuple.
name | The name of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
dim | Dimension for the variable. (Presently unimplemented!) |
docstring | Documentation string for this variable. |
defval | Pointer to the default value to use for this variable. Only works for basic types. |
If called from the constructor, the only effect is to clear ptr
.
StatusCode D3PD::IAddVariable::addDimensionedVariable | ( | class T | ) |
Add a variable to the tuple.
name | The name of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
dim | Dimension for the variable. (Presently unimplemented!) |
docstring | Documentation string for this variable. |
If called from the constructor, the only effect is to clear ptr
.
|
inherited |
Add a variable to the tuple.
name | The name of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
dim | Dimension for the variable. (Presently unimplemented!) |
docstring | Documentation string for this variable. |
If called from the constructor, the only effect is to clear ptr
.
|
virtual |
This function can be used to save the metadata about a D3PD variable.
Note that this class doesn't implement the full might of an ID3PD object, so no new object is created as a result of this function call. This means that it should always be followed by calling the addVariable(...) function of a proper IAddVariable object.
Implements D3PD::IAddVariable.
Definition at line 109 of file ObjectMetadata.cxx.
virtual StatusCode D3PD::IAddVariable::addVariable |
Make the template implementation from IAddVariable
visible.
StatusCode D3PD::IAddVariable::addVariable | ( | class T | , |
class U | |||
) |
Make the template implementation from IAddVariable
visible.
|
inherited |
Add a variable to the tuple.
name | The name of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
docstring | Documentation string for this variable. |
defval | Pointer to the default value to use for this variable. Only works for basic types. |
If called from the constructor, the only effect is to clear ptr
.
StatusCode D3PD::IAddVariable::addVariable | ( | class T | ) |
Make the template implementation from IAddVariable
visible.
|
inherited |
Add a variable to the tuple.
name | The name of the variable. |
ptr | Pointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill() . |
docstring | Documentation string for this variable. |
If called from the constructor, the only effect is to clear ptr
.
std::string metadataName D3PD::ObjectMetadata::ATLAS_NOT_THREAD_SAFE | ( | ) | const |
Get the name for the metadata object that should be created.
|
staticprivate |
Generate a unique suffix for a metadata object name.
name | The metadata object name. |
length | The length of the suffix to add. |
We used to do this by generating a random string. However, this is very bad for regression testing, as adding or removing one variable can then change the names of all subsequent variables. Instead, we generate the suffix based on a count of the number of times we've seen a particular name.
void D3PD::ObjectMetadata::clear | ( | ) |
bool D3PD::ObjectMetadata::container | ( | ) | const |
Get whether the D3PDObject describes a container or not.
Definition at line 230 of file ObjectMetadata.cxx.
ObjectMetadata & D3PD::ObjectMetadata::merge | ( | const ObjectMetadata & | obj | ) |
Function merging the contents of two objects.
This merging function was implemented in the anticipation that it might come in handy later on.
But no guarantees...
obj | The object that should be merged with this one |
Definition at line 375 of file ObjectMetadata.cxx.
const std::string & D3PD::ObjectMetadata::name | ( | ) | const |
Get the name of the D3PDObject that this object describes.
Definition at line 170 of file ObjectMetadata.cxx.
|
static |
Get the D3PDObject's name from the name of the metadata object.
This function should be used by the client code to "decode" the name of the original D3PDObject from the name of the metadata object.
This way the client code doesn't have to know how this class works internally.
metaName | The name of the metadata object in the D3PD file |
Definition at line 213 of file ObjectMetadata.cxx.
ObjectMetadata & D3PD::ObjectMetadata::operator+= | ( | const ObjectMetadata & | obj | ) |
Operator merging the contents of two objects.
Definition at line 363 of file ObjectMetadata.cxx.
bool D3PD::ObjectMetadata::operator< | ( | const ObjectMetadata & | rhs | ) | const |
Operator needed to use such objects in ordered STL containers.
Definition at line 91 of file ObjectMetadata.cxx.
ObjectMetadata & D3PD::ObjectMetadata::operator= | ( | const ObjectMetadata & | parent | ) |
bool D3PD::ObjectMetadata::operator== | ( | const ObjectMetadata & | rhs | ) | const |
Equality operator.
Definition at line 85 of file ObjectMetadata.cxx.
const std::string & D3PD::ObjectMetadata::prefix | ( | ) | const |
Get the prefix given to variables in this D3PDObject.
Definition at line 219 of file ObjectMetadata.cxx.
StatusCode D3PD::ObjectMetadata::read | ( | const std::string & | data | ) |
Function "de-serializing" the stored information from a string.
This function can be used to read in information from a serialized form.
Note that the function doesn't clear the contents of the object. So it can be used to merge information from multiple metadata objects / files.
data | The string that should be decoded |
StatusCode::SUCCESS
if the operation was successful, StatusCode::FAILURE
otherwise Definition at line 276 of file ObjectMetadata.cxx.
void D3PD::ObjectMetadata::setContainer | ( | bool | container | ) |
Set whether the D3PDObject describes a container or not.
Definition at line 235 of file ObjectMetadata.cxx.
void D3PD::ObjectMetadata::setName | ( | const std::string & | name | ) |
Set the name of the D3PDObject that this object describes.
Definition at line 175 of file ObjectMetadata.cxx.
void D3PD::ObjectMetadata::setPrefix | ( | const std::string & | prefix | ) |
Set the prefix given to variables in this D3PDObject.
Definition at line 224 of file ObjectMetadata.cxx.
std::string D3PD::ObjectMetadata::toString | ( | ) | const |
Function "serializing" the stored information into a string.
This function translates the contents of the entire object into a single string.
The different parts of the configuration string are separated by "@" character. (So variable names and variable descriptions can't have this character in them.)
Definition at line 249 of file ObjectMetadata.cxx.
const std::set< ObjectMetadata::Variable > & D3PD::ObjectMetadata::variables | ( | ) | const |
Function for accessing all the variables of the D3PDObject.
Definition at line 577 of file ObjectMetadata.cxx.
|
protected |
The D3PDObject describes a container.
Definition at line 175 of file ObjectMetadata.h.
|
protected |
Name of the D3PDObject that this object describes.
Definition at line 173 of file ObjectMetadata.h.
|
protected |
Prefix used by the D3PDObject.
Definition at line 174 of file ObjectMetadata.h.
|
protected |
The list of variables created by a D3PDObject.
Definition at line 172 of file ObjectMetadata.h.
|
static |
Length of the random string appended to the object name.
Definition at line 109 of file ObjectMetadata.h.
|
static |
"Version number" of the serialized information
While I don't plan to change this class any time soon, we should be able to clearly decide later on if the format of the metadata serialization changed, which version was used to write the metadata found in a given file.
Definition at line 119 of file ObjectMetadata.h.
Character separating parts of the object's metadata.
Definition at line 111 of file ObjectMetadata.h.