|
ATLAS Offline Software
|
Go to the documentation of this file.
17 #include "AthLinks/ElementLinkBase.h"
21 #include "TVirtualCollectionProxy.h"
38 TClass* lookupVectorType (TClass *
cl)
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());
120 m_factory (
other.m_factory),
121 m_proxy (
other.m_proxy->Generate()),
132 const void* otherPtr =
other.toPtr();
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));
267 size_t oldsz =
m_proxy->Size();
268 m_proxy->Allocate (oldsz + offs,
false);
269 char*
beg =
reinterpret_cast<char*
>(
m_proxy->At(0));
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();
372 : m_objClass (objClass),
373 m_vecClass (objClass),
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());
404 std::string(
"No type_info available for class ") +
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) {
462 std::unique_ptr<SG::IAuxTypeVector>
468 return std::make_unique<RootAuxVector> (
this, auxid,
size, capacity,
493 std::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;
518 char* dstptr =
reinterpret_cast<char*
> (dst.
getDataArray (auxid));
524 return dstptr + eltsz*dst_index;
527 const char* srcptr =
reinterpret_cast<const char*
>(
src.getDataArrayAllowMissing (auxid));
530 return dstptr + eltsz*dst_index;
558 (void)
copyImpl (auxid, dst, dst_index,
src, src_index,
n);
579 char* dstptr =
copyImpl (auxid, dst, dst_index,
src, src_index,
n);
583 for (
size_t i = 0;
i <
n;
i++) {
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);
692 std::string alloc_name;
696 else if (cn.
ntargs() == 1) {
698 if (alloc_name[alloc_name.size()-1] ==
'>') alloc_name +=
" ";
virtual void * toPtr() override
Return a pointer to the start of the vector's data.
virtual void * toVector() override
Return a pointer to the overall object.
Recursively separate out template arguments in a C++ class name.
char data[hepevt_bytes_allocation_ATLAS]
void swapRange(void *a, size_t a_index, void *b, size_t b_index, size_t n) const
Swap a range of objects between vectors.
const AuxDataSpanBase & getDataSpan() const
Return a reference to a description of this vector's start+size.
const void * getDataArray(SG::auxid_t auxid) const
Return a const pointer to the start of an aux data vector.
virtual void reserve(size_t sz) override
Change the capacity of the vector.
void init(const std::string &typname)
Initialize from a type name.
bool m_ownFlag
Should be delete the vector object?
virtual std::unique_ptr< SG::IAuxTypeVector > clone() const override
Make a copy of this vector.
virtual bool isDynamic() const override
True if the vectors created by this factory work by dynamic emulation (via TVirtualCollectionProxy or...
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...
enum SG::RootAuxVectorFactory::@28 m_isEL
Flag to tell whether we need to do thinning.
#define ATHCONTAINERS_ERROR(ctx, msg)
virtual bool shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the vector.
RootUtils::Type m_type
Wrapper for the ROOT type of the element.
void * m_obj
Pointer to the overall object itself.
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.
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.
virtual std::string tiAllocName() const override
Return the (demangled) name of the vector allocator.
Base class for ElementLinks to vectors of pointers.
size_t getSize() const
Return the size in bytes of an instance of the described type.
size_t m_offset
Offset of the STL vector within the overall object.
const RootAuxVectorFactory * m_factory
Pointer back to the factory class for this type.
RootAuxVectorFactory(TClass *objClass)
Constructor.
size_t auxid_t
Identifier for a particular aux data item.
const RootUtils::Type & rootType() const
Return the ROOT type wrapper.
virtual size_t size() const override
Return the size of the vector.
void storeDataSpan(void *beg, size_t size)
Update the stored span.
size_t ntargs() const
Return number of template arguments.
Recursively separate out template arguments in a C++ class name.
void clearRange(void *dst, size_t n) const
Clear a range of objects.
void * beg
Pointer to the start of the variable's vector.
size_t offset() const
Return the offset of the vector within the object.
std::string fullName() const
Return the full name of the expression.
Helper for emitting error messages.
void storeDataSpan()
Update the stored span.
virtual const std::type_info * tiVec() const override
Return the type_info of the overall object.
Manage lookup of vectors of auxiliary data.
TClass * m_objClass
The TClass for the overall object.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
const ClassName & targ(size_t i) const
Return one template argument.
void * m_vec
Pointer to the vector object itself.
Minimal span-like object describing the range of an auxiliary variable.
virtual const std::type_info * tiAlloc() const override
Return the type_info of the vector allocator.
virtual size_t getEltSize() const override
Return the size of an element of this vector type.
virtual const std::type_info * objType() const override
Return the type of the complete object to be saved.
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.
Interface for non-const operations on an auxiliary store.
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.
Dynamic implementation of IAuxVectorFactory, relying on root's vector proxy.
Dynamic implementation of IAuxTypeVector, relying on root vector proxy.
void copyRange(void *dst, const void *src, size_t n) const
Copy a range of objects.
std::map< std::string, ClassName > match_t
Map used to hold variable assignments from matching.
virtual AuxDataSpanBase getDataSpanImpl() const override final
Return a span object describing the current vector.
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.
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.
Abstract interface for manipulating vectors of arbitrary types.
Dynamic implementation of IAuxVectorFactory, relying on root's vector proxy.
std::unique_ptr< TVirtualCollectionProxy > m_proxy
The collection proxy for the vector.
RootAuxVector(const RootAuxVectorFactory *factory, SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked)
Constructor.
Manage lookup of vectors of auxiliary data.
#define ATLAS_THREAD_SAFE
virtual ~RootAuxVectorFactory() override
Destructor.
@ 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.
Define macros for attributes used to control the static checker.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
virtual ~RootAuxVector() override
Destructor.
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
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 bool resize(size_t sz) override
Change the size of the vector.
bool match(const ClassName &pattern, match_t &matches) const
Match this expression against a pattern.