ATLAS Offline Software
|
Implementation of IAuxTypeVector
for PackedLink
types.
More...
#include <PackedLinkVector.h>
Public Types | |
using | vector_type = typename Base::vector_type |
using | element_type = typename Base::element_type |
using | Helper = detail::PackedLinkVectorHelper< CONT > |
Helper for manipulating PackedLink instances. More... | |
typedef vector_type::value_type | vector_value_type |
Vector element type. More... | |
Public Member Functions | |
PackedLinkVectorHolder (auxid_t auxid, vector_type *vecPtr, IAuxTypeVector *linkedVec, bool ownFlag) | |
Constructor. More... | |
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. More... | |
vector_type & | vec () |
Return a reference to the payload vector. More... | |
virtual std::unique_ptr< IAuxTypeVector > | clone () const override |
Make a copy of this vector. More... | |
virtual std::unique_ptr< IAuxTypeVector > | clone () const =0 |
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 const void * | toPtr () const =0 |
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 const std::type_info * | objType () const |
Return the type of the complete object to be saved. More... | |
virtual size_t | size () const override |
Return the size of the vector. More... | |
virtual size_t | size () const =0 |
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 std::unique_ptr< IAuxTypeVector > | toPacked () override |
Try to convert this aux vector to a PackedContainer . More... | |
virtual std::unique_ptr< IAuxTypeVector > | linkedVector () |
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 AuxDataSpanBase & | getDataSpan () const |
Return a reference to a description of this vector's start+size. More... | |
Protected Member Functions | |
virtual AuxDataSpanBase | getDataSpanImpl () const override final |
Return a span object describing the current vector. More... | |
virtual AuxDataSpanBase | getDataSpanImpl () const =0 |
Return a span object describing the current vector. More... | |
void | storeDataSpan () |
Update the stored span. More... | |
void | storeDataSpan (void *beg, size_t size) |
Update the stored span. More... | |
void | resetDataSpan () |
Invalidate the stored span. More... | |
Protected Attributes | |
IAuxTypeVector * | m_linkedVec {} |
Interface for the linked vector of DataLinks. More... | |
Static Protected Attributes | |
static const int | SCALE |
1 for the usual case of V being vector<T> . More... | |
Private Types | |
using | Base = AuxTypeVectorHolder< PackedLink< CONT >, typename AuxDataTraits< PackedLink< CONT >, ALLOC >::vector_type > |
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_type * | m_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... | |
CxxUtils::CachedValue< AuxDataSpanBase > | m_span |
Description of the vector start+size. More... | |
Implementation of IAuxTypeVector
for PackedLink
types.
This class is initialized with a pointer to the actual vector. For a version that holds the vector internally, see the derived class PackedLinkVector
.
Here, CONT
is the target container of the links, and ALLOC
is the allocator to use for the vector of PackedLink
.
Definition at line 40 of file PackedLinkVector.h.
|
private |
Definition at line 44 of file PackedLinkVector.h.
using SG::PackedLinkVectorHolder< CONT, ALLOC >::element_type = typename Base::element_type |
Definition at line 52 of file PackedLinkVector.h.
using SG::PackedLinkVectorHolder< CONT, ALLOC >::Helper = detail::PackedLinkVectorHelper<CONT> |
Helper for manipulating PackedLink
instances.
Definition at line 56 of file PackedLinkVector.h.
using SG::PackedLinkVectorHolder< CONT, ALLOC >::vector_type = typename Base::vector_type |
Definition at line 51 of file PackedLinkVector.h.
|
inherited |
Vector element type.
Definition at line 61 of file AuxTypeVector.h.
SG::PackedLinkVectorHolder< CONT, ALLOC >::PackedLinkVectorHolder | ( | auxid_t | auxid, |
vector_type * | vecPtr, | ||
IAuxTypeVector * | linkedVec, | ||
bool | ownFlag | ||
) |
Constructor.
auxid | The auxid of the variable this vector represents. |
vecPtr | Pointer to the object. |
linkedVec | Interface for the linked vector of DataLinks. |
ownFlag | If true, take ownership of the object. |
|
inlineinherited |
Return the auxid of the variable this vector represents.
Definition at line 232 of file IAuxTypeVector.h.
|
pure virtualinherited |
Make a copy of this vector.
Implemented in SG::AuxTypeVectorHolder< T, CONT >, SG::RootAuxVector, xAOD::AuxPersVector< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC >, xAOD::TAuxVector, xAOD::AuxPersVector< SG::PackedLink< TARG >, VEC >, xAOD::AuxPersInfo< T >, xAOD::AuxPersVector< SG::JaggedVecElt< T >, VEC >, and xAOD::AuxPersVector< T, VEC >.
|
overridevirtualinherited |
Make a copy of this vector.
|
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.
|
protectedpure virtualinherited |
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.
|
finaloverrideprotectedvirtualinherited |
Return a span object describing the current vector.
Used to initialize m_span
the first time that getDataSpan
is called.
|
overridevirtual |
Insert elements into the vector via move semantics.
pos | The starting index of the insertion. |
src | Start of the vector containing the range of elements to insert. |
src_pos | Position of the first element to insert. |
src_n | Number of elements to insert. |
srcStore | The 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< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >.
|
privateinherited |
Helper for insertMove
.
pos | The starting index of the insertion. |
beg | Start of the range of elements to insert. |
end | End of the range of elements to insert. |
This does the actual move for non-POD types.
|
privateinherited |
Helper for insertMove
.
pos | The starting index of the insertion. |
beg | Start of the range of elements to insert. |
end | End of the range of elements to insert. |
This does the actual move for POD types.
|
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.
|
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 217 of file IAuxTypeVector.h.
|
inlinevirtualinherited |
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.
|
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.
|
overridevirtualinherited |
Change the capacity of the vector.
sz | The new vector capacity. |
Implements SG::IAuxTypeVector.
|
inlineprotectedinherited |
Invalidate the stored span.
Definition at line 297 of file IAuxTypeVector.h.
|
overridevirtualinherited |
Change the size of the vector.
sz | The 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.
|
overridevirtualinherited |
Make an option setting.
option | The 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.
|
overridevirtualinherited |
Shift the elements of the vector.
pos | The starting index for the shift. |
offs | The (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.
|
pure virtualinherited |
Return the size of the vector.
Implemented in SG::AuxTypeVectorHolder< T, CONT >, SG::RootAuxVector, xAOD::TAuxVector, and xAOD::AuxPersInfo< T >.
|
overridevirtualinherited |
Return the size of the vector.
|
protectedinherited |
Update the stored span.
|
inlineprotectedinherited |
Update the stored span.
beg | The start of the vector. |
size | The length of the vector. |
Definition at line 284 of file IAuxTypeVector.h.
|
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.
|
pure virtualinherited |
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 >.
|
overridevirtualinherited |
Return a pointer to the start of the vector's data.
Implements SG::IAuxTypeVector.
|
overridevirtualinherited |
Return a pointer to the start of the vector's data.
Implements SG::IAuxTypeVector.
|
overridevirtualinherited |
Return a pointer to the STL vector itself.
Implements SG::IAuxTypeVector.
|
inherited |
Return a reference to the payload vector.
|
privateinherited |
The auxid of the variable this vector represents.
Definition at line 305 of file IAuxTypeVector.h.
|
privateinherited |
True if this variable is linked from another one.
Definition at line 308 of file IAuxTypeVector.h.
|
protected |
Interface for the linked vector of DataLinks.
Definition at line 101 of file PackedLinkVector.h.
|
privateinherited |
True if we need to delete the object.
Definition at line 303 of file AuxTypeVector.h.
|
privateinherited |
Description of the vector start+size.
Definition at line 311 of file IAuxTypeVector.h.
|
privateinherited |
The contained vector.
Definition at line 300 of file AuxTypeVector.h.
|
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.