ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SG::IAuxTypeVector Class Referenceabstract

Abstract interface for manipulating vectors of arbitrary types. More...

#include <IAuxTypeVector.h>

Inherited by SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, SG::AuxTypeVectorHolder< T, CONT >, SG::RootAuxVector, xAOD::AuxPersInfo< T >, and xAOD::TAuxVector.

Collaboration diagram for SG::IAuxTypeVector:

Public Member Functions

 IAuxTypeVector (auxid_t auxid, bool isLinked)
 Constructor. More...
 
virtual ~IAuxTypeVector ()=default
 Destructor. More...
 
virtual std::unique_ptr< IAuxTypeVectorclone () const =0
 Make a copy of this vector. More...
 
virtual void * toPtr ()=0
 Return a pointer to the start of the vector's data. More...
 
virtual const void * toPtr () const =0
 Return a pointer to the start of the vector's data. More...
 
virtual void * toVector ()=0
 Return a pointer to the STL vector itself. More...
 
virtual size_t size () const =0
 Return the size of the vector. More...
 
virtual bool resize (size_t sz)=0
 Change the size of the vector. More...
 
virtual void reserve (size_t sz)=0
 Change the capacity of the vector. More...
 
virtual bool shift (size_t pos, ptrdiff_t offs)=0
 Shift the elements of the vector. More...
 
virtual bool insertMove (size_t pos, void *src, size_t src_pos, size_t src_n, IAuxStore &srcStore)=0
 Insert elements into the vector via move semantics. More...
 
virtual bool setOption (const AuxDataOption &)
 Set an option for this variable. More...
 
virtual std::unique_ptr< IAuxTypeVectortoPacked ()
 Make a packed version of the variable. More...
 
virtual const std::type_info * objType () const
 Return the type of the complete object to be saved. More...
 
virtual std::unique_ptr< IAuxTypeVectorlinkedVector ()
 Return IAuxTypeVector of a linked variable, if there is one. More...
 
bool isLinked () const
 Return true if this variable is linked from another one. More...
 
auxid_t auxid () const
 Return the auxid of the variable this vector represents. More...
 
const AuxDataSpanBasegetDataSpan () const
 Return a reference to a description of this vector's start+size. More...
 

Protected Member Functions

virtual AuxDataSpanBase getDataSpanImpl () const =0
 Return a span object describing the current vector. More...
 
void storeDataSpan (void *beg, size_t size)
 Update the stored span. More...
 
void resetDataSpan ()
 Invalidate the stored span. More...
 

Private Attributes

auxid_t m_auxid
 The auxid of the variable this vector represents. More...
 
bool m_isLinked
 True if this variable is linked from another one. More...
 
CxxUtils::CachedValue< AuxDataSpanBasem_span
 Description of the vector start+size. More...
 

Detailed Description

Abstract interface for manipulating vectors of arbitrary types.

The auxiliary data for a container are stored in a set of STL vectors, one for each data item. However, we want to allow storing arbitrary types in these vectors. Thus, we define this abstract interface to operate on the vectors. The concrete version of this will own one vector.

Definition at line 41 of file IAuxTypeVector.h.

Constructor & Destructor Documentation

◆ IAuxTypeVector()

SG::IAuxTypeVector::IAuxTypeVector ( auxid_t  auxid,
bool  isLinked 
)
inline

Constructor.

Parameters
auxidThe ID of the variable that this vector represents.
isLinkedTrue if this variable is linked from another one.

Definition at line 49 of file IAuxTypeVector.h.

50  : m_auxid (auxid),
52  {
53  }

◆ ~IAuxTypeVector()

virtual SG::IAuxTypeVector::~IAuxTypeVector ( )
virtualdefault

Destructor.

Member Function Documentation

◆ auxid()

auxid_t SG::IAuxTypeVector::auxid ( ) const
inline

Return the auxid of the variable this vector represents.

Definition at line 232 of file IAuxTypeVector.h.

233  {
234  return m_auxid;
235  }

◆ clone()

virtual std::unique_ptr<IAuxTypeVector> SG::IAuxTypeVector::clone ( ) const
pure virtual

◆ getDataSpan()

const AuxDataSpanBase& SG::IAuxTypeVector::getDataSpan ( ) const
inline

Return a reference to a description of this vector's start+size.

This returns a reference to an AuxDataSpanBase, which gives the start and size of the vector. This object will be updated if the vector changes.

For low overhead, we want this to be a non-virtual function call. However, for variables being read, the usage pattern is that we first create the @IAuxTypeVector object, give the underlying std::vector object to ROOT, and then ROOT fills the vector without the involvement of the IAuxTypeVector. To be able to have this work correctly, we need to defer initializing the span object until the first time that getDataSpan gets called. We do this with a CachedValue. If the span has already been initialized, we just return it; otherwise, we make a virtual call to fetch the vector from the derived class.

Be aware: this is in principle a const-correctness violation, since AuxDataSpanBase has a non-const pointer to the start of the vector. But doing it properly is kind of painful, and as this interface is only meant to be used internally, it's likely not a real problem.

Definition at line 261 of file IAuxTypeVector.h.

262  {
263  if (!m_span.isValid()) {
264  m_span.set (this->getDataSpanImpl());
265  }
266  return *m_span.ptr();
267  }

◆ getDataSpanImpl()

virtual AuxDataSpanBase SG::IAuxTypeVector::getDataSpanImpl ( ) const
protectedpure virtual

Return a span object describing the current vector.

Used to initialize m_span the first time that getDataSpan is called.

Implemented in SG::AuxTypeVectorHolder< T, CONT >, SG::RootAuxVector, xAOD::AuxPersInfo< T >, and xAOD::TAuxVector.

◆ insertMove()

virtual bool SG::IAuxTypeVector::insertMove ( size_t  pos,
void *  src,
size_t  src_pos,
size_t  src_n,
IAuxStore srcStore 
)
pure virtual

Insert elements into the vector via move semantics.

Parameters
posThe starting index of the insertion.
srcStart of the vector containing the range of elements to insert.
src_posPosition of the first element to insert.
src_nNumber of elements to insert.
srcStoreThe source store.

beg and end define a range of container elements, with length len defined by the difference of the pointers divided by the element size.

The size of the container will be increased by len, with the elements starting at pos copied to pos+len.

The contents of the source range will then be moved to our vector starting at pos. This will be done via move semantics if possible; otherwise, it will be done with a copy.

Returns true if it is known that the vector's memory did not move, false otherwise.

Implemented in xAOD::AuxPersInfo< T >, SG::RootAuxVector, xAOD::TAuxVector, SG::AuxTypeVectorHolder< T, CONT >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >, SG::PackedLinkVVectorHolder< CONT, VALLOC, VELT, ALLOC >, SG::PackedLinkVVectorHolder< TARG, VALLOC, std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >, SG::JaggedVecVectorHolder< T, ALLOC >, SG::JaggedVecVectorHolder< T, VEC::allocator_type >, SG::PackedLinkVectorHolder< CONT, ALLOC >, and SG::PackedLinkVectorHolder< TARG, VEC::allocator_type >.

◆ isLinked()

bool SG::IAuxTypeVector::isLinked ( ) const
inline

Return true if this variable is linked from another one.

This is inlined here rather than being a virtual function because this is frequently called from loops over auxids.

Definition at line 226 of file IAuxTypeVector.h.

226 { return m_isLinked; }

◆ linkedVector()

virtual std::unique_ptr<IAuxTypeVector> SG::IAuxTypeVector::linkedVector ( )
inlinevirtual

Return IAuxTypeVector of a linked variable, if there is one.

If the variable represented by this vector has a linked variable, then return its IAuxTypeVector. Otherwise, return nullptr. Beware of potential threading issues: the returned object is not locked, so it should not be modified in contexts where the parent container cannot be modified.

This returns a unique_ptr, so it can generally be called only once on a given instance. After that, it will return nullptr.

Definition at line 217 of file IAuxTypeVector.h.

217 { return nullptr; }

◆ objType()

virtual const std::type_info* SG::IAuxTypeVector::objType ( ) const
inlinevirtual

Return the type of the complete object to be saved.

For example, if the object is a std::vector, then we return the type_info of the vector. But if we're holding a PackedContainer, then we return the type_info of the PackedContainer.

Can return null if the operation is not supported. In that case, I/O will use the type found from the variable registry.

Reimplemented in SG::RootAuxVector, SG::AuxTypeVectorHolder< T, CONT >, and xAOD::AuxPersInfo< T >.

Definition at line 202 of file IAuxTypeVector.h.

202 { return 0; }

◆ reserve()

virtual void SG::IAuxTypeVector::reserve ( size_t  sz)
pure virtual

◆ resetDataSpan()

void SG::IAuxTypeVector::resetDataSpan ( )
inlineprotected

Invalidate the stored span.

Definition at line 297 of file IAuxTypeVector.h.

298  {
299  m_span.reset();
300  }

◆ resize()

virtual bool SG::IAuxTypeVector::resize ( size_t  sz)
pure virtual

Change the size of the vector.

Parameters
szThe new vector size. Returns true if it is known that iterators have not been invalidated; false otherwise. (Will always return false when increasing the size of an empty container.)

Implemented in SG::AuxTypeVectorHolder< T, CONT >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >, SG::RootAuxVector, SG::JaggedVecVectorHolder< T, ALLOC >, SG::JaggedVecVectorHolder< T, VEC::allocator_type >, xAOD::TAuxVector, and xAOD::AuxPersInfo< T >.

◆ setOption()

virtual bool SG::IAuxTypeVector::setOption ( const AuxDataOption )
inlinevirtual

◆ shift()

virtual bool SG::IAuxTypeVector::shift ( size_t  pos,
ptrdiff_t  offs 
)
pure virtual

Shift the elements of the vector.

Parameters
posThe starting index for the shift.
offsThe (signed) amount of the shift.

This operation shifts the elements in the vectors for all aux data items, to implement an insertion or deletion. offs may be either positive or negative.

If offs is positive, then the container is growing. The container size should be increased by offs, the element at pos moved to pos + offs, and similarly for following elements. The elements between pos and pos + offs should be default-initialized.

If offs is negative, then the container is shrinking. The element at pos should be moved to pos + offs, and similarly for following elements. The container should then be shrunk by -offs elements (running destructors as appropriate).

Returns true if it is known that iterators have not been invalidated; false otherwise. (Will always return false when increasing the size of an empty container.)

Implemented in xAOD::AuxPersInfo< T >, SG::AuxTypeVectorHolder< T, CONT >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >, SG::RootAuxVector, SG::JaggedVecVectorHolder< T, ALLOC >, SG::JaggedVecVectorHolder< T, VEC::allocator_type >, and xAOD::TAuxVector.

◆ size()

virtual size_t SG::IAuxTypeVector::size ( ) const
pure virtual

◆ storeDataSpan()

void SG::IAuxTypeVector::storeDataSpan ( void *  beg,
size_t  size 
)
inlineprotected

Update the stored span.

Parameters
begThe start of the vector.
sizeThe length of the vector.

Definition at line 284 of file IAuxTypeVector.h.

285  {
286  // Only do this if the span is already valid, so that it doesn't
287  // get marked valid before ROOT I/O.
288  if (m_span.isValid()) {
289  m_span.store (AuxDataSpanBase (beg, size));
290  }
291  }

◆ toPacked()

virtual std::unique_ptr<IAuxTypeVector> SG::IAuxTypeVector::toPacked ( )
inlinevirtual

Make a packed version of the variable.

If possible, return a new vector object that stores the data in a PackedContainer. The data itself should be moved to the new container (so that this vector becomes empty). This ensures that pointers to the data are preserved.

If successful, a newly-allocated object is returned. A null pointer is returned on failure (operation not supported, type can't be packed, type is already packed).

Reimplemented in SG::AuxTypeVectorHolder< T, CONT >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, and SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >.

Definition at line 188 of file IAuxTypeVector.h.

188 { return 0; }

◆ toPtr() [1/2]

virtual const void* SG::IAuxTypeVector::toPtr ( ) const
pure virtual

Return a pointer to the start of the vector's data.

Implemented in SG::AuxTypeVectorHolder< T, CONT >, SG::RootAuxVector, xAOD::TAuxVector, and xAOD::AuxPersInfo< T >.

◆ toPtr() [2/2]

virtual void* SG::IAuxTypeVector::toPtr ( )
pure virtual

Return a pointer to the start of the vector's data.

Implemented in SG::AuxTypeVectorHolder< T, CONT >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >, SG::RootAuxVector, xAOD::TAuxVector, xAOD::AuxPersInfo< T >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, and SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >.

◆ toVector()

virtual void* SG::IAuxTypeVector::toVector ( )
pure virtual

Member Data Documentation

◆ m_auxid

auxid_t SG::IAuxTypeVector::m_auxid
private

The auxid of the variable this vector represents.

Definition at line 305 of file IAuxTypeVector.h.

◆ m_isLinked

bool SG::IAuxTypeVector::m_isLinked
private

True if this variable is linked from another one.

Definition at line 308 of file IAuxTypeVector.h.

◆ m_span

CxxUtils::CachedValue<AuxDataSpanBase> SG::IAuxTypeVector::m_span
private

Description of the vector start+size.

Definition at line 311 of file IAuxTypeVector.h.


The documentation for this class was generated from the following file:
SG::IAuxTypeVector::isLinked
bool isLinked() const
Return true if this variable is linked from another one.
Definition: IAuxTypeVector.h:226
SG::IAuxTypeVector::m_span
CxxUtils::CachedValue< AuxDataSpanBase > m_span
Description of the vector start+size.
Definition: IAuxTypeVector.h:311
SG::IAuxTypeVector::getDataSpanImpl
virtual AuxDataSpanBase getDataSpanImpl() const =0
Return a span object describing the current vector.
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:232
SG::IAuxTypeVector::m_auxid
auxid_t m_auxid
The auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:305
SG::IAuxTypeVector::m_isLinked
bool m_isLinked
True if this variable is linked from another one.
Definition: IAuxTypeVector.h:308
SG::IAuxTypeVector::size
virtual size_t size() const =0
Return the size of the vector.