ATLAS Offline Software
Loading...
Searching...
No Matches
DataModelAthenaPool::DataVectorConvert Class Reference

Provide backwards compatibility for reading DataVector classes. More...

#include <DataVectorConvert.h>

Collaboration diagram for DataModelAthenaPool::DataVectorConvert:

Static Public Member Functions

static void initialize (RootUtils::ILogger *logfn=0)
 Scan all known DataVector classes and fix up the Root data for any that need conversion.

Detailed Description

Provide backwards compatibility for reading DataVector classes.

When setting up DataVector inheritance using DATAVECTOR_BASE, a side effect is that the persistent form of the data may change. Including this service will fix up the root metadata to allow reading old data. In fact, any sort of DataVector<A> to DataVector<B> conversions will be allowed, provided that A* can be converted to B*.

The only reason to make this a class rather than a free function is that Root's autoloading seems to work only with classes.

Definition at line 39 of file DataVectorConvert.h.

Member Function Documentation

◆ initialize()

void DataModelAthenaPool::DataVectorConvert::initialize ( RootUtils::ILogger * logfn = 0)
static

Scan all known DataVector classes and fix up the Root data for any that need conversion.

Parameters
logfnCallback for logging debug messages. Null for no logging.

It's ok to call this more than once to look for any new classes (we remember which classes we've already processed to avoid doing them again).

Definition at line 469 of file DataVectorConvert.cxx.

470{
471 static std::mutex m;
472 std::lock_guard<std::mutex> lock (m);
473
474 // List of classes we've already processed.
475 static std::vector<TClass*> s_seen ATLAS_THREAD_SAFE;
476
477 TIter next (gROOT->GetListOfClasses());
478 while (TClass* cls = dynamic_cast<TClass*> (next())) {
479 if (std::strncmp (cls->GetName(), "DataVector<", 11) == 0) {
480 if (std::find (s_seen.begin(), s_seen.end(), cls) == s_seen.end()) {
481 test_dv (logfn, cls);
482 s_seen.push_back (cls);
483 }
484 }
485 }
486}
#define ATLAS_THREAD_SAFE

The documentation for this class was generated from the following files: