ATLAS Offline Software
Loading...
Searching...
No Matches
SG::JaggedVecVectorHolder< T, ALLOC > Class Template Reference

Implementation of IAuxTypeVector for JaggedVec types. More...

#include <JaggedVecVector.h>

Inheritance diagram for SG::JaggedVecVectorHolder< T, ALLOC >:
Collaboration diagram for SG::JaggedVecVectorHolder< T, ALLOC >:

Public Types

using vector_type = typename Base::vector_type
using element_type = typename Base::element_type
typedef vector_type::value_type vector_value_type
 Vector element type.

Public Member Functions

 JaggedVecVectorHolder (auxid_t auxid, vector_type *vecPtr, IAuxTypeVector *linkedVec, bool ownFlag)
 Constructor.
virtual bool resize (size_t sz) override
 Change the size of the vector.
virtual bool shift (size_t pos, ptrdiff_t offs) override
 Shift the elements of the vector.
virtual bool insertMove (size_t pos, void *src, size_t src_pos, size_t src_n, IAuxStore &srcStore) override
 Insert elements into the vector via move semantics.
vector_typevec ()
 Return a reference to the payload vector.
virtual std::unique_ptr< IAuxTypeVectorclone () const override
 Make a copy of this vector.
virtual void * toPtr () override
 Return a pointer to the start of the vector's data.
virtual const void * toPtr () const override
 Return a pointer to the start of the vector's data.
virtual void * toVector () override
 Return a pointer to the STL vector itself.
virtual const std::type_info * objType () const override
 Return the type of the payload object for this instance.
virtual size_t size () const override
 Return the size of the vector.
virtual void reserve (size_t sz) override
 Change the capacity of the vector.
virtual bool setOption (const AuxDataOption &option) override
 Make an option setting.
virtual std::unique_ptr< IAuxTypeVectortoPacked () override
 Try to convert this aux vector to a PackedContainer.
virtual std::unique_ptr< IAuxTypeVectorlinkedVector ()
 Return IAuxTypeVector of a linked variable, if there is one.
bool isLinked () const
 Return true if this variable is linked from another one.
auxid_t auxid () const
 Return the auxid of the variable this vector represents.
const AuxDataSpanBasegetDataSpan () const
 Return a reference to a description of this vector's start+size.

Protected Member Functions

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

Protected Attributes

IAuxTypeVectorm_linkedVec {}
 Interface for the linked vector of DataLinks.

Static Protected Attributes

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

Private Types

using Elt = JaggedVecElt<T>
using Shift = typename Elt::Shift
using index_type = typename Elt::index_type
using Base

Private Member Functions

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

Private Attributes

vector_typem_vecPtr
 The contained vector.
bool m_ownFlag
 True if we need to delete the object.
auxid_t m_auxid
 The auxid of the variable this vector represents.
bool m_isLinked
 True if this variable is linked from another one.
CxxUtils::CachedValue< AuxDataSpanBasem_span
 Description of the vector start+size.

Detailed Description

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
class SG::JaggedVecVectorHolder< T, ALLOC >

Implementation of IAuxTypeVector for JaggedVec types.

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

Here, T is type of the vector payload, and ALLOC is the allocator to use for the vector of JaggedVecElt.

Definition at line 39 of file JaggedVecVector.h.

Member Typedef Documentation

◆ Base

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
using SG::JaggedVecVectorHolder< T, ALLOC >::Base
private
Initial value:
std::vector< T, allocator_type > vector_type
Container type used to store this variable.
AuxTypeVectorHolder(auxid_t auxid, vector_type *vecPtr, bool ownFlag, bool isLinked)
Constructor.

Definition at line 46 of file JaggedVecVector.h.

◆ element_type

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
using SG::JaggedVecVectorHolder< T, ALLOC >::element_type = typename Base::element_type

Definition at line 54 of file JaggedVecVector.h.

◆ Elt

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
using SG::JaggedVecVectorHolder< T, ALLOC >::Elt = JaggedVecElt<T>
private

Definition at line 43 of file JaggedVecVector.h.

◆ index_type

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
using SG::JaggedVecVectorHolder< T, ALLOC >::index_type = typename Elt::index_type
private

Definition at line 45 of file JaggedVecVector.h.

◆ Shift

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
using SG::JaggedVecVectorHolder< T, ALLOC >::Shift = typename Elt::Shift
private

Definition at line 44 of file JaggedVecVector.h.

◆ vector_type

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
using SG::JaggedVecVectorHolder< T, ALLOC >::vector_type = typename Base::vector_type

Definition at line 53 of file JaggedVecVector.h.

◆ vector_value_type

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

Vector element type.

Definition at line 61 of file AuxTypeVector.h.

Constructor & Destructor Documentation

◆ JaggedVecVectorHolder()

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
SG::JaggedVecVectorHolder< T, ALLOC >::JaggedVecVectorHolder ( auxid_t auxid,
vector_type * vecPtr,
IAuxTypeVector * linkedVec,
bool ownFlag )

Constructor.

Parameters
auxidThe auxid of the variable this vector represents.
vecPtrPointer to the object.
linkedVecInterface for the linked payload vector.
ownFlagIf true, take ownership of the object.

Member Function Documentation

◆ auxid()

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

Return the auxid of the variable this vector represents.

Definition at line 232 of file IAuxTypeVector.h.

233 {
234 return m_auxid;
235 }
auxid_t m_auxid
The auxid of the variable this vector represents.

◆ clone()

◆ getDataSpan()

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

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 }
virtual AuxDataSpanBase getDataSpanImpl() const =0
Return a span object describing the current vector.
CxxUtils::CachedValue< AuxDataSpanBase > m_span
Description of the vector start+size.

◆ getDataSpanImpl()

template<class T, class CONT>
virtual AuxDataSpanBase SG::AuxTypeVectorHolder< T, CONT >::getDataSpanImpl ( ) const
finaloverrideprotectedvirtualinherited

Return a span object describing the current vector.

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

Implements SG::IAuxTypeVector.

◆ insertMove()

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
virtual bool SG::JaggedVecVectorHolder< T, ALLOC >::insertMove ( size_t pos,
void * src,
size_t src_pos,
size_t src_n,
IAuxStore & srcStore )
overridevirtual

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.

Reimplemented from SG::AuxTypeVectorHolder< T, CONT >.

◆ 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  )
privateinherited

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

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

226{ return m_isLinked; }
bool m_isLinked
True if this variable is linked from another one.

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

Reimplemented in SG::JaggedVecVectorT< JaggedVecVectorHolder< T, ALLOC > >, SG::PackedLinkVectorT< PackedLinkVectorHolder< CONT, ALLOC > >, and SG::PackedLinkVectorT< PackedLinkVVectorHolder< CONT, VALLOC, VELT, ALLOC > >.

Definition at line 217 of file IAuxTypeVector.h.

217{ return nullptr; }

◆ objType()

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

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.

◆ reserve()

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

Change the capacity of the vector.

Parameters
szThe new vector capacity.

Implements SG::IAuxTypeVector.

◆ resetDataSpan()

void SG::IAuxTypeVector::resetDataSpan ( )
inlineprotectedinherited

Invalidate the stored span.

Definition at line 297 of file IAuxTypeVector.h.

298 {
299 m_span.reset();
300 }

◆ resize()

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
virtual bool SG::JaggedVecVectorHolder< T, ALLOC >::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.)

Reimplemented from SG::AuxTypeVectorHolder< T, CONT >.

◆ setOption()

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

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 ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
virtual bool SG::JaggedVecVectorHolder< T, ALLOC >::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.)

Reimplemented from SG::AuxTypeVectorHolder< T, CONT >.

◆ size()

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

Return the size of the vector.

Implements SG::IAuxTypeVector.

◆ storeDataSpan() [1/2]

template<class T, class CONT>
void SG::AuxTypeVectorHolder< T, CONT >::storeDataSpan ( )
protectedinherited

Update the stored span.

◆ storeDataSpan() [2/2]

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

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 }
virtual size_t size() const =0
Return the size of the vector.

◆ toPacked()

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

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
overridevirtualinherited

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

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

Return a pointer to the STL vector itself.

Implements SG::IAuxTypeVector.

◆ vec()

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

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

◆ m_isLinked

bool SG::IAuxTypeVector::m_isLinked
privateinherited

True if this variable is linked from another one.

Definition at line 308 of file IAuxTypeVector.h.

◆ m_linkedVec

template<class T, class ALLOC = AuxAllocator_t<JaggedVecElt<T> >>
IAuxTypeVector* SG::JaggedVecVectorHolder< T, ALLOC >::m_linkedVec {}
protected

Interface for the linked vector of DataLinks.

Definition at line 138 of file JaggedVecVector.h.

138{};

◆ m_ownFlag

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

True if we need to delete the object.

Definition at line 303 of file AuxTypeVector.h.

◆ m_span

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

Description of the vector start+size.

Definition at line 311 of file IAuxTypeVector.h.

◆ m_vecPtr

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

The contained vector.

Definition at line 300 of file AuxTypeVector.h.

◆ SCALE

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

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

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

Definition at line 67 of file AuxTypeVector.h.


The documentation for this class was generated from the following file: