17#include "AthLinks/ElementLinkBase.h"
21#include "TVirtualCollectionProxy.h"
40 std::string tname =
cl->GetName();
41 tname +=
"::vector_type";
42 TDataType* typ = gROOT->GetType (tname.c_str());
44 return TClass::GetClass (typ->GetFullTypeName());
71 const TClass* vecClass = factory->vecClass();
72 m_proxy.reset (vecClass->GetCollectionProxy()->Generate());
73 m_obj = factory->objClass()->New ();
105 if (isPacked) std::abort();
106 const TClass* vecClass = factory->vecClass();
107 m_proxy.reset (vecClass->GetCollectionProxy()->Generate());
127 size_t sz = other.size();
132 const void* otherPtr = other.toPtr();
133 rootType.copyRange (this->
toPtr(), otherPtr,
sz);
155 return std::make_unique<RootAuxVector> (*
this);
252 size_t eltsz =
m_proxy->GetIncrement();
257 if (-offs >
static_cast<ptrdiff_t
>(pos)) offs = -pos;
258 char* beg =
reinterpret_cast<char*
>(
m_proxy->At(0));
259 rootType.copyRange (beg + eltsz*(pos+offs),
267 size_t oldsz =
m_proxy->Size();
268 m_proxy->Allocate (oldsz + offs,
false);
269 char* beg =
reinterpret_cast<char*
>(
m_proxy->At(0));
271 rootType.copyRange (beg + eltsz*(pos+offs),
274 rootType.clearRange (beg + eltsz*pos, offs);
305 void* src,
size_t src_pos,
size_t src_n,
308 size_t eltsz =
m_proxy->GetIncrement();
312 char* srcp =
reinterpret_cast<char*
> (src);
313 char* begp = srcp + src_pos*eltsz;
319 rootType.copyRange (
reinterpret_cast<char*
>(this->
toPtr()) + pos*eltsz,
339 return m_factory->objClass()->GetTypeInfo();
377 TVirtualCollectionProxy* proxy =
m_vecClass->GetCollectionProxy();
380 TClass* vecClass = lookupVectorType (objClass);
383 Int_t offs = objClass->GetBaseClassOffset (vecClass);
386 proxy = vecClass->GetCollectionProxy();
390 std::string(
"Can't find vector base class in ") +
391 objClass->GetName());
397 std::string err =
"Can't find collection proxy for ";
399 throw std::runtime_error (err.c_str());
403 ATHCONTAINERS_ERROR(
"RootAuxVectorFactory::RootAuxVectorFactory",
404 std::string(
"No type_info available for class ") +
405 m_vecClass->GetName() +
406 std::string(
". There is probably a missing dictionary. We will likely crash further on."));
409 TClass* eltClass = proxy->GetValueClass();
413 const std::type_info* ti = eltClass->GetTypeInfo();
421 if (clname.
match (pat1, matches)) {
423 if (eltClass->GetBaseClass (
"ElementLinkBase") ==
nullptr) {
427 else if (clname.
match (pat2, matches)) {
430 TVirtualCollectionProxy* proxy2 = eltClass->GetCollectionProxy();
432 TClass* innerEltClass = proxy2->GetValueClass();
434 if (innerEltClass->GetBaseClass (
"ElementLinkBase") ==
nullptr) {
443 m_type.init (proxy->GetType());
462std::unique_ptr<SG::IAuxTypeVector>
468 return std::make_unique<RootAuxVector> (
this, auxid, size, capacity,
493std::unique_ptr<SG::IAuxTypeVector>
501 if (linkedVector) std::abort();
502 return std::make_unique<RootAuxVector> (
this, auxid,
data, isPacked, ownFlag,
516 if (n == 0)
return nullptr;
517 size_t eltsz =
m_type.getSize();
518 char* dstptr =
reinterpret_cast<char*
> (dst.
getDataArray (auxid));
523 m_type.copyRange (dstptr + eltsz*dst_index, dstptr + eltsz*src_index, n);
524 return dstptr + eltsz*dst_index;
527 const char* srcptr =
reinterpret_cast<const char*
>(src.getDataArrayAllowMissing (auxid));
529 m_type.copyRange (dstptr + eltsz*dst_index, srcptr + eltsz*src_index, n);
530 return dstptr + eltsz*dst_index;
533 m_type.clearRange (dstptr + eltsz*dst_index, n);
558 (void)
copyImpl (auxid, dst, dst_index, src, src_index, n);
579 char* dstptr =
copyImpl (auxid, dst, dst_index, src, src_index, n);
582 size_t eltsz =
m_type.getSize();
583 for (
size_t i = 0; i < n; i++) {
588 size_t eltsz =
m_type.getSize();
589 for (
size_t i = 0; i < n; i++) {
590 std::vector<ElementLinkBase>& v =
591 *
reinterpret_cast<std::vector<ElementLinkBase>*
> (dstptr +i*eltsz);
599 std::string(
"Cannot apply thinning for ElementLink with non-pointer element: ") +
623 void* aptr =
a.getDataArray (auxid);
624 void* bptr = &
a == &b ? aptr : b.getDataArray (auxid);
625 m_type.swapRange (aptr, aindex, bptr, bindex, n);
692 std::string alloc_name;
696 else if (cn.
ntargs() == 1) {
698 if (alloc_name[alloc_name.size()-1] ==
'>') alloc_name +=
" ";
Manage lookup of vectors of auxiliary data.
Recursively separate out template arguments in a C++ class name.
char data[hepevt_bytes_allocation_ATLAS]
Dynamic implementation of IAuxVectorFactory, relying on root's vector proxy.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Recursively separate out template arguments in a C++ class name.
std::string fullName() const
Return the full name of the expression.
std::map< std::string, ClassName > match_t
Map used to hold variable assignments from matching.
bool match(const ClassName &pattern, match_t &matches) const
Match this expression against a pattern.
const ClassName & targ(size_t i) const
Return one template argument.
size_t ntargs() const
Return number of template arguments.
Base class for ElementLinks to vectors of pointers.
Manage lookup of vectors of auxiliary data.
const void * getDataArray(SG::auxid_t auxid) const
Return a const pointer to the start of an aux data vector.
Interface for non-const operations on an auxiliary store.
Abstract interface for manipulating vectors of arbitrary types.
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.
void storeDataSpan(void *beg, size_t size)
Update the stored span.
const AuxDataSpanBase & getDataSpan() const
Return a reference to a description of this vector's start+size.
IAuxTypeVector(auxid_t auxid, bool isLinked)
Constructor.
Dynamic implementation of IAuxVectorFactory, relying on root's vector proxy.
RootAuxVectorFactory(TClass *objClass)
Constructor.
size_t offset() const
Return the offset of the vector within the object.
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const override
Copy elements between vectors.
virtual bool isDynamic() const override
True if the vectors created by this factory work by dynamic emulation (via TVirtualCollectionProxy or...
virtual ~RootAuxVectorFactory() override
Destructor.
virtual void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const override
Swap elements between vectors.
RootUtils::Type m_type
Wrapper for the ROOT type of the element.
char * copyImpl(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const
Helper for copy; returns a pointer to the first destination object, or nullptr if the destination was...
virtual const std::type_info * tiVec() const override
Return the type_info of the overall object.
size_t m_offset
Offset of the STL vector within the overall object.
enum SG::RootAuxVectorFactory::@071257101107162132204103261125230107154016006205 m_isEL
Flag to tell whether we need to do thinning.
virtual const std::type_info * tiAlloc() const override
Return the type_info of the vector allocator.
virtual std::string tiAllocName() const override
Return the (demangled) name of the vector allocator.
TClass * m_objClass
The TClass for the overall object.
TClass * m_vecClass
The TClass for the std::vector.
virtual void copyForOutput(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const override
Copy elements between vectors, possibly applying thinning.
@ ELEMENT_LINK_NONPOINTER
virtual std::unique_ptr< SG::IAuxTypeVector > createFromData(SG::auxid_t auxid, void *data, IAuxTypeVector *linkedVector, bool isPacked, bool ownFlag, bool isLinked) const override
Create a vector object of this type from a data blob.
virtual std::unique_ptr< SG::IAuxTypeVector > create(SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked) const override
Create a vector object of this type.
virtual size_t getEltSize() const override
Return the size of an element of this vector type.
virtual void clear(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const override
Clear a range of elements within a vector.
const RootAuxVectorFactory * m_factory
Pointer back to the factory class for this type.
void * m_vec
Pointer to the vector object itself.
virtual void * toPtr() override
Return a pointer to the start of the vector's data.
std::unique_ptr< TVirtualCollectionProxy > m_proxy
The collection proxy for the vector.
bool m_ownFlag
Should be delete the vector object?
RootAuxVector(const RootAuxVectorFactory *factory, SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked)
Constructor.
virtual AuxDataSpanBase getDataSpanImpl() const override final
Return a span object describing the current vector.
virtual std::unique_ptr< SG::IAuxTypeVector > clone() const override
Make a copy of this vector.
virtual void * toVector() override
Return a pointer to the overall object.
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.
void storeDataSpan()
Update the stored span.
virtual ~RootAuxVector() override
Destructor.
void * m_obj
Pointer to the overall object itself.
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 const std::type_info * objType() const override
Return the type of the complete object to be saved.
virtual void reserve(size_t sz) override
Change the capacity of the vector.
virtual size_t size() const override
Return the size of the vector.
Helper for emitting error messages.
#define ATHCONTAINERS_ERROR(ctx, msg)
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
size_t auxid_t
Identifier for a particular aux data item.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
TClass * lookupVectorType(TClass &cl)
Internal function used by xAOD::TAuxStore and xAOD::RAuxStore.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Minimal span-like object describing the range of an auxiliary variable.
void * beg
Pointer to the start of the variable's vector.