ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
SG::ConstAuxElement Class Reference

Const part of AuxElement. More...

#include <AuxElement.h>

Inheritance diagram for SG::ConstAuxElement:
Collaboration diagram for SG::ConstAuxElement:

Public Types

using TypelessConstAccessor = SG::TypelessConstAccessor
 Helper class to provide const generic access to aux data. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
using ConstAccessor = SG::ConstAccessor< T, ALLOC >
 Helper class to provide type-safe access to aux data. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
using Decorator = SG::Decorator< T, ALLOC >
 class to provide type-safe access to aux data. More...
 

Public Member Functions

 ConstAuxElement ()
 Default constructor. More...
 
 ConstAuxElement (const SG::AuxVectorData *container, size_t index)
 Constructor with explicit container / index. More...
 
 ConstAuxElement (const ConstAuxElement &other)
 Copy Constructor. More...
 
ConstAuxElementoperator= (const ConstAuxElement &other)=delete
 No assignment to a const element. More...
 
 ~ConstAuxElement ()
 Destructor. More...
 
const SG::AuxVectorDatacontainer () const
 Return the container holding this element. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor< T, ALLOC >::const_reference_type auxdata (const std::string &name) const
 Fetch an aux data variable, as a const reference. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor< T, ALLOC >::const_reference_type auxdata (const std::string &name, const std::string &clsname) const
 Fetch an aux data variable, as a const reference. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor< T, ALLOC >::const_reference_type auxdataConst (const std::string &name) const
 Fetch an aux data variable, as a const reference. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor< T, ALLOC >::const_reference_type auxdataConst (const std::string &name, const std::string &clsname) const
 Fetch an aux data variable, as a const reference. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
bool isAvailable (const std::string &name, const std::string &clsname="") const
 Check if an aux variable is available for reading. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
bool isAvailableWritableAsDecoration (const std::string &name, const std::string &clsname="") const
 Check if an aux variable is available for writing as a decoration. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
Decorator< T, ALLOC >::reference_type auxdecor (const std::string &name) const
 Fetch an aux decoration, as a non-const reference. More...
 
template<class T , class ALLOC = AuxAllocator_t<T>>
Decorator< T, ALLOC >::reference_type auxdecor (const std::string &name, const std::string &clsname) const
 Fetch an aux decoration, as a non-const reference. More...
 
const SG::auxid_set_tgetAuxIDs () const
 Return a set of identifiers for existing data items for this object. More...
 
size_t index () const
 Return the index of this element within its container. More...
 
size_t index () const
 Return the index of this element within its container. More...
 

Protected Member Functions

bool noPrivateData () const
 True if this element has no private data. More...
 
bool havePrivateData () const
 True if this element currently has private data. More...
 
bool hadPrivateData () const
 True if this element had private data before it was added to its current container. More...
 

Private Types

enum  PrivateStoreState : uint8_t { PrivateStoreState::NO_PRIVATE = 0, PrivateStoreState::HAVE_PRIVATE = 1, PrivateStoreState::HAD_PRIVATE = 2 }
 The current private data state. More...
 

Private Member Functions

void releasePrivateStoreForDtor ()
 Out-of-line portion of destructor. More...
 
void setIndex (size_t index, const SG::AuxVectorData *container)
 Set the index/container for this element. More...
 
bool setIndexPrivate (size_t index, const SG::AuxVectorData *container)
 Set the index/container for this element. More...
 
void setNoPrivateData ()
 Record that this element does not have private data. More...
 
void setHavePrivateData ()
 Record that this element currently has private data. More...
 
void setHadPrivateData ()
 Record that this element used to have private data. More...
 

Private Attributes

const SG::AuxVectorDatam_container
 The container of which this object is an element. More...
 
size_t m_index
 The index of this element within its container. More...
 
PrivateStoreState m_privateStoreState
 

Friends

class AuxElement
 
class SG::AuxVectorBase
 

Detailed Description

Const part of AuxElement.

This base class factors out the const portions of AuxElement (which see for a complete description).

Definition at line 51 of file AuxElement.h.

Member Typedef Documentation

◆ ConstAccessor

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::ConstAuxElement::ConstAccessor = SG::ConstAccessor<T, ALLOC>

Helper class to provide type-safe access to aux data.

Definition at line 113 of file AuxElement.h.

◆ Decorator

template<class T , class ALLOC = AuxAllocator_t<T>>
using SG::ConstAuxElement::Decorator = SG::Decorator<T, ALLOC>

class to provide type-safe access to aux data.

Definition at line 117 of file AuxElement.h.

◆ TypelessConstAccessor

Helper class to provide const generic access to aux data.

Definition at line 109 of file AuxElement.h.

Member Enumeration Documentation

◆ PrivateStoreState

enum SG::IAuxElement::PrivateStoreState : uint8_t
strongprivateinherited

The current private data state.

Enumerator
NO_PRIVATE 
HAVE_PRIVATE 
HAD_PRIVATE 

Definition at line 131 of file IAuxElement.h.

132  {
133  NO_PRIVATE = 0,
134  HAVE_PRIVATE = 1,
135  HAD_PRIVATE = 2,
136  };

Constructor & Destructor Documentation

◆ ConstAuxElement() [1/3]

SG::ConstAuxElement::ConstAuxElement ( )

Default constructor.

◆ ConstAuxElement() [2/3]

SG::ConstAuxElement::ConstAuxElement ( const SG::AuxVectorData container,
size_t  index 
)

Constructor with explicit container / index.

Parameters
containerContainer of which this element will be a part.
indexIndex of this element within the container.

This does not make any changes to aux data.

◆ ConstAuxElement() [3/3]

SG::ConstAuxElement::ConstAuxElement ( const ConstAuxElement other)

Copy Constructor.

Parameters
otherObject being copied.

We do not copy the container/index — the new object is not yet in a container!

In the case of constructing an object with a private store, makePrivateStore will take care of copying the aux data.

◆ ~ConstAuxElement()

SG::ConstAuxElement::~ConstAuxElement ( )

Destructor.

Any private store is deleted.

Member Function Documentation

◆ auxdata() [1/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor<T, ALLOC>::const_reference_type SG::ConstAuxElement::auxdata ( const std::string &  name) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor or ConstAccessor classes.

◆ auxdata() [2/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor<T, ALLOC>::const_reference_type SG::ConstAuxElement::auxdata ( const std::string &  name,
const std::string &  clsname 
) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor or ConstAccessor classes.

◆ auxdataConst() [1/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor<T, ALLOC>::const_reference_type SG::ConstAuxElement::auxdataConst ( const std::string &  name) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the ConstAccessor class.

◆ auxdataConst() [2/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
ConstAccessor<T, ALLOC>::const_reference_type SG::ConstAuxElement::auxdataConst ( const std::string &  name,
const std::string &  clsname 
) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the ConstAccessor class.

◆ auxdecor() [1/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
Decorator<T, ALLOC>::reference_type SG::ConstAuxElement::auxdecor ( const std::string &  name) const

Fetch an aux decoration, as a non-const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ auxdecor() [2/2]

template<class T , class ALLOC = AuxAllocator_t<T>>
Decorator<T, ALLOC>::reference_type SG::ConstAuxElement::auxdecor ( const std::string &  name,
const std::string &  clsname 
) const

Fetch an aux decoration, as a non-const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ container()

const SG::AuxVectorData* SG::ConstAuxElement::container ( ) const

Return the container holding this element.

◆ getAuxIDs()

const SG::auxid_set_t & SG::ConstAuxElement::getAuxIDs ( ) const

Return a set of identifiers for existing data items for this object.

If this object has a private or standalone store, then information from that will be returned. Otherwise, if this element is part of a container, then information for the container will be returned. Otherwise, return an empty set.

Definition at line 152 of file AuxElement.cxx.

153 {
154  if (havePrivateData())
155  return m_container->getConstStore()->getAuxIDs();
156  if (container())
157  return container()->getAuxIDs();
158  static const SG::auxid_set_t null_set;
159  return null_set;
160 }

◆ hadPrivateData()

bool SG::IAuxElement::hadPrivateData ( ) const
protectedinherited

True if this element had private data before it was added to its current container.

◆ havePrivateData()

bool SG::IAuxElement::havePrivateData ( ) const
protectedinherited

True if this element currently has private data.

◆ index() [1/2]

size_t SG::IAuxElement::index ( ) const
inherited

Return the index of this element within its container.

◆ index() [2/2]

size_t SG::IAuxElement::index

Return the index of this element within its container.

Inherited from IAuxElement.

◆ isAvailable()

template<class T , class ALLOC = AuxAllocator_t<T>>
bool SG::ConstAuxElement::isAvailable ( const std::string &  name,
const std::string &  clsname = "" 
) const

Check if an aux variable is available for reading.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ isAvailableWritableAsDecoration()

template<class T , class ALLOC = AuxAllocator_t<T>>
bool SG::ConstAuxElement::isAvailableWritableAsDecoration ( const std::string &  name,
const std::string &  clsname = "" 
) const

Check if an aux variable is available for writing as a decoration.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ noPrivateData()

bool SG::IAuxElement::noPrivateData ( ) const
protectedinherited

True if this element has no private data.

◆ operator=()

ConstAuxElement& SG::ConstAuxElement::operator= ( const ConstAuxElement other)
delete

No assignment to a const element.

◆ releasePrivateStoreForDtor()

void SG::ConstAuxElement::releasePrivateStoreForDtor ( )
private

Out-of-line portion of destructor.

Delete a private store if we have one.

Definition at line 79 of file AuxElement.cxx.

80 {
81  if (havePrivateData()) {
82  delete m_container;
83  }
84 }

◆ setHadPrivateData()

void SG::IAuxElement::setHadPrivateData ( )
privateinherited

Record that this element used to have private data.

◆ setHavePrivateData()

void SG::IAuxElement::setHavePrivateData ( )
privateinherited

Record that this element currently has private data.

◆ setIndex()

void SG::ConstAuxElement::setIndex ( size_t  index,
const SG::AuxVectorData container 
)
private

Set the index/container for this element.

Parameters
indexThe index of this object within the container.
containerThe container holding this object. May be null if this object is being removed from a container.

Usually this simply sets the index and container members of this object. However, in the case where this object has an associated private store, then we need to deal with releasing the store if the object is being added to a container, or making a new store if the object is being removed from a container.

◆ setIndexPrivate()

bool SG::ConstAuxElement::setIndexPrivate ( size_t  index,
const SG::AuxVectorData container 
)
private

Set the index/container for this element.

Parameters
indexThe index of this object within the container.
containerThe container holding this object. May be null if this object is being removed from a container.

This is called from setIndex when we have a private store to deal with.

Definition at line 96 of file AuxElement.cxx.

98 {
99  if (hadPrivateData()) {
100  // We had a private store, but it was released because we were added
101  // to a container.
102 
103  if (container == 0) {
104  // We're being moved out of the container. Make a new private
105  // store, copy the data, and switch to it.
106  auto privateData = new SG::AuxElementPrivateData;
107  AuxElement to (privateData, 0);
108  to.copyAux (*this);
111  m_container = privateData;
112  return true;
113  }
114  }
115  else if (havePrivateData() &&
116  typeid(*m_container) == typeid(AuxElementPrivateData))
117  {
118  // We currently have a private store.
119 
120  if (container != 0 && container != m_container) {
121  // We're being added to a container.
122  // Aux data has already been copied.
123  // Release private store.
126  delete m_container;
128  return false;
129  }
130  }
131  else {
132  // We have a standalone store.
133  throw SG::ExcBadPrivateStore ("Attempt to add/remove a standalone object "
134  "from a container.");
135  }
136 
139  return false;
140 }

◆ setNoPrivateData()

void SG::IAuxElement::setNoPrivateData ( )
privateinherited

Record that this element does not have private data.

Friends And Related Function Documentation

◆ AuxElement

friend class AuxElement
friend

Definition at line 255 of file AuxElement.h.

◆ SG::AuxVectorBase

friend class SG::AuxVectorBase
friend

Definition at line 256 of file AuxElement.h.

Member Data Documentation

◆ m_container

const SG::AuxVectorData* SG::ConstAuxElement::m_container
private

The container of which this object is an element.

Should be null if this object is not within a container, except that it may also point at a private store.

Definition at line 298 of file AuxElement.h.

◆ m_index

size_t SG::IAuxElement::m_index
privateinherited

The index of this element within its container.

Should be 0 if this object is not within a container.

Definition at line 128 of file IAuxElement.h.

◆ m_privateStoreState

PrivateStoreState SG::IAuxElement::m_privateStoreState
privateinherited

Definition at line 137 of file IAuxElement.h.


The documentation for this class was generated from the following files:
SG::AuxVectorData::getConstStore
const SG::IConstAuxStore * getConstStore() const
Return the current store, as a const interface.
SG::ConstAuxElement::AuxElement
friend class AuxElement
Definition: AuxElement.h:255
SG::ConstAuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
index
Definition: index.py:1
SG::ConstAuxElement::m_container
const SG::AuxVectorData * m_container
The container of which this object is an element.
Definition: AuxElement.h:298
SG::AuxVectorData::getAuxIDs
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items in store associated with this object.
Definition: AuxVectorData.cxx:201
SG::IAuxElement::setHadPrivateData
void setHadPrivateData()
Record that this element used to have private data.
SG::IAuxElement::havePrivateData
bool havePrivateData() const
True if this element currently has private data.
SG::AuxElementPrivateData
Internal data container for private store.
Definition: AuxElement.cxx:45
SG::IAuxElement::setHavePrivateData
void setHavePrivateData()
Record that this element currently has private data.
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:32
SG::IAuxElement::setIndex
void setIndex(size_t index)
Set the index of this element within its container.
SG::ExcBadPrivateStore
Exception — Bad use of private store.
Definition: Control/AthContainers/AthContainers/exceptions.h:113
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
SG::IAuxElement::hadPrivateData
bool hadPrivateData() const
True if this element had private data before it was added to its current container.
SG::IConstAuxStore::getAuxIDs
virtual const SG::auxid_set_t & getAuxIDs() const =0
Return a set of identifiers for existing data items in this store.