CMS 3D CMS Logo

FWSimpleRepresentationChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWSimpleRepresentationChecker
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Nov 25 10:54:28 EST 2008
11 //
12 
13 // system include files
14 #include <iostream>
15 #include "TClass.h"
17 
18 // user include files
20 
22 
25 
26 //
27 // constants, enums and typedefs
28 //
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38  const std::string& iPurpose,
39  unsigned int iBitPackedViews,
40  bool iRepresentsSubPart,
41  bool iRequiresFF)
42  : FWRepresentationCheckerBase(iPurpose, iBitPackedViews, iRepresentsSubPart, iRequiresFF),
43  m_typeidName(iTypeName) {}
44 
45 // FWSimpleRepresentationChecker::FWSimpleRepresentationChecker(const FWSimpleRepresentationChecker& rhs)
46 // {
47 // // do actual copying here;
48 // }
49 
51 
52 //
53 // assignment operators
54 //
55 // const FWSimpleRepresentationChecker& FWSimpleRepresentationChecker::operator=(const FWSimpleRepresentationChecker& rhs)
56 // {
57 // //An exception safe implementation is
58 // FWSimpleRepresentationChecker temp(rhs);
59 // swap(rhs);
60 //
61 // return *this;
62 // }
63 
64 //
65 // member functions
66 //
67 
68 //
69 // const member functions
70 //
72  const std::string& iParentTypeName,
73  unsigned int& distance) {
74  if (iChild.getClass()) {
75  if (iChild.getClass()->GetTypeInfo() == nullptr) {
76  return false;
77  }
78  }
79 
80  if (iChild.typeInfo().name() == iParentTypeName) {
81  return true;
82  }
83  edm::TypeBases bases(iChild);
84  if (bases.size() == 0) {
85  return false;
86  }
87  ++distance;
88  for (auto const& base : bases) {
89  if (inheritsFrom(edm::BaseWithDict(base).typeOf(), iParentTypeName, distance)) {
90  return true;
91  }
92  }
93  --distance;
94  return false;
95 }
96 
98  unsigned int distance = 1;
99 
100  FWItemAccessorFactory factory;
101  //std::cout<<"checker infoFor"<<iTypeName<<std::endl;
102  TClass* clss = TClass::GetClass(iTypeName.c_str());
103  //Class could be unknown if the dictionary for it has not been loaded
104  if (nullptr == clss || nullptr == clss->GetTypeInfo()) {
105  return FWRepresentationInfo();
106  }
107  std::shared_ptr<FWItemAccessorBase> accessor = factory.accessorFor(clss);
108 
109  const TClass* modelClass = accessor->modelType();
110  //std::cout <<" "<<modelClass->GetName()<<" "<< bool(modelClass == clss)<< std::endl;
111 
112  if (nullptr == modelClass || nullptr == modelClass->GetTypeInfo()) {
113  //some containers e.g. vector<int> do not have known TClasses for their elements
114  // or the contained type may be unknown to ROOT
115  return FWRepresentationInfo();
116  }
117  edm::TypeWithDict modelType(*(modelClass->GetTypeInfo()));
118  //see if the modelType inherits from our type
119 
120  if (inheritsFrom(modelType, m_typeidName, distance)) {
122  }
123  return FWRepresentationInfo();
124 }
125 
126 //
127 // static member functions
128 //
FWSimpleRepresentationChecker::m_typeidName
const std::string m_typeidName
Definition: FWSimpleRepresentationChecker.h:52
BaseWithDict.h
FWItemAccessorFactory::accessorFor
std::shared_ptr< FWItemAccessorBase > accessorFor(const TClass *) const
Definition: FWItemAccessorFactory.cc:89
FWRepresentationInfo.h
FWItemAccessorFactory.h
FWSimpleRepresentationChecker::inheritsFrom
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
Definition: FWSimpleRepresentationChecker.cc:71
FWItemAccessorFactory
Definition: FWItemAccessorFactory.h:31
edm::BaseWithDict
Definition: BaseWithDict.h:18
FWRepresentationCheckerBase::purpose
const std::string & purpose() const
Definition: FWRepresentationCheckerBase.cc:64
FWSimpleRepresentationChecker::FWSimpleRepresentationChecker
FWSimpleRepresentationChecker(const std::string &iTypeidName, const std::string &iPurpose, unsigned int iBitPackedViews, bool iRepresentsSubPart, bool iRequiresFF=false)
Definition: FWSimpleRepresentationChecker.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::TypeWithDict
Definition: TypeWithDict.h:38
FWRepresentationCheckerBase::bitPackedViews
unsigned int bitPackedViews() const
Definition: FWRepresentationCheckerBase.cc:66
edm::TypeWithDict::typeInfo
std::type_info const & typeInfo() const
Definition: TypeWithDict.cc:357
FWItemAccessorBase.h
FWRepresentationCheckerBase::requiresFF
bool requiresFF() const
Definition: FWRepresentationCheckerBase.h:44
FWRepresentationInfo
Definition: FWRepresentationInfo.h:28
edm::TypeWithDict::getClass
TClass * getClass() const
Definition: TypeWithDict.cc:380
FWSimpleRepresentationChecker.h
FWRepresentationCheckerBase::representsSubPart
bool representsSubPart() const
Definition: FWRepresentationCheckerBase.cc:68
FWSimpleRepresentationChecker::~FWSimpleRepresentationChecker
~FWSimpleRepresentationChecker() override
Definition: FWSimpleRepresentationChecker.cc:50
FWRepresentationCheckerBase
Definition: FWRepresentationCheckerBase.h:28
edm::TypeBases::size
size_t size() const
Definition: TypeWithDict.cc:847
edm::TypeBases
Definition: TypeWithDict.h:153
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
FWSimpleRepresentationChecker::infoFor
FWRepresentationInfo infoFor(const std::string &iTypeName) const override
Definition: FWSimpleRepresentationChecker.cc:97