ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
D3PD::RootObjectMetadata Class Reference

Extension of the ObjectMetadata class for reading D3PD files. More...

#include <RootObjectMetadata.h>

Inheritance diagram for D3PD::RootObjectMetadata:
Collaboration diagram for D3PD::RootObjectMetadata:

Public Member Functions

 RootObjectMetadata ()
 Default constructor. More...
 
 RootObjectMetadata (const RootObjectMetadata &parent)
 Copy constructor. More...
 
StatusCode addVariable (const std::string &name, const std::string &type, const std::string &docstring)
 Function adding a variable, when the exact type_info is not available. More...
 
StatusCode checkPrefixes ()
 Remove possibly overlooked prefixes in the variable names. More...
 
virtual StatusCode addVariable (const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
 Make the implementation from ObjectMetadata visible. 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...
 
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...
 
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...
 
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...
 
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 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...
 
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...
 
ObjectMetadataoperator+= (const ObjectMetadata &obj)
 Operator merging the contents of two objects. More...
 
ObjectMetadatamerge (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...
 

Static Public Member Functions

static bool isObjectMetadata (const std::string &name)
 Function guessing if an object with a given name is object metadata. More...
 
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< Variablem_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...
 

Private Member Functions

RootObjectMetadataoperator= (const RootObjectMetadata &)
 

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...
 

Detailed Description

Extension of the ObjectMetadata class for reading D3PD files.

   The base D3PD::ObjectMetadata class needs to get some extra
   features for interpreting the metadata found in D3PD ROOT files
   correctly. Instead of putting all the frunctionality into the
   base class, it is only put here.
Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
530460
Date
2012-12-13 19:27:24 +0100 (Thu, 13 Dec 2012)

Definition at line 32 of file RootObjectMetadata.h.

Constructor & Destructor Documentation

◆ RootObjectMetadata() [1/2]

D3PD::RootObjectMetadata::RootObjectMetadata ( )

Default constructor.

Definition at line 20 of file RootObjectMetadata.cxx.

21  : ObjectMetadata() {
22 
23  }

◆ RootObjectMetadata() [2/2]

D3PD::RootObjectMetadata::RootObjectMetadata ( const RootObjectMetadata parent)

Copy constructor.

Definition at line 25 of file RootObjectMetadata.cxx.

26  : ObjectMetadata( parent ) {
27 
28  }

Member Function Documentation

◆ addDimensionedVariable() [1/6]

StatusCode D3PD::ObjectMetadata::addDimensionedVariable ( const std::string &  name,
const std::type_info &  ti,
void *&  ptr,
const std::string &  dim,
const std::string &  docstring = "",
const void *  defval = 0 
)
virtualinherited

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.

162  {
163 
164  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata" )
165  << "addDimensionedVariable(...) not implemented";
166 
167  return StatusCode::FAILURE;
168  }

◆ addDimensionedVariable() [2/6]

virtual StatusCode D3PD::IAddVariable::addDimensionedVariable
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
typeThe type of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer 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.

◆ addDimensionedVariable() [3/6]

template<class T , class U >
StatusCode D3PD::IAddVariable::addDimensionedVariable ( class T  ,
class U   
)
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer 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.

◆ addDimensionedVariable() [4/6]

template<class T , class U >
StatusCode D3PD::IAddVariable::addDimensionedVariable ( const std::string &  name,
T *&  ptr,
const std::string &  dim,
const std::string &  docstring,
const U &  defval 
)
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer 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.

◆ addDimensionedVariable() [5/6]

template<class T >
StatusCode D3PD::IAddVariable::addDimensionedVariable ( class T  )
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.

If called from the constructor, the only effect is to clear ptr.

◆ addDimensionedVariable() [6/6]

template<class T >
StatusCode D3PD::IAddVariable::addDimensionedVariable ( const std::string &  name,
T *&  ptr,
const std::string &  dim,
const std::string &  docstring = "" 
)
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.

If called from the constructor, the only effect is to clear ptr.

◆ addVariable() [1/7]

StatusCode D3PD::RootObjectMetadata::addVariable ( const std::string &  name,
const std::string &  type,
const std::string &  docstring 
)

Function adding a variable, when the exact type_info is not available.

Definition at line 30 of file RootObjectMetadata.cxx.

32  {
33 
34  // Check that the variable has the correct prefix:
35  if( ( m_prefix != "" ) &&
36  ( name.find( m_prefix ) != 0 ) ) {
37  REPORT_MESSAGE_WITH_CONTEXT( MSG::ERROR, "RootObjectMetadata" )
38  << "Specified variable name (" << name << ") doesn't have the "
39  << "expected prefix (" << m_prefix << ")";
40  return StatusCode::RECOVERABLE;
41  }
42 
43  // Create a new variable:
44  Variable var;
45 
46  // Remove the prefix from the variable name:
47  var.setName( name.substr( m_prefix.size(), name.npos ) );
48 
49  // Check if it's already amongst the existing variables:
50  if( m_variables.find( var ) != m_variables.end() ) {
51  return StatusCode::SUCCESS;
52  }
53 
54  // Set the type of the variable:
55  var.setType( type );
56 
57  // Set whether the variable is a primitive:
58  var.setPrimitive( isPrimitive( type ) );
59 
60  // Set the documentation string for the variable:
61  var.setDoc( docstring );
62 
63  // Remember the variable:
64  m_variables.insert( var );
65 
66  return StatusCode::SUCCESS;
67  }

◆ addVariable() [2/7]

StatusCode D3PD::ObjectMetadata::addVariable

Make the implementation from ObjectMetadata visible.

Definition at line 59 of file ObjectMetadata.cxx.

113  {
114 
115  // Check that the variable has the correct prefix:
116  if( m_prefix != "" &&
117  !name.starts_with( m_prefix) )
118  {
119  REPORT_MESSAGE_WITH_CONTEXT( MSG::ERROR, "ObjectMetadata" )
120  << "Specified variable name (" << name << ") doesn't have the "
121  << "expected prefix (" << m_prefix << ")";
122  return StatusCode::RECOVERABLE;
123  }
124 
125  // Create a new variable:
126  Variable var;
127 
128  // Remove the prefix from the variable name:
129  var.setName( name.substr( m_prefix.size(), name.npos ) );
130 
131  // Check if it's already amongst the existing variables:
132  if( m_variables.find( var ) != m_variables.end() ) {
133  return StatusCode::SUCCESS;
134  }
135 
136  // Set the type of the variable:
137  var.setType( System::typeinfoName( ti.name() ) );
138 
139  // Set whether the variable is a primitive:
140  var.setPrimitive( isPrimitive( ti ) );
141 
142  // Set the documentation string for the variable:
143  var.setDoc( docstring );
144 
145  // Remember the variable:
146  m_variables.insert( var );
147 
148  return StatusCode::SUCCESS;
149  }

◆ addVariable() [3/7]

StatusCode D3PD::ObjectMetadata::addVariable ( const std::string &  name,
const std::type_info &  ti,
void *&  ptr,
const std::string &  docstring = "",
const void *  defval = 0 
)
virtualinherited

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.

113  {
114 
115  // Check that the variable has the correct prefix:
116  if( m_prefix != "" &&
117  !name.starts_with( m_prefix) )
118  {
119  REPORT_MESSAGE_WITH_CONTEXT( MSG::ERROR, "ObjectMetadata" )
120  << "Specified variable name (" << name << ") doesn't have the "
121  << "expected prefix (" << m_prefix << ")";
122  return StatusCode::RECOVERABLE;
123  }
124 
125  // Create a new variable:
126  Variable var;
127 
128  // Remove the prefix from the variable name:
129  var.setName( name.substr( m_prefix.size(), name.npos ) );
130 
131  // Check if it's already amongst the existing variables:
132  if( m_variables.find( var ) != m_variables.end() ) {
133  return StatusCode::SUCCESS;
134  }
135 
136  // Set the type of the variable:
137  var.setType( System::typeinfoName( ti.name() ) );
138 
139  // Set whether the variable is a primitive:
140  var.setPrimitive( isPrimitive( ti ) );
141 
142  // Set the documentation string for the variable:
143  var.setDoc( docstring );
144 
145  // Remember the variable:
146  m_variables.insert( var );
147 
148  return StatusCode::SUCCESS;
149  }

◆ addVariable() [4/7]

template<class T , class U >
StatusCode D3PD::IAddVariable::addVariable ( class T  ,
class U   
)
inherited

Make the template implementation from IAddVariable visible.

◆ addVariable() [5/7]

template<class T , class U >
StatusCode D3PD::IAddVariable::addVariable ( const std::string &  name,
T *&  ptr,
const std::string &  docstring,
const U &  defval 
)
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
docstringDocumentation string for this variable.
defvalPointer 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.

◆ addVariable() [6/7]

template<class T >
StatusCode D3PD::IAddVariable::addVariable ( class T  )
inherited

Make the template implementation from IAddVariable visible.

◆ addVariable() [7/7]

template<class T >
StatusCode D3PD::IAddVariable::addVariable ( const std::string &  name,
T *&  ptr,
const std::string &  docstring = "" 
)
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
docstringDocumentation string for this variable.

If called from the constructor, the only effect is to clear ptr.

◆ ATLAS_NOT_THREAD_SAFE() [1/2]

std::string metadataName D3PD::ObjectMetadata::ATLAS_NOT_THREAD_SAFE ( ) const
inherited

Get the name for the metadata object that should be created.

◆ ATLAS_NOT_THREAD_SAFE() [2/2]

static std::string genSuffix D3PD::ObjectMetadata::ATLAS_NOT_THREAD_SAFE ( const std::string &  name,
size_t  length 
)
staticprivateinherited

Generate a unique suffix for a metadata object name.

Parameters
nameThe metadata object name.
lengthThe 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.

◆ checkPrefixes()

StatusCode D3PD::RootObjectMetadata::checkPrefixes ( )

Remove possibly overlooked prefixes in the variable names.

By mistake some of the variable names in the D3PDs produced by AtlasPhysics-17.0.5.5.2 did not get their prefix removed when they were saved into the metadata.

(Still need to investigate why.)

This function remedies this by fixing the variable names manually.

Returns
StatusCode::SUCCESS if everything went fine

Definition at line 78 of file RootObjectMetadata.cxx.

78  {
79 
80  // For simplicity's sake I don't modify the original std::set,
81  // but create a new one instead. This is slightly slower, but
82  // much easier. In any case, performance is not a major concern
83  // in this code...
84  std::set< Variable > newVariables;
85 
86  // Loop over the variables:
87  std::set< Variable >::const_iterator itr = m_variables.begin();
88  std::set< Variable >::const_iterator end = m_variables.end();
89  for( ; itr != end; ++itr ) {
90 
91  // Check if the variable name begins with the prefix (it shouldn't):
92  if( ( m_prefix != "" ) &&
93  ( itr->name().find( m_prefix ) == 0 ) ) {
94  // Create a copy of the variable, and remove the prefix from its name:
95  Variable var = *itr;
96  var.setName( var.name().substr( m_prefix.size(), var.name().npos ) );
97  // Insert it into the new container:
98  newVariables.insert( var );
99  } else {
100  // Insert the variable as it is into the new container:
101  newVariables.insert( *itr );
102  }
103  }
104 
105  // Swap the two containers. (This should be a fairly quick operation...)
106  m_variables.swap( newVariables );
107 
108  return StatusCode::SUCCESS;
109  }

◆ clear()

void D3PD::ObjectMetadata::clear ( )
inherited

Function clearing the object.

Definition at line 352 of file ObjectMetadata.cxx.

352  {
353 
354  // Clear/reset all the variables:
355  m_variables.clear();
356  m_name = "";
357  m_prefix = "";
358  m_container = false;
359 
360  return;
361  }

◆ container()

bool D3PD::ObjectMetadata::container ( ) const
inherited

Get whether the D3PDObject describes a container or not.

Definition at line 230 of file ObjectMetadata.cxx.

230  {
231 
232  return m_container;
233  }

◆ isObjectMetadata()

bool D3PD::RootObjectMetadata::isObjectMetadata ( const std::string &  name)
static

Function guessing if an object with a given name is object metadata.

Metadata objects are saved with a name like "Something_XXXXXX".

This function makes a very simple check whether the name given to it follows this format.

Parameters
nameThe name of a metadata object
Returns
true if it appears to be an object metadata object

Definition at line 118 of file RootObjectMetadata.cxx.

118  {
119 
120  if( ( name.size() > ( RANDOM_NAME_POSTFIX_LENGTH + 1 ) ) &&
121  ( name[ name.size() - ( RANDOM_NAME_POSTFIX_LENGTH + 1 ) ] == '_' ) ) {
122  return true;
123  } else {
124  return false;
125  }
126  }

◆ merge()

ObjectMetadata & D3PD::ObjectMetadata::merge ( const ObjectMetadata obj)
inherited

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...

Parameters
objThe object that should be merged with this one
Returns
A reference to the current object

Definition at line 375 of file ObjectMetadata.cxx.

375  {
376 
377  // Only objects with the same "name" should be merged:
378  if( name() != obj.name() ) {
379  REPORT_MESSAGE_WITH_CONTEXT( MSG::WARNING, "ObjectMetadata" )
380  << "Can't merge object with name \"" << obj.name()
381  << "\" into another object with name \"" << name() << "\"";
382  return *this;
383  }
384 
385  // Now merge all the variable definitions:
386  std::set< Variable >::const_iterator itr = obj.variables().begin();
387  std::set< Variable >::const_iterator end = obj.variables().end();
388  for( ; itr != end; ++itr ) {
389  m_variables.insert( *itr );
390  }
391 
392  return *this;
393  }

◆ name()

const std::string & D3PD::ObjectMetadata::name ( ) const
inherited

Get the name of the D3PDObject that this object describes.

Definition at line 170 of file ObjectMetadata.cxx.

170  {
171 
172  return m_name;
173  }

◆ objectName()

std::string D3PD::ObjectMetadata::objectName ( const std::string &  metaName)
staticinherited

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.

Parameters
metaNameThe name of the metadata object in the D3PD file
Returns
The name of the original D3PDObject that the metadata object describes

Definition at line 213 of file ObjectMetadata.cxx.

213  {
214 
215  return metaName.substr( 0, metaName.size() -
216  ( RANDOM_NAME_POSTFIX_LENGTH + 1 ) );
217  }

◆ operator+=()

ObjectMetadata & D3PD::ObjectMetadata::operator+= ( const ObjectMetadata obj)
inherited

Operator merging the contents of two objects.

Definition at line 363 of file ObjectMetadata.cxx.

363  {
364 
365  return this->merge( obj );
366  }

◆ operator<()

bool D3PD::ObjectMetadata::operator< ( const ObjectMetadata rhs) const
inherited

Operator needed to use such objects in ordered STL containers.

Definition at line 91 of file ObjectMetadata.cxx.

91  {
92 
93  if( prefix() != rhs.prefix() ) {
94  return ( prefix() < rhs.prefix() );
95  } else if( name() != rhs.name() ) {
96  return ( name() < rhs.name() );
97  } else {
98  return ( container() < rhs.container() );
99  }
100  }

◆ operator=()

RootObjectMetadata& D3PD::RootObjectMetadata::operator= ( const RootObjectMetadata )
private

◆ operator==()

bool D3PD::ObjectMetadata::operator== ( const ObjectMetadata rhs) const
inherited

Equality operator.

Definition at line 85 of file ObjectMetadata.cxx.

85  {
86 
87  return ( ( name() == rhs.name() ) && ( prefix() == rhs.prefix() ) &&
88  ( container() == rhs.container() ) );
89  }

◆ prefix()

const std::string & D3PD::ObjectMetadata::prefix ( ) const
inherited

Get the prefix given to variables in this D3PDObject.

Definition at line 219 of file ObjectMetadata.cxx.

219  {
220 
221  return m_prefix;
222  }

◆ read()

StatusCode D3PD::ObjectMetadata::read ( const std::string &  data)
inherited

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.

Parameters
dataThe string that should be decoded
Returns
StatusCode::SUCCESS if the operation was successful, StatusCode::FAILURE otherwise

Definition at line 276 of file ObjectMetadata.cxx.

276  {
277 
278  //
279  // Tokenize the string using Boost:
280  //
281  boost::char_separator< char > separator( STRING_SEPARATOR, "",
282  boost::keep_empty_tokens );
283  boost::tokenizer< boost::char_separator< char > > tokens( data,
284  separator );
285  boost::tokenizer< boost::char_separator< char > >::const_iterator itr = tokens.begin();
286  boost::tokenizer< boost::char_separator< char > >::const_iterator end = tokens.end();
287 
288  // Check that we didn't reach the last token yet:
289  if( itr == end ) {
290  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata" )
291  << "The received data can not be parsed successfully: "
292  << data;
293  return StatusCode::FAILURE;
294  }
295 
296  // Check that the metadata was saved using the same version of the
297  // serializer code. Later on we might want to introduce backward
298  // compatibility, but for now this simple check should be enough.
299  if( atoi(itr->c_str()) != SERIALIZER_VERSION ) {
300  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata" )
301  << "Version mismatch! The metadata was saved with a different "
302  << "serialization version (" << *itr << ") than the code used ("
303  << SERIALIZER_VERSION << ")";
304  return StatusCode::FAILURE;
305  }
306 
307  ++itr;
308 
309  // Check that we didn't reach the last token yet:
310  if( itr == end ) {
311  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata" )
312  << "The received data can not be parsed successfully: "
313  << data;
314  return StatusCode::FAILURE;
315  }
316 
317  // Extract the prefix from the metadata:
318  m_prefix = *itr; ++itr;
319 
320  // Check that we didn't reach the last token yet:
321  if( itr == end ) {
322  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata" )
323  << "The received data can not be parsed successfully: "
324  << data;
325  return StatusCode::FAILURE;
326  }
327 
328  // Extract whether this is a container that the variables describe:
329  if( *itr == "0" ) {
330  m_container = false;
331  } else if( *itr == "1" ) {
332  m_container = true;
333  } else {
334  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata" )
335  << "The received data can not be parsed successfully: "
336  << data;
337  return StatusCode::FAILURE;
338  }
339 
340  ++itr;
341 
342  // Finally, let's extract all the variable metadata:
343  for( ; itr != end; ++itr ) {
344  Variable var;
345  CHECK( var.read( *itr ) );
346  m_variables.insert( var );
347  }
348 
349  return StatusCode::SUCCESS;
350  }

◆ setContainer()

void D3PD::ObjectMetadata::setContainer ( bool  container)
inherited

Set whether the D3PDObject describes a container or not.

Definition at line 235 of file ObjectMetadata.cxx.

235  {
236 
238  return;
239  }

◆ setName()

void D3PD::ObjectMetadata::setName ( const std::string &  name)
inherited

Set the name of the D3PDObject that this object describes.

Definition at line 175 of file ObjectMetadata.cxx.

175  {
176 
177  m_name = name;
178  return;
179  }

◆ setPrefix()

void D3PD::ObjectMetadata::setPrefix ( const std::string &  prefix)
inherited

Set the prefix given to variables in this D3PDObject.

Definition at line 224 of file ObjectMetadata.cxx.

224  {
225 
226  m_prefix = prefix;
227  return;
228  }

◆ toString()

std::string D3PD::ObjectMetadata::toString ( ) const
inherited

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.)

Returns
The configuration of this object "serialized" into a string

Definition at line 249 of file ObjectMetadata.cxx.

249  {
250 
251  // Save the simple part of the information
252  std::string result =
255  STRING_SEPARATOR + ( m_container ? "1" : "0" );
256 
257  // Save the serialized version of all the variables:
258  std::set< Variable >::const_iterator itr = m_variables.begin();
259  std::set< Variable >::const_iterator end = m_variables.end();
260  for( ; itr != end; ++itr ) {
261  result += STRING_SEPARATOR + itr->toString();
262  }
263 
264  return result;
265  }

◆ variables()

const std::set< ObjectMetadata::Variable > & D3PD::ObjectMetadata::variables ( ) const
inherited

Function for accessing all the variables of the D3PDObject.

Definition at line 577 of file ObjectMetadata.cxx.

577  {
578 
579  return m_variables;
580  }

Member Data Documentation

◆ m_container

bool D3PD::ObjectMetadata::m_container
protectedinherited

The D3PDObject describes a container.

Definition at line 175 of file ObjectMetadata.h.

◆ m_name

std::string D3PD::ObjectMetadata::m_name
protectedinherited

Name of the D3PDObject that this object describes.

Definition at line 173 of file ObjectMetadata.h.

◆ m_prefix

std::string D3PD::ObjectMetadata::m_prefix
protectedinherited

Prefix used by the D3PDObject.

Definition at line 174 of file ObjectMetadata.h.

◆ m_variables

std::set< Variable > D3PD::ObjectMetadata::m_variables
protectedinherited

The list of variables created by a D3PDObject.

Definition at line 172 of file ObjectMetadata.h.

◆ RANDOM_NAME_POSTFIX_LENGTH

const size_t D3PD::ObjectMetadata::RANDOM_NAME_POSTFIX_LENGTH = 6
staticinherited

Length of the random string appended to the object name.

Definition at line 109 of file ObjectMetadata.h.

◆ SERIALIZER_VERSION

const unsigned int D3PD::ObjectMetadata::SERIALIZER_VERSION = 1
staticinherited

"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.

◆ STRING_SEPARATOR

const char *const D3PD::ObjectMetadata::STRING_SEPARATOR = "@"
staticinherited

Character separating parts of the object's metadata.

Definition at line 111 of file ObjectMetadata.h.


The documentation for this class was generated from the following files:
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
D3PD::ObjectMetadata::m_variables
std::set< Variable > m_variables
The list of variables created by a D3PDObject.
Definition: ObjectMetadata.h:172
get_generator_info.result
result
Definition: get_generator_info.py:21
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
D3PD::ObjectMetadata::m_name
std::string m_name
Name of the D3PDObject that this object describes.
Definition: ObjectMetadata.h:173
D3PD::ObjectMetadata::m_prefix
std::string m_prefix
Prefix used by the D3PDObject.
Definition: ObjectMetadata.h:174
D3PD::ObjectMetadata::SERIALIZER_VERSION
static const unsigned int SERIALIZER_VERSION
"Version number" of the serialized information
Definition: ObjectMetadata.h:119
D3PD::isPrimitive
bool isPrimitive(const std::string &type)
This function is used in the code generator to determine from a type name if it's a primitive type or...
Definition: isPrimitive.cxx:24
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
D3PD::ObjectMetadata::container
bool container() const
Get whether the D3PDObject describes a container or not.
Definition: ObjectMetadata.cxx:230
D3PD::ObjectMetadata::m_container
bool m_container
The D3PDObject describes a container.
Definition: ObjectMetadata.h:175
D3PD::ObjectMetadata::STRING_SEPARATOR
static const char *const STRING_SEPARATOR
Character separating parts of the object's metadata.
Definition: ObjectMetadata.h:111
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
D3PD::ObjectMetadata::ObjectMetadata
ObjectMetadata()
Default constructor.
Definition: ObjectMetadata.cxx:61
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
D3PD::ObjectMetadata::merge
ObjectMetadata & merge(const ObjectMetadata &obj)
Function merging the contents of two objects.
Definition: ObjectMetadata.cxx:375
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
D3PD::ObjectMetadata::prefix
const std::string & prefix() const
Get the prefix given to variables in this D3PDObject.
Definition: ObjectMetadata.cxx:219
Variable
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:39
D3PD::ObjectMetadata::RANDOM_NAME_POSTFIX_LENGTH
static const size_t RANDOM_NAME_POSTFIX_LENGTH
Length of the random string appended to the object name.
Definition: ObjectMetadata.h:109
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
python.PyAthena.obj
obj
Definition: PyAthena.py:132
D3PD::ObjectMetadata::name
const std::string & name() const
Get the name of the D3PDObject that this object describes.
Definition: ObjectMetadata.cxx:170