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 "Reflex/Base.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 ROOT::Reflex::Type& iChild,
00076 const std::string& iParentTypeName,
00077 unsigned int& distance) {
00078 if(iChild.TypeInfo().name() == iParentTypeName) {
00079 return true;
00080 }
00081 if(iChild.BaseSize() == 0) {
00082 return false;
00083 }
00084 ++distance;
00085 for(ROOT::Reflex::Base_Iterator it = iChild.Base_Begin(),
00086 itEnd = iChild.Base_End();
00087 it != itEnd;
00088 ++it) {
00089 if(inheritsFrom(it->ToType(),iParentTypeName,distance)) {
00090 return true;
00091 }
00092 }
00093 --distance;
00094 return false;
00095 }
00096
00097 FWRepresentationInfo
00098 FWSimpleRepresentationChecker::infoFor(const std::string& iTypeName) const
00099 {
00100 unsigned int distance=1;
00101
00102 FWItemAccessorFactory factory;
00103
00104 TClass* clss = TClass::GetClass(iTypeName.c_str());
00105
00106 if(0==clss || 0==clss->GetTypeInfo()) {
00107 return FWRepresentationInfo();
00108 }
00109 boost::shared_ptr<FWItemAccessorBase> accessor = factory.accessorFor(clss);
00110
00111 const TClass* modelClass = accessor->modelType();
00112
00113
00114 if(0==modelClass || 0 == modelClass->GetTypeInfo()) {
00115
00116
00117 return FWRepresentationInfo();
00118 }
00119 ROOT::Reflex::Type modelType =
00120 ROOT::Reflex::Type::ByTypeInfo( *(modelClass->GetTypeInfo()));
00121
00122
00123 if(inheritsFrom(modelType,m_typeidName,distance) ) {
00124 return FWRepresentationInfo(purpose(),distance,bitPackedViews(), representsSubPart());
00125 }
00126 return FWRepresentationInfo();
00127 }
00128
00129
00130
00131