Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include "TClass.h"
00017 #include "FWCore/Utilities/interface/BaseWithDict.h"
00018
00019
00020 #include "Fireworks/Core/interface/FWSimpleRepresentationChecker.h"
00021
00022 #include "Fireworks/Core/interface/FWRepresentationInfo.h"
00023
00024 #include "Fireworks/Core/interface/FWItemAccessorFactory.h"
00025 #include "Fireworks/Core/interface/FWItemAccessorBase.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 FWSimpleRepresentationChecker::FWSimpleRepresentationChecker(const std::string& iTypeName,
00039 const std::string& iPurpose,
00040 unsigned int iBitPackedViews,
00041 bool iRepresentsSubPart) :
00042 FWRepresentationCheckerBase(iPurpose,iBitPackedViews,iRepresentsSubPart),
00043 m_typeidName(iTypeName)
00044 {
00045 }
00046
00047
00048
00049
00050
00051
00052 FWSimpleRepresentationChecker::~FWSimpleRepresentationChecker()
00053 {
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 static bool inheritsFrom(const edm::TypeWithDict& iChild,
00076 const std::string& iParentTypeName,
00077 unsigned int& distance) {
00078 if(iChild.typeInfo().name() == iParentTypeName) {
00079 return true;
00080 }
00081 edm::TypeBases bases(iChild);
00082 if(bases.size() == 0) {
00083 return false;
00084 }
00085 ++distance;
00086 for(auto const& base : bases) {
00087 if(inheritsFrom(edm::BaseWithDict(base).typeOf(),iParentTypeName,distance)) {
00088 return true;
00089 }
00090 }
00091 --distance;
00092 return false;
00093 }
00094
00095 FWRepresentationInfo
00096 FWSimpleRepresentationChecker::infoFor(const std::string& iTypeName) const
00097 {
00098 unsigned int distance=1;
00099
00100 FWItemAccessorFactory factory;
00101
00102 TClass* clss = TClass::GetClass(iTypeName.c_str());
00103
00104 if(0==clss || 0==clss->GetTypeInfo()) {
00105 return FWRepresentationInfo();
00106 }
00107 boost::shared_ptr<FWItemAccessorBase> accessor = factory.accessorFor(clss);
00108
00109 const TClass* modelClass = accessor->modelType();
00110
00111
00112 if(0==modelClass || 0 == modelClass->GetTypeInfo()) {
00113
00114
00115 return FWRepresentationInfo();
00116 }
00117 edm::TypeWithDict modelType( *(modelClass->GetTypeInfo()));
00118
00119
00120 if(inheritsFrom(modelType,m_typeidName,distance) ) {
00121 return FWRepresentationInfo(purpose(),distance,bitPackedViews(), representsSubPart());
00122 }
00123 return FWRepresentationInfo();
00124 }
00125
00126
00127
00128