CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions
FWItemAccessorFactory Class Reference

#include <Fireworks/Core/interface/FWItemAccessorFactory.h>

Public Member Functions

std::shared_ptr< FWItemAccessorBaseaccessorFor (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 &)=delete
 
const FWItemAccessorFactoryoperator= (const FWItemAccessorFactory &)=delete
 

Detailed Description

Description: Factory for constructing FWItemAccessorBases appropriate to a certain type

Usage: <usage>

Definition at line 31 of file FWItemAccessorFactory.h.

Constructor & Destructor Documentation

◆ FWItemAccessorFactory() [1/2]

FWItemAccessorFactory::FWItemAccessorFactory ( )

Definition at line 38 of file FWItemAccessorFactory.cc.

38 {}

◆ ~FWItemAccessorFactory()

FWItemAccessorFactory::~FWItemAccessorFactory ( )
virtual

Definition at line 45 of file FWItemAccessorFactory.cc.

45 {}

◆ FWItemAccessorFactory() [2/2]

FWItemAccessorFactory::FWItemAccessorFactory ( const FWItemAccessorFactory )
privatedelete

Member Function Documentation

◆ accessorFor()

std::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 above is not true, we lookup the plugin based FWItemAccessorRegistry for a plugin that can handle the given type.

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.

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 89 of file FWItemAccessorFactory.cc.

89  {
90  static const bool debug = false;
91 
92  TClass *member = nullptr;
93  size_t offset = 0;
94 
95  if (hasTVirtualCollectionProxy(iClass)) {
96  if (debug)
97  fwLog(fwlog::kDebug) << "class " << iClass->GetName() << " uses FWItemTVirtualCollectionProxyAccessor."
98  << std::endl;
99  return std::make_shared<FWItemTVirtualCollectionProxyAccessor>(
100  iClass, std::shared_ptr<TVirtualCollectionProxy>(iClass->GetCollectionProxy()->Generate()));
101  }
102 
103  // Iterate on the available plugins and use the one which handles
104  // the iClass type.
105  // NOTE: This is done only a few times, not really performance critical.
106  // If you want this to be fast, the loop can be moved in the
107  // constructor. Notice that this will require constructing FWEventItemsManager
108  // after the plugin manager (i.e. invoking FWLiteEnabler::enable()) is configured
109  // (i.e. invoking FWLiteEnabler::enable()) in CmsShowMain.
110  std::string accessorName;
111  if (hasAccessor(iClass, accessorName)) {
112  if (debug)
113  fwLog(fwlog::kDebug) << "class " << iClass->GetName() << " uses " << accessorName << "." << std::endl;
114  return std::shared_ptr<FWItemAccessorBase>(FWItemAccessorRegistry::get()->create(accessorName, iClass));
115  }
116 
117  if (hasMemberTVirtualCollectionProxy(iClass, member, offset)) {
118  if (debug)
119  fwLog(fwlog::kDebug) << "class " << iClass->GetName() << " only contains data member " << member->GetName()
120  << " which uses FWItemTVirtualCollectionProxyAccessor." << std::endl;
121 
122  return std::make_shared<FWItemTVirtualCollectionProxyAccessor>(
123  iClass, std::shared_ptr<TVirtualCollectionProxy>(member->GetCollectionProxy()->Generate()), offset);
124  }
125 
126  return std::make_shared<FWItemSingleAccessor>(iClass);
127 }

References beamerCreator::create(), debug, fwLog, get, hasAccessor(), hasMemberTVirtualCollectionProxy(), hasTVirtualCollectionProxy(), fwlog::kDebug, hltrates_dqm_sourceclient-live_cfg::offset, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWSimpleRepresentationChecker::infoFor().

◆ classAccessedAsCollection()

bool FWItemAccessorFactory::classAccessedAsCollection ( const TClass *  iClass)
static

Helper method which checks if the object will be treated as a collection.

Returns
true if this is the case, false otherwise.

Definition at line 202 of file FWItemAccessorFactory.cc.

202  {
203  std::string accessorName;
204  TClass *member = nullptr;
205  size_t offset = 0;
206 
207  // This is pretty much the same thing that happens
210  FWItemAccessorFactory::hasAccessor(iClass, accessorName));
211 }

References hasAccessor(), hasMemberTVirtualCollectionProxy(), hasTVirtualCollectionProxy(), hltrates_dqm_sourceclient-live_cfg::offset, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWLiteJobMetadataManager::doUpdate(), and FWFFMetadataManager::doUpdate().

◆ hasAccessor()

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.

Returns
true if the plugin coul be found, false otherwise.

Definition at line 182 of file FWItemAccessorFactory.cc.

182  {
183  const std::vector<edmplugin::PluginInfo> &available =
184  edmplugin::PluginManager::get()->categoryToInfos().find("cmsShow FWItemAccessorBase")->second;
185 
186  for (size_t i = 0, e = available.size(); i != e; ++i) {
187  std::string name = available[i].name_;
188  std::string type = name.substr(0, name.find_first_of('@'));
189  if (iClass->GetTypeInfo()->name() == type) {
190  result.swap(name);
191  return true;
192  }
193  }
194  return false;
195 }

References edmplugin::PluginManager::categoryToInfos(), MillePedeFileConverter_cfg::e, edmplugin::PluginManager::get(), mps_fire::i, Skims_PA_cff::name, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by accessorFor(), and classAccessedAsCollection().

◆ hasMemberTVirtualCollectionProxy()

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.

@oOffset a reference which will hold the offset of the member relative to the beginning address of a class instance.

Returns
true if this is the case, false otherwise.

Definition at line 150 of file FWItemAccessorFactory.cc.

150  {
151  assert(iClass->GetTypeInfo());
152  edm::TypeWithDict dataType(*(iClass->GetTypeInfo()));
153  assert(bool(dataType));
154 
155  // If the object has more than one data member, we avoid guessing.
157  if (members.size() != 1)
158  return false;
159 
160  edm::MemberWithDict member(*members.begin());
161  edm::TypeWithDict memType(member.typeOf());
162  assert(bool(memType));
163  oMember = TClass::GetClass(memType.typeInfo());
164  oOffset = member.offset();
165 
166  // Check if this is a collection known by ROOT but also that the item held by
167  // the colletion actually has a dictionary
168 
169  if (!hasTVirtualCollectionProxy(oMember))
170  return false;
171 
172  return true;
173 }

References cms::cuda::assert(), edm::TypeDataMembers::begin(), DTskim_cfg::dataType, hasTVirtualCollectionProxy(), and edm::TypeDataMembers::size().

Referenced by accessorFor(), and classAccessedAsCollection().

◆ hasTVirtualCollectionProxy()

bool FWItemAccessorFactory::hasTVirtualCollectionProxy ( const TClass *  iClass)
static

Helper method which

Returns
true if the passes iClass can be accessed via TVirtualCollectionProxy.

Definition at line 132 of file FWItemAccessorFactory.cc.

132  {
133  // Check if this is a collection known by ROOT but also that the item held by
134  // the colletion actually has a dictionary
135  return iClass && iClass->GetCollectionProxy() && iClass->GetCollectionProxy()->GetValueClass() &&
136  iClass->GetCollectionProxy()->GetValueClass()->IsLoaded();
137 }

Referenced by accessorFor(), classAccessedAsCollection(), and hasMemberTVirtualCollectionProxy().

◆ operator=()

const FWItemAccessorFactory& FWItemAccessorFactory::operator= ( const FWItemAccessorFactory )
privatedelete
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
mps_fire.i
i
Definition: mps_fire.py:355
cms::cuda::assert
assert(be >=bs)
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
FWItemAccessorFactory::hasTVirtualCollectionProxy
static bool hasTVirtualCollectionProxy(const TClass *iClass)
Definition: FWItemAccessorFactory.cc:132
DTskim_cfg.dataType
dataType
Definition: DTskim_cfg.py:56
edmplugin::PluginManager::get
static PluginManager * get()
Definition: PluginManager.cc:307
edmplugin::PluginManager::categoryToInfos
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:80
debug
#define debug
Definition: HDRShower.cc:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::TypeWithDict
Definition: TypeWithDict.h:38
edm::TypeDataMembers
Definition: TypeWithDict.h:164
edm::MemberWithDict
Definition: MemberWithDict.h:19
get
#define get
type
type
Definition: HCALResponse.h:21
fwlog::kDebug
Definition: fwLog.h:35
FWItemAccessorFactory::hasMemberTVirtualCollectionProxy
static bool hasMemberTVirtualCollectionProxy(const TClass *iClass, TClass *&oMember, size_t &oOffset)
Definition: FWItemAccessorFactory.cc:150
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
mps_fire.result
result
Definition: mps_fire.py:303
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
FWItemAccessorFactory::hasAccessor
static bool hasAccessor(const TClass *iClass, std::string &result)
Definition: FWItemAccessorFactory.cc:182
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37