#include <Fireworks/Core/interface/FWItemAccessorFactory.h>
Public Member Functions | |
boost::shared_ptr < FWItemAccessorBase > | accessorFor (const TClass *) const |
FWItemAccessorFactory () | |
virtual | ~FWItemAccessorFactory () |
Static Public Member Functions | |
static bool | classAccessedAsCollection (const TClass *) |
static bool | hasAccessor (const TClass *iClass, std::string &result) |
static bool | hasMemberTVirtualCollectionProxy (const TClass *iClass, TClass *&oMember, size_t &oOffset) |
static bool | hasTVirtualCollectionProxy (const TClass *iClass) |
Private Member Functions | |
FWItemAccessorFactory (const FWItemAccessorFactory &) | |
const FWItemAccessorFactory & | operator= (const FWItemAccessorFactory &) |
Description: Factory for constructing FWItemAccessorBases appropriate to a certain type
Usage: <usage>
Definition at line 32 of file FWItemAccessorFactory.h.
FWItemAccessorFactory::FWItemAccessorFactory | ( | ) |
Definition at line 39 of file FWItemAccessorFactory.cc.
{ }
FWItemAccessorFactory::~FWItemAccessorFactory | ( | ) | [virtual] |
Definition at line 48 of file FWItemAccessorFactory.cc.
{ }
FWItemAccessorFactory::FWItemAccessorFactory | ( | const FWItemAccessorFactory & | ) | [private] |
boost::shared_ptr< FWItemAccessorBase > FWItemAccessorFactory::accessorFor | ( | const TClass * | iClass | ) | const |
Create an accessor for a given type iClass.
iClass the type for which we need an accessor.
If the type is known to ROOT to be some sort of collection, we return the a FWItemTVirtualCollectionProxyAccessor constructed using the associated TVirtualCollectionProxy.
If the type is not a collection but it contains only one element which is a collection, we return a FWItemTVirtualCollectionProxyAccessor using the TVirtualCollectionProxy of that element.
If none of the above is true, we lookup the plugin based FWItemAccessorRegistry for a plugin that can handle the given type.
Failing that, we return a FWItemSingleAccessor which threats the object as if it was not a collection. Notice that this also will mean that the product associated to iClass will not show up in the "Add Collection" table.
Definition at line 95 of file FWItemAccessorFactory.cc.
References debug, fwLog, reco::get(), hasAccessor(), hasMemberTVirtualCollectionProxy(), hasTVirtualCollectionProxy(), fwlog::kDebug, and evf::evtn::offset().
Referenced by FWSimpleRepresentationChecker::infoFor().
{ static const bool debug = false; TClass *member = 0; size_t offset=0; if(hasTVirtualCollectionProxy(iClass)) { if (debug) fwLog(fwlog::kDebug) << "class " << iClass->GetName() << " uses FWItemTVirtualCollectionProxyAccessor." << std::endl; return boost::shared_ptr<FWItemAccessorBase>( new FWItemTVirtualCollectionProxyAccessor(iClass, boost::shared_ptr<TVirtualCollectionProxy>(iClass->GetCollectionProxy()->Generate()))); } else if (hasMemberTVirtualCollectionProxy(iClass, member,offset)) { if (debug) fwLog(fwlog::kDebug) << "class "<< iClass->GetName() << " only contains data member " << member->GetName() << " which uses FWItemTVirtualCollectionProxyAccessor." << std::endl; return boost::shared_ptr<FWItemAccessorBase>( new FWItemTVirtualCollectionProxyAccessor(iClass, boost::shared_ptr<TVirtualCollectionProxy>(member->GetCollectionProxy()->Generate()), offset)); } // Iterate on the available plugins and use the one which handles // the iClass type. // NOTE: This is done only a few times, not really performance critical. // If you want this to be fast, the loop can be moved in the // constructor. Notice that this will require constructing FWEventItemsManager // after the plugin manager (i.e. invoking AutoLibraryLoader::enable()) is configured // (i.e. invoking AutoLibraryLoader::enable()) in CmsShowMain. std::string accessorName; if (hasAccessor(iClass, accessorName)) { if (debug) fwLog(fwlog::kDebug) << "class " << iClass->GetName() << " uses " << accessorName << "." << std::endl; return boost::shared_ptr<FWItemAccessorBase>(FWItemAccessorRegistry::get()->create(accessorName, iClass)); } return boost::shared_ptr<FWItemAccessorBase>(new FWItemSingleAccessor(iClass)); }
bool FWItemAccessorFactory::classAccessedAsCollection | ( | const TClass * | iClass | ) | [static] |
Helper method which checks if the object will be treated as a collection.
Definition at line 229 of file FWItemAccessorFactory.cc.
References hasAccessor(), hasMemberTVirtualCollectionProxy(), hasTVirtualCollectionProxy(), and evf::evtn::offset().
Referenced by FWLiteJobMetadataManager::doUpdate(), and FWFFMetadataManager::doUpdate().
{ std::string accessorName; TClass *member = 0; size_t offset=0; // This is pretty much the same thing that happens return (FWItemAccessorFactory::hasTVirtualCollectionProxy(iClass) || FWItemAccessorFactory::hasMemberTVirtualCollectionProxy(iClass, member,offset) || FWItemAccessorFactory::hasAccessor(iClass, accessorName)); }
bool FWItemAccessorFactory::hasAccessor | ( | const TClass * | iClass, |
std::string & | result | ||
) | [static] |
Helper method which can be used to retrieve the name of the accessor plugin which has to be created for a object of type iClass.
The result is stored in the passed reference result.
Definition at line 206 of file FWItemAccessorFactory.cc.
References reco::get(), i, and mergeVDriftHistosByStation::name.
Referenced by accessorFor(), and classAccessedAsCollection().
{ const std::vector<edmplugin::PluginInfo> &available = FWItemAccessorRegistry::get()->available(); for (size_t i = 0, e = available.size(); i != e; ++i) { std::string name = available[i].name_; std::string type = name.substr(0, name.find_first_of('@')); if (iClass->GetTypeInfo()->name() == type) { result.swap(name); return true; } } return false; }
bool FWItemAccessorFactory::hasMemberTVirtualCollectionProxy | ( | const TClass * | iClass, |
TClass *& | oMember, | ||
size_t & | oOffset | ||
) | [static] |
Helper method which checks if the object has only one data member and if that data memeber can be accessed via a TVirtualCollectionProxy.
oMember a reference to the pointer which will hold the actual TClass of the datamember to be used to build the TVirtualCollectionProxy.
a reference which will hold the offset of the member relative to the beginning address of a class instance.
Definition at line 170 of file FWItemAccessorFactory.cc.
References dtT0WireCalibration_cfg::dataType, and hasTVirtualCollectionProxy().
Referenced by accessorFor(), and classAccessedAsCollection().
{ assert(iClass->GetTypeInfo()); ROOT::Reflex::Type dataType(ROOT::Reflex::Type::ByTypeInfo(*(iClass->GetTypeInfo()))); assert(dataType != ROOT::Reflex::Type()); // If the object has more than one data member, we avoid guessing. if (dataType.DataMemberSize() != 1) return false; ROOT::Reflex::Type memType(dataType.DataMemberAt(0).TypeOf()); assert(memType != ROOT::Reflex::Type()); //make sure this is the real type and not a typedef memType = memType.FinalType(); oMember = TClass::GetClass(memType.TypeInfo()); oOffset = dataType.DataMemberAt(0).Offset(); // Check if this is a collection known by ROOT but also that the item held by // the colletion actually has a dictionary if (!hasTVirtualCollectionProxy(oMember)) return false; return true; }
bool FWItemAccessorFactory::hasTVirtualCollectionProxy | ( | const TClass * | iClass | ) | [static] |
Helper method which
Definition at line 148 of file FWItemAccessorFactory.cc.
Referenced by accessorFor(), classAccessedAsCollection(), and hasMemberTVirtualCollectionProxy().
{ // Check if this is a collection known by ROOT but also that the item held by // the colletion actually has a dictionary return iClass && iClass->GetCollectionProxy() && iClass->GetCollectionProxy()->GetValueClass() && iClass->GetCollectionProxy()->GetValueClass()->IsLoaded(); }
const FWItemAccessorFactory& FWItemAccessorFactory::operator= | ( | const FWItemAccessorFactory & | ) | [private] |