ATLAS Offline Software
ObjectMetadata.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef D3PDMAKERUTILS_OBJECTMETADATA_H
8 #define D3PDMAKERUTILS_OBJECTMETADATA_H
9 
10 // STL include(s):
11 #include <atomic>
12 #include <string>
13 #include <set>
14 #include <unordered_map>
15 
16 // D3PD include(s):
18 
19 // Gaudi/Athena include(s):
21 
22 namespace D3PD {
23 
36  class ObjectMetadata : public IAddVariable {
37 
38  public:
43 
47  bool operator== ( const ObjectMetadata& rhs ) const;
49  bool operator< ( const ObjectMetadata& rhs ) const;
50 
54 
56  //
57  // Functions inherited from IAddVariable
58 
59  virtual StatusCode addVariable( const std::string& name,
60  const std::type_info& ti,
61  void*& ptr,
62  const std::string& docstring = "",
63  const void* defval = 0 );
64 
65  virtual StatusCode addDimensionedVariable( const std::string& name,
66  const std::type_info& ti,
67  void*& ptr,
68  const std::string& dim,
69  const std::string& docstring = "",
70  const void* defval = 0 );
71 
72  //
74 
76  const std::string& name() const;
78  void setName( const std::string& name );
79 
81  std::string metadataName ATLAS_NOT_THREAD_SAFE () const;
83  static std::string objectName( const std::string& metaName );
84 
86  const std::string& prefix() const;
88  void setPrefix( const std::string& prefix );
89 
91  bool container() const;
93  void setContainer( bool container );
94 
96  std::string toString() const;
98  StatusCode read( const std::string& data );
99 
101  void clear();
102 
107 
109  static const size_t RANDOM_NAME_POSTFIX_LENGTH;
111  static const char* const STRING_SEPARATOR;
113 
119  static const unsigned int SERIALIZER_VERSION;
120 
131  class Variable {
132  public:
134  Variable();
136  const std::string& type() const;
138  const std::string& name() const;
140  const std::string& doc() const;
142  bool primitive() const;
144  void setType( const std::string& type );
146  void setName( const std::string& name );
148  void setDoc( const std::string& doc );
150  void setPrimitive( bool primitive );
152  std::string toString() const;
154  StatusCode read( const std::string& data );
156  bool operator== ( const Variable& var ) const;
158  bool operator< ( const Variable& var ) const;
160  static const char* const STRING_SEPARATOR;
161  private:
162  std::string m_type;
163  std::string m_name;
164  std::string m_doc;
165  bool m_primitive;
166  }; // class Variable
167 
169  const std::set< Variable >& variables() const;
170 
171  protected:
172  std::set< Variable > m_variables;
173  std::string m_name;
174  std::string m_prefix;
175  bool m_container;
176 
177  private:
189  static std::string genSuffix ATLAS_NOT_THREAD_SAFE (const std::string& name, size_t length);
190 
191  }; // class ObjectMetadata
192 
195  const ObjectMetadata& obj2 );
196 
197 } // namespace D3PD
198 
199 #endif // D3PDMAKERUTILS_OBJECTMETADATA_H
D3PD::ObjectMetadata::operator<
bool operator<(const ObjectMetadata &rhs) const
Operator needed to use such objects in ordered STL containers.
Definition: ObjectMetadata.cxx:91
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
D3PD::IAddVariable
Common interface for adding a variable to a tuple.
Definition: IAddVariable.h:70
D3PD::ObjectMetadata::variables
const std::set< Variable > & variables() const
Function for accessing all the variables of the D3PDObject.
Definition: ObjectMetadata.cxx:577
D3PD::ObjectMetadata::Variable::Variable
Variable()
Default constructor.
Definition: ObjectMetadata.cxx:422
D3PD::ObjectMetadata::Variable::m_type
std::string m_type
Full type name of the variable.
Definition: ObjectMetadata.h:162
D3PD::ObjectMetadata::addDimensionedVariable
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...
Definition: ObjectMetadata.cxx:157
D3PD::ObjectMetadata::Variable::primitive
bool primitive() const
Flag showing whether the variable is a primitive.
Definition: ObjectMetadata.cxx:442
D3PD::ObjectMetadata::ATLAS_NOT_THREAD_SAFE
static std::string genSuffix ATLAS_NOT_THREAD_SAFE(const std::string &name, size_t length)
Generate a unique suffix for a metadata object name.
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
D3PD::ObjectMetadata::m_variables
std::set< Variable > m_variables
The list of variables created by a D3PDObject.
Definition: ObjectMetadata.h:172
D3PD::ObjectMetadata::Variable::operator==
bool operator==(const Variable &var) const
Operator checking the equivalence of two variables.
Definition: ObjectMetadata.cxx:562
D3PD::ObjectMetadata::Variable::type
const std::string & type() const
Type name of the variable.
Definition: ObjectMetadata.cxx:427
D3PD::ObjectMetadata::Variable::read
StatusCode read(const std::string &data)
Read data from a "serialized" string.
Definition: ObjectMetadata.cxx:495
D3PD::ObjectMetadata::m_name
std::string m_name
Name of the D3PDObject that this object describes.
Definition: ObjectMetadata.h:173
D3PD::ObjectMetadata::setName
void setName(const std::string &name)
Set the name of the D3PDObject that this object describes.
Definition: ObjectMetadata.cxx:175
D3PD::ObjectMetadata::Variable::toString
std::string toString() const
Function "serializing" the variable information into a string.
Definition: ObjectMetadata.cxx:479
D3PD::ObjectMetadata::m_prefix
std::string m_prefix
Prefix used by the D3PDObject.
Definition: ObjectMetadata.h:174
ReadCellNoiseFromCoolCompare.obj2
obj2
Definition: ReadCellNoiseFromCoolCompare.py:303
D3PD::ObjectMetadata::SERIALIZER_VERSION
static const unsigned int SERIALIZER_VERSION
"Version number" of the serialized information
Definition: ObjectMetadata.h:119
D3PD::ObjectMetadata::operator+=
ObjectMetadata & operator+=(const ObjectMetadata &obj)
Operator merging the contents of two objects.
Definition: ObjectMetadata.cxx:363
D3PD::ObjectMetadata::setPrefix
void setPrefix(const std::string &prefix)
Set the prefix given to variables in this D3PDObject.
Definition: ObjectMetadata.cxx:224
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
D3PD::ObjectMetadata::container
bool container() const
Get whether the D3PDObject describes a container or not.
Definition: ObjectMetadata.cxx:230
D3PD::ObjectMetadata::read
StatusCode read(const std::string &data)
Function "de-serializing" the stored information from a string.
Definition: ObjectMetadata.cxx:276
D3PD::ObjectMetadata::Variable::setType
void setType(const std::string &type)
Set the type name of the variable.
Definition: ObjectMetadata.cxx:447
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
D3PD::ObjectMetadata::ObjectMetadata
ObjectMetadata()
Default constructor.
Definition: ObjectMetadata.cxx:61
D3PD::ObjectMetadata::Variable::STRING_SEPARATOR
static const char *const STRING_SEPARATOR
Character separating parts of the variable's metadata.
Definition: ObjectMetadata.h:160
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
D3PD::ObjectMetadata::merge
ObjectMetadata & merge(const ObjectMetadata &obj)
Function merging the contents of two objects.
Definition: ObjectMetadata.cxx:375
D3PD::operator+
ObjectMetadata operator+(const ObjectMetadata &obj1, const ObjectMetadata &obj2)
Operator for creating the sum of two metadata objects.
Definition: ObjectMetadata.cxx:582
D3PD::ObjectMetadata::operator=
ObjectMetadata & operator=(const ObjectMetadata &parent)
Assignment operator.
Definition: ObjectMetadata.cxx:73
D3PD::ObjectMetadata::Variable::setName
void setName(const std::string &name)
Set the name of the variable.
Definition: ObjectMetadata.cxx:453
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::ObjectMetadata::objectName
static std::string objectName(const std::string &metaName)
Get the D3PDObject's name from the name of the metadata object.
Definition: ObjectMetadata.cxx:213
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::ObjectMetadata::clear
void clear()
Function clearing the object.
Definition: ObjectMetadata.cxx:352
D3PD::ObjectMetadata::toString
std::string toString() const
Function "serializing" the stored information into a string.
Definition: ObjectMetadata.cxx:249
D3PD::ObjectMetadata::Variable::setDoc
void setDoc(const std::string &doc)
Set the description of the variable.
Definition: ObjectMetadata.cxx:459
D3PD::ObjectMetadata::Variable::operator<
bool operator<(const Variable &var) const
Operator needed to use such objects in STL containers.
Definition: ObjectMetadata.cxx:568
D3PD::ObjectMetadata::Variable::name
const std::string & name() const
Name of the variable without its prefix.
Definition: ObjectMetadata.cxx:432
D3PD::ObjectMetadata::setContainer
void setContainer(bool container)
Set whether the D3PDObject describes a container or not.
Definition: ObjectMetadata.cxx:235
D3PD::ObjectMetadata
D3PD variable metadata handling class.
Definition: ObjectMetadata.h:36
D3PD::ObjectMetadata::Variable::m_primitive
bool m_primitive
Flag showing whether the variable is a primitive.
Definition: ObjectMetadata.h:165
D3PD::ObjectMetadata::addVariable
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.
Definition: ObjectMetadata.cxx:109
D3PD::ObjectMetadata::prefix
const std::string & prefix() const
Get the prefix given to variables in this D3PDObject.
Definition: ObjectMetadata.cxx:219
D3PD::ObjectMetadata::operator==
bool operator==(const ObjectMetadata &rhs) const
Equality operator.
Definition: ObjectMetadata.cxx:85
D3PD::ObjectMetadata::Variable
Internal class keeping track of a single variable.
Definition: ObjectMetadata.h:131
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
D3PD::ObjectMetadata::ATLAS_NOT_THREAD_SAFE
std::string metadataName ATLAS_NOT_THREAD_SAFE() const
Get the name for the metadata object that should be created.
D3PD::ObjectMetadata::Variable::setPrimitive
void setPrimitive(bool primitive)
Set whether the variable is a primitive.
Definition: ObjectMetadata.cxx:465
D3PD::ObjectMetadata::Variable::m_doc
std::string m_doc
Description of the variable.
Definition: ObjectMetadata.h:164
D3PD::IAddVariable::addVariable
StatusCode addVariable(const std::string &name, T *&ptr, const std::string &docstring="")
Add a variable to the tuple.
IAddVariable.h
Common interface for adding a variable to a tuple.
D3PD::IAddVariable::addDimensionedVariable
StatusCode addDimensionedVariable(const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring="")
Add a variable to the tuple.
D3PD::ObjectMetadata::Variable::m_name
std::string m_name
Name of the variable without its prefix.
Definition: ObjectMetadata.h:163
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
D3PD::ObjectMetadata::Variable::doc
const std::string & doc() const
Description of the variable.
Definition: ObjectMetadata.cxx:437
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
D3PD::ObjectMetadata::name
const std::string & name() const
Get the name of the D3PDObject that this object describes.
Definition: ObjectMetadata.cxx:170