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

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

#include <IAuxTypeVector.h>

Inheritance diagram for SG::IAuxTypeVector:
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 *beg, void *end, 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...
 

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...
 

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 39 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 47 of file IAuxTypeVector.h.

48  : m_auxid (auxid),
50  {}

◆ ~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 227 of file IAuxTypeVector.h.

228  {
229  return m_auxid;
230  }

◆ clone()

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

◆ insertMove()

virtual bool SG::IAuxTypeVector::insertMove ( size_t  pos,
void *  beg,
void *  end,
IAuxStore srcStore 
)
pure virtual

Insert elements into the vector via move semantics.

Parameters
posThe starting index of the insertion.
begStart of the range of elements to insert.
endEnd of the range 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 beg:end 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 >, and SG::AuxTypeVectorHolder< T, std::vector< T > >.

◆ 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 221 of file IAuxTypeVector.h.

221 { 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 212 of file IAuxTypeVector.h.

212 { 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 197 of file IAuxTypeVector.h.

197 { return 0; }

◆ reserve()

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

Change the capacity of the vector.

Parameters
szThe new vector capacity.

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

◆ 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< T, std::vector< T > >, SG::RootAuxVector, xAOD::TAuxVector, and xAOD::AuxPersInfo< T >.

◆ setOption()

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

Set an option for this variable.

Parameters
optionThe option to set.

The interpretation of the option depends on the particular representation of the variable provided by the concrete class.

Returns true if the option setting was successful; false otherwise.

Reimplemented in SG::AuxTypeVectorHolder< T, CONT >, and SG::AuxTypeVectorHolder< T, std::vector< T > >.

Definition at line 167 of file IAuxTypeVector.h.

168  { return false; }

◆ 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< T, std::vector< T > >, SG::RootAuxVector, and xAOD::TAuxVector.

◆ size()

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

◆ 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 >, and SG::AuxTypeVectorHolder< T, std::vector< T > >.

Definition at line 183 of file IAuxTypeVector.h.

183 { 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

◆ 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 235 of file IAuxTypeVector.h.

◆ m_isLinked

bool SG::IAuxTypeVector::m_isLinked
private

True if this variable is linked from another one.

Definition at line 238 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:221
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:227
SG::IAuxTypeVector::m_auxid
auxid_t m_auxid
The auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:235
SG::IAuxTypeVector::m_isLinked
bool m_isLinked
True if this variable is linked from another one.
Definition: IAuxTypeVector.h:238