CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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 FWItemAccessorFactoryoperator= (const FWItemAccessorFactory &)
 

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::FWItemAccessorFactory ( )

Definition at line 38 of file FWItemAccessorFactory.cc.

39 {
40 }
FWItemAccessorFactory::~FWItemAccessorFactory ( )
virtual

Definition at line 47 of file FWItemAccessorFactory.cc.

48 {
49 }
FWItemAccessorFactory::FWItemAccessorFactory ( const FWItemAccessorFactory )
private

Member Function Documentation

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

References debug, fwLog, reco::get(), hasAccessor(), hasMemberTVirtualCollectionProxy(), hasTVirtualCollectionProxy(), fwlog::kDebug, HLT_25ns14e33_v1_cff::offset, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FWSimpleRepresentationChecker::infoFor().

95 {
96  static const bool debug = false;
97 
98  TClass *member = 0;
99  size_t offset=0;
100 
101  if(hasTVirtualCollectionProxy(iClass))
102  {
103  if (debug)
104  fwLog(fwlog::kDebug) << "class " << iClass->GetName()
105  << " uses FWItemTVirtualCollectionProxyAccessor." << std::endl;
106  return boost::shared_ptr<FWItemAccessorBase>(
108  boost::shared_ptr<TVirtualCollectionProxy>(iClass->GetCollectionProxy()->Generate())));
109  }
110  else if (hasMemberTVirtualCollectionProxy(iClass, member,offset))
111  {
112  if (debug)
113  fwLog(fwlog::kDebug) << "class "<< iClass->GetName()
114  << " only contains data member " << member->GetName()
115  << " which uses FWItemTVirtualCollectionProxyAccessor."
116  << std::endl;
117 
118  return boost::shared_ptr<FWItemAccessorBase>(
120  boost::shared_ptr<TVirtualCollectionProxy>(member->GetCollectionProxy()->Generate()),
121  offset));
122  }
123 
124  // Iterate on the available plugins and use the one which handles
125  // the iClass type.
126  // NOTE: This is done only a few times, not really performance critical.
127  // If you want this to be fast, the loop can be moved in the
128  // constructor. Notice that this will require constructing FWEventItemsManager
129  // after the plugin manager (i.e. invoking AutoLibraryLoader::enable()) is configured
130  // (i.e. invoking AutoLibraryLoader::enable()) in CmsShowMain.
131  std::string accessorName;
132  if (hasAccessor(iClass, accessorName))
133  {
134  if (debug)
135  fwLog(fwlog::kDebug) << "class " << iClass->GetName() << " uses "
136  << accessorName << "." << std::endl;
137  return boost::shared_ptr<FWItemAccessorBase>(FWItemAccessorRegistry::get()->create(accessorName, iClass));
138  }
139 
140  return boost::shared_ptr<FWItemAccessorBase>(new FWItemSingleAccessor(iClass));
141 }
#define debug
Definition: HDRShower.cc:19
#define fwLog(_level_)
Definition: fwLog.h:50
static bool hasTVirtualCollectionProxy(const TClass *iClass)
static bool hasMemberTVirtualCollectionProxy(const TClass *iClass, TClass *&oMember, size_t &oOffset)
static bool hasAccessor(const TClass *iClass, std::string &result)
T get(const Candidate &c)
Definition: component.h:55
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 228 of file FWItemAccessorFactory.cc.

References hasAccessor(), hasMemberTVirtualCollectionProxy(), hasTVirtualCollectionProxy(), HLT_25ns14e33_v1_cff::offset, and AlCaHLTBitMon_QueryRunRegistry::string.

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

229 {
230  std::string accessorName;
231  TClass *member = 0;
232  size_t offset=0;
233 
234  // This is pretty much the same thing that happens
237  || FWItemAccessorFactory::hasAccessor(iClass, accessorName));
238 }
static bool hasTVirtualCollectionProxy(const TClass *iClass)
static bool hasMemberTVirtualCollectionProxy(const TClass *iClass, TClass *&oMember, size_t &oOffset)
static bool hasAccessor(const TClass *iClass, std::string &result)
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 205 of file FWItemAccessorFactory.cc.

References edmplugin::PluginManager::categoryToInfos(), alignCSCRings::e, edmplugin::PluginManager::get(), i, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by accessorFor(), and classAccessedAsCollection().

206 {
207  const std::vector<edmplugin::PluginInfo> &available
208  = edmplugin::PluginManager::get()->categoryToInfos().find("cmsShow FWItemAccessorBase")->second;
209 
210  for (size_t i = 0, e = available.size(); i != e; ++i)
211  {
212  std::string name = available[i].name_;
213  std::string type = name.substr(0, name.find_first_of('@'));
214  if (iClass->GetTypeInfo()->name() == type)
215  {
216  result.swap(name);
217  return true;
218  }
219  }
220  return false;
221 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
static PluginManager * get()
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.

Returns
true if this is the case, false otherwise.

Definition at line 169 of file FWItemAccessorFactory.cc.

References assert(), edm::TypeDataMembers::begin(), dtTPAnalyzer_cfg::dataType, hasTVirtualCollectionProxy(), and edm::TypeDataMembers::size().

Referenced by accessorFor(), and classAccessedAsCollection().

172 {
173  assert(iClass->GetTypeInfo());
174  edm::TypeWithDict dataType(*(iClass->GetTypeInfo()));
175  assert(bool(dataType));
176 
177  // If the object has more than one data member, we avoid guessing.
179  if (members.size() != 1)
180  return false;
181 
182  edm::MemberWithDict member(*members.begin());
183  edm::TypeWithDict memType(member.typeOf());
184  assert(bool(memType));
185  oMember = TClass::GetClass(memType.typeInfo());
186  oOffset = member.offset();
187 
188  // Check if this is a collection known by ROOT but also that the item held by
189  // the colletion actually has a dictionary
190 
191  if (!hasTVirtualCollectionProxy(oMember))
192  return false;
193 
194  return true;
195 }
assert(m_qm.get())
static bool hasTVirtualCollectionProxy(const TClass *iClass)
bool FWItemAccessorFactory::hasTVirtualCollectionProxy ( const TClass *  iClass)
static

Helper method which

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

Definition at line 147 of file FWItemAccessorFactory.cc.

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

148 {
149  // Check if this is a collection known by ROOT but also that the item held by
150  // the colletion actually has a dictionary
151  return iClass &&
152  iClass->GetCollectionProxy() &&
153  iClass->GetCollectionProxy()->GetValueClass() &&
154  iClass->GetCollectionProxy()->GetValueClass()->IsLoaded();
155 }
const FWItemAccessorFactory& FWItemAccessorFactory::operator= ( const FWItemAccessorFactory )
private