ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
AthenaAttributeListSpecification Class Reference

#include <CoralBase/AthenaAttributeListSpecification.h>

Collaboration diagram for AthenaAttributeListSpecification:

Classes

class  const_iterator
 The iterator class. More...
 

Public Member Functions

 AthenaAttributeListSpecification ()
 Constructor. More...
 
 AthenaAttributeListSpecification (const AthenaAttributeListSpecification &rhs)
 Copy constructor. More...
 
 AthenaAttributeListSpecification (const coral::AttributeListSpecification &rhs)
 Copy constructor. More...
 
void release () const
 Decrements the reference counter. More...
 
template<typename T >
void extend (const std::string &name, const std::string &unitName="UNKNOWN", const std::string &groupName="UNKNOWN")
 Appends a new specification. More...
 
void extend (const std::string &name, const std::string &typeName, const std::string &unitName="UNKNOWN", const std::string &groupName="UNKNOWN")
 
void extend (const std::string &name, const std::type_info &type, const std::string &unitName="UNKNOWN", const std::string &groupName="UNKNOWN")
 
void extend (const std::string &name, const AthenaAttributeType &type)
 
void extend (const AthenaAttributeSpecification &row)
 
size_t size () const
 Returns the size of the specification. More...
 
bool operator== (const AthenaAttributeListSpecification &rhs) const
 Equal operator. Compares only types and values. Not the attribute names. More...
 
bool operator!= (const AthenaAttributeListSpecification &rhs) const
 Comparison operator. Compares only types and values. Not the attribute names. More...
 
int index (const std::string &name) const
 Returns the index of a specification given its name. If the name is not found it returns -1. More...
 
const AthenaAttributeSpecificationoperator[] (size_t index) const
 Bracket operator. More...
 
const AthenaAttributeSpecificationspecificationForAttribute (int index) const
 Returns the specification given an index. More...
 
void coralSpec (coral::AttributeListSpecification &) const
 Fills a coral Specification. More...
 
const_iterator begin () const
 Returns a forward iterator. More...
 
const_iterator end () const
 

Protected Member Functions

void addRef () const
 
 ~AthenaAttributeListSpecification ()
 The destructor is private. More...
 
AthenaAttributeListSpecificationoperator= (const AthenaAttributeListSpecification &)
 No assignment operator. More...
 

Private Attributes

std::atomic< int > m_counter
 The reference counter. More...
 
std::vector< AthenaAttributeSpecification * > m_attributeSpecifications
 The specifications. More...
 
std::map< std::string, int > m_mapOfNameToIndex
 The map of names to indices. More...
 

Friends

class AthenaAttributeList
 Increments the reference counter only the AttributeList can call this method. More...
 

Detailed Description

The specification of an AttributeList

Definition at line 42 of file AthenaAttributeListSpecification.h.

Constructor & Destructor Documentation

◆ AthenaAttributeListSpecification() [1/3]

AthenaAttributeListSpecification::AthenaAttributeListSpecification ( )
inline

Constructor.

Definition at line 236 of file AthenaAttributeListSpecification.h.

236  :
237  m_counter( 1 ),
240 {}

◆ AthenaAttributeListSpecification() [2/3]

AthenaAttributeListSpecification::AthenaAttributeListSpecification ( const AthenaAttributeListSpecification rhs)
inline

Copy constructor.

Definition at line 243 of file AthenaAttributeListSpecification.h.

243  :
244  m_counter( 1 ),
247 {
248  for ( std::vector< AthenaAttributeSpecification* >::const_iterator iSpecification = rhs.m_attributeSpecifications.begin();
249  iSpecification != rhs.m_attributeSpecifications.end(); ++iSpecification ) {
250  m_attributeSpecifications.push_back( new AthenaAttributeSpecification( **iSpecification ) );
251  }
252 }

◆ AthenaAttributeListSpecification() [3/3]

AthenaAttributeListSpecification::AthenaAttributeListSpecification ( const coral::AttributeListSpecification &  rhs)
inline

Copy constructor.

Definition at line 255 of file AthenaAttributeListSpecification.h.

255  :
256  m_counter( 1 ),
259 {
260  //std::cerr << "AthenaAttributeListSpecification (coral version) with counter = " << m_counter << std::endl;
261  for ( coral::AttributeListSpecification::const_iterator iSpecification = rhs.begin();
262  iSpecification != rhs.end(); ++iSpecification )
263  {
264  this->extend(iSpecification->name(),iSpecification->typeName());
265  }
266 }

◆ ~AthenaAttributeListSpecification()

AthenaAttributeListSpecification::~AthenaAttributeListSpecification ( )
inlineprotected

The destructor is private.

Definition at line 269 of file AthenaAttributeListSpecification.h.

270 {
271  //std::cerr << "In AthenaAttributeListSpecification destructor" << std::endl;
273  iSpecification != m_attributeSpecifications.end(); ++iSpecification ) delete *iSpecification;
274 }

Member Function Documentation

◆ addRef()

void AthenaAttributeListSpecification::addRef ( ) const
inlineprotected

Definition at line 278 of file AthenaAttributeListSpecification.h.

279 {
280  ++m_counter;
281 }

◆ begin()

AthenaAttributeListSpecification::const_iterator AthenaAttributeListSpecification::begin ( ) const
inline

Returns a forward iterator.

Definition at line 163 of file AthenaAttributeListSpecification.h.

◆ coralSpec()

void AthenaAttributeListSpecification::coralSpec ( coral::AttributeListSpecification &  s) const
inline

Fills a coral Specification.

Definition at line 362 of file AthenaAttributeListSpecification.h.

363 {
365  i != this->end();
366  ++i)
367  {
368  s.extend( i->name(), i->attributeType().typeName() );
369  }
370 }

◆ end()

AthenaAttributeListSpecification::const_iterator AthenaAttributeListSpecification::end ( ) const
inline

◆ extend() [1/5]

void AthenaAttributeListSpecification::extend ( const AthenaAttributeSpecification row)
inline

Definition at line 332 of file AthenaAttributeListSpecification.h.

333 {
334  if ( m_mapOfNameToIndex.find( aas.name() ) != m_mapOfNameToIndex.end() )
335  throw coral::AttributeListException( "An attribute with the name \"" + aas.name() + "\" exists already" );
337  m_mapOfNameToIndex.insert( std::make_pair( aas.name(), static_cast<int>( m_attributeSpecifications.size() - 1 ) ) );
338 }

◆ extend() [2/5]

void AthenaAttributeListSpecification::extend ( const std::string &  name,
const AthenaAttributeType type 
)
inline

Definition at line 321 of file AthenaAttributeListSpecification.h.

323 {
324  if ( m_mapOfNameToIndex.find( name ) != m_mapOfNameToIndex.end() )
325  throw coral::AttributeListException( "An attribute with the name \"" + name + "\" exists already" );
327  m_mapOfNameToIndex.insert( std::make_pair( name, static_cast<int>( m_attributeSpecifications.size() - 1 ) ) );
328 }

◆ extend() [3/5]

void AthenaAttributeListSpecification::extend ( const std::string &  name,
const std::string &  typeName,
const std::string &  unitName = "UNKNOWN",
const std::string &  groupName = "UNKNOWN" 
)
inline

Definition at line 294 of file AthenaAttributeListSpecification.h.

298 {
299  if ( m_mapOfNameToIndex.find( name ) != m_mapOfNameToIndex.end() )
300  throw coral::AttributeListException( "An attribute with the name \"" + name + "\" exists already" );
302  m_mapOfNameToIndex.insert( std::make_pair( name, static_cast<int>( m_attributeSpecifications.size() - 1 ) ) );
303 }

◆ extend() [4/5]

template<typename T >
void AthenaAttributeListSpecification::extend ( const std::string &  name,
const std::string &  unitName = "UNKNOWN",
const std::string &  groupName = "UNKNOWN" 
)

Appends a new specification.

Definition at line 149 of file AthenaAttributeListSpecification.h.

150 {
151  this->extend( name, typeid(T), unitName, groupName );
152 }

◆ extend() [5/5]

void AthenaAttributeListSpecification::extend ( const std::string &  name,
const std::type_info &  type,
const std::string &  unitName = "UNKNOWN",
const std::string &  groupName = "UNKNOWN" 
)
inline

Definition at line 307 of file AthenaAttributeListSpecification.h.

311 {
312  std::string typeName = System::typeinfoName(typeInfo);
313  if ( m_mapOfNameToIndex.find( name ) != m_mapOfNameToIndex.end() )
314  throw coral::AttributeListException( "An attribute with the name \"" + name + "\" exists already" );
316  m_mapOfNameToIndex.insert( std::make_pair( name, static_cast<int>( m_attributeSpecifications.size() - 1 ) ) );
317 }

◆ index()

int AthenaAttributeListSpecification::index ( const std::string &  name) const
inline

Returns the index of a specification given its name. If the name is not found it returns -1.

Definition at line 342 of file AthenaAttributeListSpecification.h.

343 {
344  std::map<std::string, int>::const_iterator iSpecificationForAttribute = m_mapOfNameToIndex.find( name );
345  if ( iSpecificationForAttribute == m_mapOfNameToIndex.end() ) return -1;
346  else return iSpecificationForAttribute->second;
347 }

◆ operator!=()

Comparison operator. Compares only types and values. Not the attribute names.

Definition at line 230 of file AthenaAttributeListSpecification.h.

231 {
232  return ( ! ( *this == rhs ) );
233 }

◆ operator=()

AthenaAttributeListSpecification& AthenaAttributeListSpecification::operator= ( const AthenaAttributeListSpecification )
protected

No assignment operator.

◆ operator==()

bool AthenaAttributeListSpecification::operator== ( const AthenaAttributeListSpecification rhs) const
inline

Equal operator. Compares only types and values. Not the attribute names.

Definition at line 374 of file AthenaAttributeListSpecification.h.

375 {
376  if ( this->size() != rhs.size() ) return false;
377  size_t theSize = this->size();
378  const AthenaAttributeListSpecification& lhs = *this;
379  for ( size_t i = 0; i < theSize; ++i )
380  //if ( (*this)[i] != rhs[i] )
381  if ( lhs[i] != rhs[i] )
382  return false;
383  return true;
384 }

◆ operator[]()

const AthenaAttributeSpecification & AthenaAttributeListSpecification::operator[] ( size_t  index) const
inline

Bracket operator.

Definition at line 224 of file AthenaAttributeListSpecification.h.

225 {
226  return this->specificationForAttribute( static_cast<int>( index ) );
227 }

◆ release()

void AthenaAttributeListSpecification::release ( ) const
inline

Decrements the reference counter.

Definition at line 285 of file AthenaAttributeListSpecification.h.

286 {
287  //std::cerr << "Before decrement " << std::endl;
288  //std::cerr << "AthenaAttributeListSpecification release called "
289  // << "with counter = " << m_counter << std::endl;
290  if (--m_counter == 0) delete this;
291 }

◆ size()

size_t AthenaAttributeListSpecification::size ( ) const
inline

Returns the size of the specification.

Definition at line 156 of file AthenaAttributeListSpecification.h.

157 {
158  return m_attributeSpecifications.size();
159 }

◆ specificationForAttribute()

const AthenaAttributeSpecification & AthenaAttributeListSpecification::specificationForAttribute ( int  index) const
inline

Returns the specification given an index.

Definition at line 351 of file AthenaAttributeListSpecification.h.

352 {
353  if ( index < 0 || index >= static_cast<int>( m_attributeSpecifications.size() ) )
354  throw coral::AttributeListException( "Invalid index for the attribute already" );
355  return *( m_attributeSpecifications[ index ] );
356 }

Friends And Related Function Documentation

◆ AthenaAttributeList

friend class AthenaAttributeList
friend

Increments the reference counter only the AttributeList can call this method.

Definition at line 124 of file AthenaAttributeListSpecification.h.

Member Data Documentation

◆ m_attributeSpecifications

std::vector< AthenaAttributeSpecification* > AthenaAttributeListSpecification::m_attributeSpecifications
private

The specifications.

Definition at line 138 of file AthenaAttributeListSpecification.h.

◆ m_counter

std::atomic<int> AthenaAttributeListSpecification::m_counter
mutableprivate

The reference counter.

Definition at line 135 of file AthenaAttributeListSpecification.h.

◆ m_mapOfNameToIndex

std::map< std::string, int > AthenaAttributeListSpecification::m_mapOfNameToIndex
private

The map of names to indices.

Definition at line 141 of file AthenaAttributeListSpecification.h.


The documentation for this class was generated from the following file:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AthenaAttributeListSpecification::index
int index(const std::string &name) const
Returns the index of a specification given its name. If the name is not found it returns -1.
Definition: AthenaAttributeListSpecification.h:342
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
AthenaAttributeListSpecification
Definition: AthenaAttributeListSpecification.h:42
AthenaAttributeListSpecification::m_mapOfNameToIndex
std::map< std::string, int > m_mapOfNameToIndex
The map of names to indices.
Definition: AthenaAttributeListSpecification.h:141
AthenaAttributeListSpecification::const_iterator
The iterator class.
Definition: AthenaAttributeListSpecification.h:94
index
Definition: index.py:1
RunTileMonitoring.groupName
groupName
Definition: RunTileMonitoring.py:158
AthenaAttributeListSpecification::begin
const_iterator begin() const
Returns a forward iterator.
Definition: AthenaAttributeListSpecification.h:163
AthenaAttributeListSpecification::specificationForAttribute
const AthenaAttributeSpecification & specificationForAttribute(int index) const
Returns the specification given an index.
Definition: AthenaAttributeListSpecification.h:351
AthenaAttributeListSpecification::m_counter
std::atomic< int > m_counter
The reference counter.
Definition: AthenaAttributeListSpecification.h:135
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
AthenaAttributeListSpecification::m_attributeSpecifications
std::vector< AthenaAttributeSpecification * > m_attributeSpecifications
The specifications.
Definition: AthenaAttributeListSpecification.h:138
lumiFormat.i
int i
Definition: lumiFormat.py:92
AthenaAttributeListSpecification::end
const_iterator end() const
Definition: AthenaAttributeListSpecification.h:170
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthenaAttributeListSpecification::size
size_t size() const
Returns the size of the specification.
Definition: AthenaAttributeListSpecification.h:156
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
AthenaAttributeSpecification
Definition: AthenaAttributeSpecification.h:25
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35