ATLAS Offline Software
TagAthenaAttributeList.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
21 #ifndef DBDATAOBJECTS_TAGATHENAATTRIBUTELIST_H
22 # define DBDATAOBJECTS_TAGATHENAATTRIBUTELIST_H
23 
24 
25 #include "CoralBase/Attribute.h"
26 #include "CoralBase/AttributeList.h"
27 #include "CoralBase/AttributeListSpecification.h"
29 #include "AthenaKernel/CLASS_DEF.h"
30 
31 #include "GaudiKernel/DataObject.h"
32 
45  public DataObject
46 {
47 public:
48 
51 
57 
62  explicit TagAthenaAttributeList(const coral::AttributeListSpecification& rhs);
63 
67 
69 
72  template<typename T> void extend( const std::string& name );
73  void extend( const std::string& name,
74  const std::string& typeName );
75  void extend( const std::string& name,
76  const std::type_info& type );
77  void extend( const std::string& name,
78  const AthenaAttributeType& type );
79 
81  void print(std::ostream& os) const;
82 
83  bool hasDesc() const;
85 
86  const coral::AttributeList& coralList() const {return *static_cast<const coral::AttributeList*>(this);}
87 
88 private:
89 
92 
93 
94 };
95 
97 
98 
99 inline
101  if(m_desc!=0) m_desc->release();
102 }
103 // CONSTRUCTORS - CORAL VERSIONS
104 inline
106  m_desc(0)
107 {}
108 
109 inline
111  coral::AttributeList(rhs),
112  DataObject(*this),
113  m_desc(0)
114 {}
115 
116 inline
117 TagAthenaAttributeList::TagAthenaAttributeList(const coral::AttributeListSpecification& spec) :
119  m_desc(0)
120 {}
121 
122 // CONSTRUCTORS - ATHENA MOD VERSIONS
123 inline
125  coral::AttributeList(rhs),
126  DataObject(rhs)
127 {
128  if (rhs.hasDesc()) m_desc = new AthenaAttributeListSpecification( *(rhs.getDesc()) );
129  else m_desc=0;
130 }
131 
132 inline
135 {
136  if (this != &rhs) {
137  coral::AttributeList::operator= (rhs);
138  DataObject::operator= (rhs);
139  if (m_desc) m_desc->release();
140  if (rhs.hasDesc()) m_desc = new AthenaAttributeListSpecification( *(rhs.getDesc()) );
141  else m_desc=0;
142  }
143  return *this;
144 }
145 
146 inline
148  coral::AttributeList(),
150 {
152  i != desc.end();
153  ++i)
154  {
155  this->coral::AttributeList::extend( i->name(), i->attributeType().typeName() );
156  }
157 }
158 
159 // INLINE METHODS
160 
161 template<typename T> void
163 {
164  this->extend( name, typeid(T) );
165 }
166 
167 inline void
169  const std::string& typeName )
170 {
171  if (this->hasDesc()) m_desc->extend( name, typeName );
172  this->coral::AttributeList::extend( name, typeName );
173 }
174 
175 
176 inline void
178  const std::type_info& type )
179 {
180  if (this->hasDesc()) m_desc->extend( name, type );
181  this->coral::AttributeList::extend( name, type );
182 }
183 
184 inline void
186  const AthenaAttributeType& type )
187 {
188  if (this->hasDesc()) m_desc->extend( name, type );
189  this->coral::AttributeList::extend( name, type.typeName() );
190 }
191 
192 inline
193 void TagAthenaAttributeList::print(std::ostream& os) const {
194  // this->toOutputStream(os);
195  os << "{";
196  for (coral::AttributeList::const_iterator itr=this->begin();
197  itr!=this->end();++itr) {
198  if (itr!=this->begin()) os << ",";
199  itr->toOutputStream(os);
200  }
201  os << "}";
202 }
203 
205 {
206  return m_desc!=0;
207 }
208 
209 inline
211 {
212  // User has to check for zero = no desc
213  return m_desc;
214 }
215 
216 
217 #endif // DBDATAOBJECTS_TAGATHENAATTRIBUTELIST_H
TagAthenaAttributeList::~TagAthenaAttributeList
~TagAthenaAttributeList()
Definition: TagAthenaAttributeList.h:100
TagAthenaAttributeList::print
void print(std::ostream &os) const
print to simulate function provided by old POOL AttributeList
Definition: TagAthenaAttributeList.h:193
TagAthenaAttributeList::coralList
const coral::AttributeList & coralList() const
Definition: TagAthenaAttributeList.h:86
AthenaAttributeListSpecification
Definition: AthenaAttributeListSpecification.h:42
AthenaAttributeListSpecification.h
AthenaAttributeListSpecification::const_iterator
The iterator class.
Definition: AthenaAttributeListSpecification.h:94
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TagAthenaAttributeList::hasDesc
bool hasDesc() const
Definition: TagAthenaAttributeList.h:204
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
coral
Definition: ISecondaryEventSelector.h:19
AthenaAttributeListSpecification::extend
void extend(const std::string &name, const std::string &unitName="UNKNOWN", const std::string &groupName="UNKNOWN")
Appends a new specification.
Definition: AthenaAttributeListSpecification.h:149
TagAthenaAttributeList::operator=
TagAthenaAttributeList & operator=(const TagAthenaAttributeList &rhs)
Assignment.
Definition: TagAthenaAttributeList.h:134
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
TagAthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: TagAthenaAttributeList.h:46
TagAthenaAttributeList::extend
void extend(const std::string &name)
Extends the AttributeList by one attribute, given a specification.
Definition: TagAthenaAttributeList.h:162
lumiFormat.i
int i
Definition: lumiFormat.py:92
TagAthenaAttributeList::getDesc
const AthenaAttributeListSpecification * getDesc() const
Definition: TagAthenaAttributeList.h:210
AthenaAttributeListSpecification::release
void release() const
Decrements the reference counter.
Definition: AthenaAttributeListSpecification.h:285
TagAthenaAttributeList::TagAthenaAttributeList
TagAthenaAttributeList()
Construct empty attribute list with empty specification.
Definition: TagAthenaAttributeList.h:105
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
AthenaAttributeType
Definition: AthenaAttributeType.h:31
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
TagAthenaAttributeList::m_desc
AthenaAttributeListSpecification * m_desc
The specification (empty if created with coral version)
Definition: TagAthenaAttributeList.h:91
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
CLASS_DEF.h
macros to associate a CLID to a type
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35