ATLAS Offline Software
Public Types | Public Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
SG::AuxTypeVectorHolder< T, CONT > Class Template Reference

Implementation of IAuxTypeVector for specific types. More...

#include <AuxTypeVector.h>

Inheritance diagram for SG::AuxTypeVectorHolder< T, CONT >:
Collaboration diagram for SG::AuxTypeVectorHolder< T, CONT >:

Public Types

typedef CONT vector_type
 Type of the STL vector used for storage. More...
 
typedef AuxDataTraits< T >::element_type element_type
 Type that the user sees. More...
 
typedef vector_type::value_type vector_value_type
 Vector element type. More...
 

Public Member Functions

 AuxTypeVectorHolder (auxid_t auxid, vector_type *vecPtr, bool ownFlag, bool isLinked)
 Constructor. More...
 
 ~AuxTypeVectorHolder ()
 Destructor. More...
 
 AuxTypeVectorHolder (const AuxTypeVectorHolder &other)
 Copy constructor. More...
 
 AuxTypeVectorHolder (AuxTypeVectorHolder &&other)
 Move constructor. More...
 
AuxTypeVectorHolderoperator= (const AuxTypeVectorHolder &other)
 Assignment. More...
 
AuxTypeVectorHolderoperator= (AuxTypeVectorHolder &&other)
 Move assignment. More...
 
vector_typevec ()
 Return a reference to the payload vector. More...
 
virtual std::unique_ptr< IAuxTypeVectorclone () const override
 Make a copy of this vector. More...
 
virtual void * toPtr () override
 Return a pointer to the start of the vector's data. More...
 
virtual const void * toPtr () const override
 Return a pointer to the start of the vector's data. More...
 
virtual void * toVector () override
 Return a pointer to the STL vector itself. More...
 
virtual const std::type_info * objType () const override
 Return the type of the payload object for this instance. More...
 
virtual size_t size () const override
 Return the size of the vector. More...
 
virtual bool resize (size_t sz) override
 Change the size of the vector. More...
 
virtual void reserve (size_t sz) override
 Change the capacity of the vector. More...
 
virtual bool setOption (const AuxDataOption &option) override
 Make an option setting. More...
 
virtual bool shift (size_t pos, ptrdiff_t offs) override
 Shift the elements of the vector. More...
 
virtual bool insertMove (size_t pos, void *beg, void *end, IAuxStore &srcStore) override
 Insert elements into the vector via move semantics. More...
 
virtual std::unique_ptr< IAuxTypeVectortoPacked () override
 Try to convert this aux vector to a PackedContainer. 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...
 

Static Protected Attributes

static const int SCALE = sizeof(element_type) / sizeof(vector_value_type)
 1 for the usual case of V being vector<T>. More...
 

Private Member Functions

void insertMove1 (typename CONT::iterator pos, element_type *beg, element_type *end, std::true_type)
 Helper for insertMove. More...
 
void insertMove1 (typename CONT::iterator pos, element_type *beg, element_type *end, std::false_type)
 Helper for insertMove. More...
 

Private Attributes

vector_typem_vecPtr
 The contained vector. More...
 
bool m_ownFlag
 True if we need to delete the object. More...
 
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

template<class T, class CONT>
class SG::AuxTypeVectorHolder< T, CONT >

Implementation of IAuxTypeVector for specific types.

The auxiliary data for a container is 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. This template class provides the concrete implementations of this interface.

This class is initialized with a pointer to the actual vector. For a version that holds the vector internally, see the derived class AuxTypeVector.

Definition at line 49 of file AuxTypeVector.h.

Member Typedef Documentation

◆ element_type

template<class T , class CONT >
typedef AuxDataTraits<T>::element_type SG::AuxTypeVectorHolder< T, CONT >::element_type

Type that the user sees.

Definition at line 57 of file AuxTypeVector.h.

◆ vector_type

template<class T , class CONT >
typedef CONT SG::AuxTypeVectorHolder< T, CONT >::vector_type

Type of the STL vector used for storage.

Definition at line 54 of file AuxTypeVector.h.

◆ vector_value_type

template<class T , class CONT >
typedef vector_type::value_type SG::AuxTypeVectorHolder< T, CONT >::vector_value_type

Vector element type.

Definition at line 60 of file AuxTypeVector.h.

Constructor & Destructor Documentation

◆ AuxTypeVectorHolder() [1/3]

template<class T , class CONT >
SG::AuxTypeVectorHolder< T, CONT >::AuxTypeVectorHolder ( auxid_t  auxid,
vector_type vecPtr,
bool  ownFlag,
bool  isLinked 
)

Constructor.

Parameters
auxidThe auxid of the variable this vector represents.
vecPtrPointer to the object (of type CONT).
ownFlagIf true, take ownership of the object.
isLinkedTrue if this variable is linked from another one.

◆ ~AuxTypeVectorHolder()

template<class T , class CONT >
SG::AuxTypeVectorHolder< T, CONT >::~AuxTypeVectorHolder ( )

Destructor.

If ownFlag was true, then delete the vector object.

◆ AuxTypeVectorHolder() [2/3]

template<class T , class CONT >
SG::AuxTypeVectorHolder< T, CONT >::AuxTypeVectorHolder ( const AuxTypeVectorHolder< T, CONT > &  other)

Copy constructor.

Parameters
otherObject to copy.

◆ AuxTypeVectorHolder() [3/3]

template<class T , class CONT >
SG::AuxTypeVectorHolder< T, CONT >::AuxTypeVectorHolder ( AuxTypeVectorHolder< T, CONT > &&  other)

Move constructor.

Parameters
otherObject to move.

Member Function Documentation

◆ auxid()

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

Return the auxid of the variable this vector represents.

Definition at line 227 of file IAuxTypeVector.h.

228  {
229  return m_auxid;
230  }

◆ clone()

template<class T , class CONT >
virtual std::unique_ptr<IAuxTypeVector> SG::AuxTypeVectorHolder< T, CONT >::clone ( ) const
overridevirtual

Make a copy of this vector.

Implements SG::IAuxTypeVector.

◆ insertMove()

template<class T , class CONT >
virtual bool SG::AuxTypeVectorHolder< T, CONT >::insertMove ( size_t  pos,
void *  beg,
void *  end,
IAuxStore srcStore 
)
overridevirtual

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.

Implements SG::IAuxTypeVector.

◆ insertMove1() [1/2]

template<class T , class CONT >
void SG::AuxTypeVectorHolder< T, CONT >::insertMove1 ( typename CONT::iterator  pos,
element_type beg,
element_type end,
std::false_type   
)
private

Helper for insertMove.

Parameters
posThe starting index of the insertion.
begStart of the range of elements to insert.
endEnd of the range of elements to insert.

This does the actual move for non-POD types.

◆ insertMove1() [2/2]

template<class T , class CONT >
void SG::AuxTypeVectorHolder< T, CONT >::insertMove1 ( typename CONT::iterator  pos,
element_type beg,
element_type end,
std::true_type   
)
private

Helper for insertMove.

Parameters
posThe starting index of the insertion.
begStart of the range of elements to insert.
endEnd of the range of elements to insert.

This does the actual move for POD types.

◆ isLinked()

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

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 ( )
inlinevirtualinherited

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()

template<class T , class CONT >
virtual const std::type_info* SG::AuxTypeVectorHolder< T, CONT >::objType ( ) const
overridevirtual

Return the type of the payload object for this instance.

May be different from what we get from the registry; if packing is used, for example.

Reimplemented from SG::IAuxTypeVector.

◆ operator=() [1/2]

template<class T , class CONT >
AuxTypeVectorHolder& SG::AuxTypeVectorHolder< T, CONT >::operator= ( AuxTypeVectorHolder< T, CONT > &&  other)

Move assignment.

◆ operator=() [2/2]

template<class T , class CONT >
AuxTypeVectorHolder& SG::AuxTypeVectorHolder< T, CONT >::operator= ( const AuxTypeVectorHolder< T, CONT > &  other)

Assignment.

◆ reserve()

template<class T , class CONT >
virtual void SG::AuxTypeVectorHolder< T, CONT >::reserve ( size_t  sz)
overridevirtual

Change the capacity of the vector.

Parameters
szThe new vector capacity.

Implements SG::IAuxTypeVector.

◆ resize()

template<class T , class CONT >
virtual bool SG::AuxTypeVectorHolder< T, CONT >::resize ( size_t  sz)
overridevirtual

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

Implements SG::IAuxTypeVector.

◆ setOption()

template<class T , class CONT >
virtual bool SG::AuxTypeVectorHolder< T, CONT >::setOption ( const AuxDataOption option)
overridevirtual

Make an option setting.

Parameters
optionThe option to set.

The interpretation of the option depends on the concrete class.

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

Reimplemented from SG::IAuxTypeVector.

◆ shift()

template<class T , class CONT >
virtual bool SG::AuxTypeVectorHolder< T, CONT >::shift ( size_t  pos,
ptrdiff_t  offs 
)
overridevirtual

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

Implements SG::IAuxTypeVector.

◆ size()

template<class T , class CONT >
virtual size_t SG::AuxTypeVectorHolder< T, CONT >::size ( ) const
overridevirtual

Return the size of the vector.

Implements SG::IAuxTypeVector.

◆ toPacked()

template<class T , class CONT >
virtual std::unique_ptr<IAuxTypeVector> SG::AuxTypeVectorHolder< T, CONT >::toPacked ( )
overridevirtual

Try to convert this aux vector to a PackedContainer.

If successful, returns a newly-allocated IAuxTypeVector. In this case, the contents of the vector will have been moved to the new vector (and this object will be empty).

Returns null on failure.

Reimplemented from SG::IAuxTypeVector.

◆ toPtr() [1/2]

template<class T , class CONT >
virtual const void* SG::AuxTypeVectorHolder< T, CONT >::toPtr ( ) const
overridevirtual

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

Implements SG::IAuxTypeVector.

◆ toPtr() [2/2]

template<class T , class CONT >
virtual void* SG::AuxTypeVectorHolder< T, CONT >::toPtr ( )
overridevirtual

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

Implements SG::IAuxTypeVector.

◆ toVector()

template<class T , class CONT >
virtual void* SG::AuxTypeVectorHolder< T, CONT >::toVector ( )
overridevirtual

Return a pointer to the STL vector itself.

Implements SG::IAuxTypeVector.

◆ vec()

template<class T , class CONT >
vector_type& SG::AuxTypeVectorHolder< T, CONT >::vec ( )

Return a reference to the payload vector.

Member Data Documentation

◆ m_auxid

auxid_t SG::IAuxTypeVector::m_auxid
privateinherited

The auxid of the variable this vector represents.

Definition at line 235 of file IAuxTypeVector.h.

◆ m_isLinked

bool SG::IAuxTypeVector::m_isLinked
privateinherited

True if this variable is linked from another one.

Definition at line 238 of file IAuxTypeVector.h.

◆ m_ownFlag

template<class T , class CONT >
bool SG::AuxTypeVectorHolder< T, CONT >::m_ownFlag
private

True if we need to delete the object.

Definition at line 285 of file AuxTypeVector.h.

◆ m_vecPtr

template<class T , class CONT >
vector_type* SG::AuxTypeVectorHolder< T, CONT >::m_vecPtr
private

The contained vector.

Definition at line 282 of file AuxTypeVector.h.

◆ SCALE

template<class T , class CONT >
const int SG::AuxTypeVectorHolder< T, CONT >::SCALE = sizeof(element_type) / sizeof(vector_value_type)
staticprotected

1 for the usual case of V being vector<T>.

If V is vector<char>, then this is sizeof(T).

Definition at line 66 of file AuxTypeVector.h.


The documentation for this class was generated from the following file:
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