CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //
tuple base
Main Program
Definition: newFWLiteAna.py:92
const std::string & purpose() const
FWRepresentationInfo infoFor(const std::string &iTypeName) const override
std::shared_ptr< FWItemAccessorBase > accessorFor(const TClass *) const
FWSimpleRepresentationChecker(const std::string &iTypeidName, const std::string &iPurpose, unsigned int iBitPackedViews, bool iRepresentsSubPart, bool iRequiresFF=false)
size_t size() const
static bool inheritsFrom(const edm::TypeWithDict &iChild, const std::string &iParentTypeName, unsigned int &distance)
TClass * getClass() const
std::type_info const & typeInfo() const