ATLAS Offline Software
|
Dynamic implementation of IAuxTypeVector
, relying on root vector proxy.
More...
#include <RootAuxVectorFactory.h>
Public Member Functions | |
RootAuxVector (const RootAuxVectorFactory *factory, SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked) | |
Constructor. More... | |
RootAuxVector (const RootAuxVectorFactory *factory, SG::auxid_t auxid, void *data, bool isPacked, bool ownFlag, bool isLinked) | |
Constructor, from a pointer to a vector object. More... | |
RootAuxVector (const RootAuxVector &other) | |
Copy constructor. More... | |
RootAuxVector & | operator= (const RootAuxVector &)=delete |
virtual | ~RootAuxVector () override |
Destructor. More... | |
virtual std::unique_ptr< SG::IAuxTypeVector > | clone () 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 overall object. 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 | shift (size_t pos, ptrdiff_t offs) override |
Shift the elements of the vector. More... | |
virtual bool | insertMove (size_t pos, void *src, size_t src_pos, size_t src_n, SG::IAuxStore &srcStore) override |
Insert elements into the vector via move semantics. More... | |
virtual const std::type_info * | objType () const override |
Return the type of the complete object to be saved. More... | |
virtual bool | setOption (const AuxDataOption &) |
Set an option for this variable. More... | |
virtual std::unique_ptr< IAuxTypeVector > | toPacked () |
Make a packed version of the variable. 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... | |
void | storeDataSpan (void *beg, size_t size) |
Update the stored span. More... | |
void | resetDataSpan () |
Invalidate the stored span. More... | |
Private Member Functions | |
void | storeDataSpan () |
Update the stored span. More... | |
Private Attributes | |
const RootAuxVectorFactory * | m_factory |
Pointer back to the factory class for this type. More... | |
std::unique_ptr< TVirtualCollectionProxy > | m_proxy |
The collection proxy for the vector. More... | |
void * | m_obj |
Pointer to the overall object itself. More... | |
void * | m_vec |
Pointer to the vector object itself. More... | |
bool | m_ownFlag |
Should be delete the vector 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... | |
Dynamic implementation of IAuxTypeVector
, relying on root vector proxy.
This is used for the case when we need to manipulate an aux data vector present in an input data file but we have neither a proper template instantiation for the factory (because the variable was never explicitly referenced), nor can we find a dictionary entry for the factory.j
This implementation works by relying entirely on the root dictionary information.
Definition at line 46 of file RootAuxVectorFactory.h.
SG::RootAuxVector::RootAuxVector | ( | const RootAuxVectorFactory * | factory, |
SG::auxid_t | auxid, | ||
size_t | size, | ||
size_t | capacity, | ||
bool | isLinked | ||
) |
Constructor.
Makes a new vector.
factory | The factory object for this type. |
auxid | The auxid of the variable this vector represents. |
size | Initial size of the new vector. |
capacity | Initial capacity of the new vector. |
isLinked | True if this variable is linked from another one. |
Definition at line 63 of file RootAuxVectorFactory.cxx.
SG::RootAuxVector::RootAuxVector | ( | const RootAuxVectorFactory * | factory, |
SG::auxid_t | auxid, | ||
void * | data, | ||
bool | isPacked, | ||
bool | ownFlag, | ||
bool | isLinked | ||
) |
Constructor, from a pointer to a vector object.
factory | The factory object for this type. |
auxid | The auxid of the variable this vector represents. |
data | The vector object. |
isPacked | If true, data is a PackedContainer . |
ownFlag | If true, then take ownership of data . |
isLinked | True if this variable is linked from another one. |
If the element type is T, then data
should be a pointer to a std::vector<T> object, which was obtained with new
.
This version does not support packed containers, so isPacked
must be false.
Definition at line 95 of file RootAuxVectorFactory.cxx.
SG::RootAuxVector::RootAuxVector | ( | const RootAuxVector & | other | ) |
Copy constructor.
other | The vector to copy. |
Definition at line 118 of file RootAuxVectorFactory.cxx.
|
overridevirtual |
Destructor.
This will free the vector data.
Definition at line 143 of file RootAuxVectorFactory.cxx.
|
inlineinherited |
Return the auxid of the variable this vector represents.
Definition at line 232 of file IAuxTypeVector.h.
|
overridevirtual |
Make a copy of this vector.
Implements SG::IAuxTypeVector.
Definition at line 153 of file RootAuxVectorFactory.cxx.
|
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.
|
finaloverrideprotectedvirtual |
Return a span object describing the current vector.
Used to initialize m_span
the first time that getDataSpan
is called.
Implements SG::IAuxTypeVector.
Definition at line 348 of file RootAuxVectorFactory.cxx.
|
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.
Implements SG::IAuxTypeVector.
Definition at line 304 of file RootAuxVectorFactory.cxx.
|
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.
|
overridevirtual |
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 from SG::IAuxTypeVector.
Definition at line 337 of file RootAuxVectorFactory.cxx.
|
delete |
|
overridevirtual |
Change the capacity of the vector.
sz | The new vector capacity. |
Implements SG::IAuxTypeVector.
Definition at line 219 of file RootAuxVectorFactory.cxx.
|
inlineprotectedinherited |
Invalidate the stored span.
Definition at line 297 of file IAuxTypeVector.h.
|
overridevirtual |
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. |
Implements SG::IAuxTypeVector.
Definition at line 206 of file RootAuxVectorFactory.cxx.
|
inlinevirtualinherited |
Set an option for this variable.
option | The 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 >, 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 172 of file IAuxTypeVector.h.
|
overridevirtual |
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.
Definition at line 250 of file RootAuxVectorFactory.cxx.
|
overridevirtual |
Return the size of the vector.
Implements SG::IAuxTypeVector.
Definition at line 194 of file RootAuxVectorFactory.cxx.
|
private |
Update the stored span.
Definition at line 358 of file RootAuxVectorFactory.cxx.
|
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.
|
inlinevirtualinherited |
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.
|
overridevirtual |
Return a pointer to the start of the vector's data.
Implements SG::IAuxTypeVector.
Definition at line 173 of file RootAuxVectorFactory.cxx.
|
overridevirtual |
Return a pointer to the start of the vector's data.
Implements SG::IAuxTypeVector.
Definition at line 162 of file RootAuxVectorFactory.cxx.
|
overridevirtual |
Return a pointer to the overall object.
Implements SG::IAuxTypeVector.
Definition at line 185 of file RootAuxVectorFactory.cxx.
|
privateinherited |
The auxid of the variable this vector represents.
Definition at line 305 of file IAuxTypeVector.h.
|
private |
Pointer back to the factory class for this type.
Definition at line 241 of file RootAuxVectorFactory.h.
|
privateinherited |
True if this variable is linked from another one.
Definition at line 308 of file IAuxTypeVector.h.
|
private |
Pointer to the overall object itself.
Definition at line 250 of file RootAuxVectorFactory.h.
|
private |
Should be delete the vector object?
Definition at line 256 of file RootAuxVectorFactory.h.
|
private |
The collection proxy for the vector.
Cloned from the proxy held by the TClass and permanently bound to m_vec. That makes things a bit more efficient, and prevents potential thread-safety problems.
Definition at line 247 of file RootAuxVectorFactory.h.
|
privateinherited |
Description of the vector start+size.
Definition at line 311 of file IAuxTypeVector.h.
|
private |
Pointer to the vector object itself.
Definition at line 253 of file RootAuxVectorFactory.h.