ATLAS Offline Software
Loading...
Searching...
No Matches
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
22namespace D3PD {
23
37
38 public:
42 ObjectMetadata( const ObjectMetadata& parent );
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
106 ObjectMetadata& merge( const ObjectMetadata& obj );
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;
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;
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
double length(const pvec &v)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Common interface for adding a variable to a tuple.
Define macros for attributes used to control the static checker.
Common interface for adding a variable to a tuple.
StatusCode addVariable(const std::string &name, T *&ptr, const std::string &docstring="")
Add a variable to the tuple.
StatusCode addDimensionedVariable(const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring="")
Add a variable to the tuple.
bool operator<(const Variable &var) const
Operator needed to use such objects in STL containers.
const std::string & type() const
Type name of the variable.
bool m_primitive
Flag showing whether the variable is a primitive.
StatusCode read(const std::string &data)
Read data from a "serialized" string.
bool operator==(const Variable &var) const
Operator checking the equivalence of two variables.
std::string toString() const
Function "serializing" the variable information into a string.
std::string m_type
Full type name of the variable.
void setDoc(const std::string &doc)
Set the description of the variable.
void setPrimitive(bool primitive)
Set whether the variable is a primitive.
const std::string & doc() const
Description of the variable.
const std::string & name() const
Name of the variable without its prefix.
static const char *const STRING_SEPARATOR
Character separating parts of the variable's metadata.
std::string m_name
Name of the variable without its prefix.
void setName(const std::string &name)
Set the name of the variable.
bool primitive() const
Flag showing whether the variable is a primitive.
void setType(const std::string &type)
Set the type name of the variable.
std::string m_doc
Description of the variable.
D3PD variable metadata handling class.
static const size_t RANDOM_NAME_POSTFIX_LENGTH
Length of the random string appended to the object name.
void clear()
Function clearing the object.
const std::string & name() const
Get the name of the D3PDObject that this object describes.
static const unsigned int SERIALIZER_VERSION
"Version number" of the serialized information
ObjectMetadata & operator+=(const ObjectMetadata &obj)
Operator merging the contents of two objects.
std::set< Variable > m_variables
The list of variables created by a D3PDObject.
const std::set< Variable > & variables() const
Function for accessing all the variables of the D3PDObject.
bool m_container
The D3PDObject describes a container.
static std::string genSuffix ATLAS_NOT_THREAD_SAFE(const std::string &name, size_t length)
Generate a unique suffix for a metadata object name.
ObjectMetadata & operator=(const ObjectMetadata &parent)
Assignment operator.
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.
StatusCode read(const std::string &data)
Function "de-serializing" the stored information from a string.
std::string metadataName ATLAS_NOT_THREAD_SAFE() const
Get the name for the metadata object that should be created.
std::string toString() const
Function "serializing" the stored information into a string.
std::string m_name
Name of the D3PDObject that this object describes.
void setPrefix(const std::string &prefix)
Set the prefix given to variables in this D3PDObject.
void setName(const std::string &name)
Set the name of the D3PDObject that this object describes.
void setContainer(bool container)
Set whether the D3PDObject describes a container or not.
const std::string & prefix() const
Get the prefix given to variables in this D3PDObject.
std::string m_prefix
Prefix used by the D3PDObject.
static std::string objectName(const std::string &metaName)
Get the D3PDObject's name from the name of the metadata object.
ObjectMetadata()
Default constructor.
bool operator<(const ObjectMetadata &rhs) const
Operator needed to use such objects in ordered STL containers.
static const char *const STRING_SEPARATOR
Character separating parts of the object's metadata.
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...
bool operator==(const ObjectMetadata &rhs) const
Equality operator.
bool container() const
Get whether the D3PDObject describes a container or not.
Block filler tool for noisy FEB information.
ObjectMetadata operator+(const ObjectMetadata &obj1, const ObjectMetadata &obj2)
Operator for creating the sum of two metadata objects.
Definition merge.py:1