10#include <TClassEdit.h>
12#include <TBaseClass.h>
13#include <TCollectionProxyInfo.h>
28const bool mn = getenv(
"MN_DEBUG");
42 return cls->GetBaseClassOffset(
base );
52 std::vector< std::string > args;
58 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
59 TClassEdit::GetSplit( dvclass->GetName(), args, tailloc );
61 assert( args.size() > 1 );
64 std::string elname = args[ 1 ];
65 assert( elname.size() > 0 );
68 TClass* elclass = TClass::GetClass( elname.c_str() );
70 ::Error(
"xAOD::TDVCollectionProxy",
"Cannot find class %s",
89 TIter next( dvclass->GetListOfBases() );
90 while( TBaseClass* bcl =
dynamic_cast< TBaseClass*
>( next() ) ) {
91 TClass* cc = bcl->GetClassPointer();
92 if( strncmp( cc->GetName(),
"DataVector", 10 ) == 0 ) {
95 if( strncmp( cc->GetName(),
"DataVector<", 11 ) == 0 )
116 TClass::GetClass(
"DataVector<xAOD::TDVCollectionProxyDummy>" );
118 Error(
"xAOD::findDVElement",
119 "Couldn't load the dictionary for "
120 "DataVector<xAOD::TDVCollectionProxyDummy>" );
126 const char*
name = cl->GetName();
127 if( strncmp(
name,
"DataVector<", 11 ) == 0 ) {
129 elt = std::string(
name + 11, strlen(
name ) - 11 - 1 );
133 const std::string::size_type comma = elt.find(
',' );
134 if( comma != std::string::npos ) {
142 TIter next( cl->GetListOfBases() );
143 while( TBaseClass* bcl =
dynamic_cast< TBaseClass*
>( next() ) ) {
144 TClass* cc = bcl->GetClassPointer();
146 if( ! elt.empty() ) {
193 using Env_t = ROOT::TCollectionProxyInfo::Environ<TEnvBuff>;
220 char* start = c[ 0 ];
221 buff.fEltPtr = start + buff.fOffset;
233 static void*
next(
void* env ) {
238 buff.fIndex +=
e.fIdx;
240 if( buff.fIndex >=
e.fSize ) {
243 char* ptr = c[ buff.fIndex ];
244 buff.fEltPtr = ptr + buff.fOffset;
251 static void*
size(
void* env ) {
254 e->fSize =
cont( env )->size();
255 return &(
e->fSize );
263 cont( env )->clear();
280 ::Fatal(
"xAOD::TDVCollectionProxy",
"resize function not specified!" );
285 ::Fatal(
"xAOD::TDVCollectionProxy",
"construct not implemented" );
291 ::Fatal(
"xAOD::TDVCollectionProxy",
"destruct not implemented" );
299 const std::type_info &elem_typeinfo = dv->dvlinfo_v().elt_tinfo();
302 if(
mn) cout <<
"PROX: feed, typename=" << ru_type.getTypeName() <<
" typesize=" << ru_type.getSize() <<endl;
305 for(
size_t i=0; i<
size; i++) {
306 void *obj = ru_type.create();
308 dv->dvlinfo_v().push(dv,obj);
316 ::Fatal(
"xAOD::TDVCollectionProxy",
"collect not implemented" );
335 fValDiff =
sizeof(
void* );
353 delete fValue.exchange(
nullptr );
371 : TGenCollectionProxy( rhs ),
383 delete fValue.exchange(
nullptr );
399 ::TGenCollectionProxy::PushProxy( objstart );
406 buff.fOffset = fOffset;
410 char* dvstart =
reinterpret_cast< char*
>( objstart ) + fContoff;
418 const std::vector< char* >&
vec = dv->stdcont();
421 const_cast< std::vector< char* >*
>( &
vec );
451 TClass* cl = TClass::GetClass(
fName );
453 ::Fatal(
"xAOD::TDVCollectionProxy::InitializeEx",
454 "Couldn't find dictionary for class %s",
461 if( eltname.empty() ) {
462 ::Fatal(
"xAOD::TDVCollectionProxy::InitializeEx",
463 "Class \"%s\" doesn't seem to be a DataVector",
472 fValDiff =
sizeof(
void* );
477 TGenCollectionProxy::InitializeEx( silent );
480 fSTL_type = TClassEdit::kList;
484 delete fValue.exchange(
nullptr );
486 if( fVal )
delete fVal;
487 fValue =
new TGenCollectionProxy::Value( eltname.c_str(),
false );
488 fVal =
new TGenCollectionProxy::Value( *fValue );
523 const char* conttype ) {
530 TClass* dvclass = TClass::GetClass( conttype );
532 ::Fatal(
"xAOD::TDVCollectionProxy::FindOffsets",
533 "Cannot find class %s", conttype );
542 ::Fatal(
"xAOD::TDVCollectionProxy::FindOffsets",
543 "Couldn't find element type of %s",
544 dvclass->GetName() );
558 std::string elttype2 = elttype;
559 if( elttype2[ elttype2.size() - 1 ] ==
'*' ) {
560 elttype2.erase( elttype2.size() - 1 );
562 fEltType = TClass::GetClass( elttype2.c_str() );
566 ::Fatal(
"xAOD::TDVCollectionProxy::FindOffsets",
567 "Couldn't find dictionaries for DV element "
568 "type(s) for %s", conttype );
std::vector< size_t > vec
An STL vector of pointers that by default owns its pointed-to elements.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Helper functions for accessing the container data via the proxy.
static Cont_t * cont(void *env)
Fetch the container from a proxy environment.
static void * collect(void *, void *)
Not implemented for xAOD.
static void * first(void *env)
Return the first element of the container.
static void * construct(void *, size_t)
Not implemented for xAOD.
static void * size(void *env)
Return the size of the container.
static void * clear(void *env)
Erase the container.
ROOT::TCollectionProxyInfo::Environ< TEnvBuff > Env_t
The Root proxy environment structure.
static void * next(void *env)
Return a following element of the container.
std::vector< char * > Cont_t
The container type.
static void resize(void *, size_t)
Not implemented for xAOD.
static void * feed(void *, void *to, size_t size)
static void * create_env()
Return a new environment structure.
static void destruct(void *, size_t)
Not implemented for xAOD.
Dummy class to use as the DataVector template argument for the class we give to the Root proxy.
TClass * fEltBase
The element type to which the DV representation points.
void FindOffsets(const char *elttype, const char *conttype)
Initialize the cached pointer offsets.
virtual TVirtualCollectionProxy * Generate() const
Clone this object.
Bool_t fInitialized
Flag for knowing whether the class was initialised already.
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Function initialising the proxy just in time.
TClass * fEltType
The declared element type of the DV.
void SetResize(Sizing_t func)
Set the resize(...) function used by the proxy.
TString fName
Name of the container that this class proxies.
virtual void PushProxy(void *objstart)
Start working with a new collection.
ptrdiff_t fContoff
The offset of the underlying DataVector in the declared type.
ptrdiff_t fOffset
Offset between the DV base pointer and the full DV pointer.
TDVCollectionProxy(const char *conttype)
Constructor.
TGenCollectionProxy::Sizing_t Sizing_t
Make the definition of Sizing_t public.
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...
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
int safeGetBaseOffset(TClass *cls, TClass *base)
Find base class offset using Reflex.
std::string findDVElement(TClass *cl)
Find the element type of a DataVector class.
TClass * classFromDVClass(TClass *dvclass)
Find the contained class in a DataVector.
TClass * findDVBase(TClass *dvclass)
Find the unique base DataVector class.
Helper to disable undefined behavior sanitizer for a function.
#define NO_SANITIZE_UNDEFINED
Proxy environment buffer.
size_t fIndex
The index of the last element retrieved.
int fOffset
Offset between the pointer held by the DV and the start of the object.
void * fEltPtr
The last element pointer to have been returned.
Cont_t * fCont
Pointer to the container.