Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "FWCore/Utilities/interface/TypeWithDict.h"
00016 #include "FWCore/Utilities/interface/ObjectWithDict.h"
00017
00018 #include <assert.h>
00019 #include <iostream>
00020 #include <boost/bind.hpp>
00021
00022
00023 #include "FWCore/Utilities/interface/TypeID.h"
00024
00025 #include "Fireworks/Core/interface/FWParameterSetterBase.h"
00026 #include "Fireworks/Core/interface/FWParameterBase.h"
00027 #include "Fireworks/Core/interface/FWParameterSetterEditorBase.h"
00028 #include "Fireworks/Core/interface/fwLog.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 FWParameterSetterBase::FWParameterSetterBase() :
00042 m_frame(0)
00043 {
00044 }
00045
00046
00047
00048
00049
00050
00051 FWParameterSetterBase::~FWParameterSetterBase()
00052 {
00053 }
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 void
00072 FWParameterSetterBase::attach(FWParameterBase* iBase, FWParameterSetterEditorBase* iFrame)
00073 {
00074 m_frame=iFrame;
00075 attach(iBase);
00076 }
00077
00078
00079
00080
00081
00082
00083 void
00084 FWParameterSetterBase::update() const
00085 {
00086 if (m_frame != 0)
00087 m_frame->updateEditor();
00088 }
00089
00090
00091
00092
00093
00094 boost::shared_ptr<FWParameterSetterBase>
00095 FWParameterSetterBase::makeSetterFor(FWParameterBase* iParam)
00096 {
00097 static std::map<edm::TypeID,edm::TypeWithDict> s_paramToSetterMap;
00098 edm::TypeID paramType( typeid(*iParam) );
00099 std::map<edm::TypeID,edm::TypeWithDict>::iterator itFind = s_paramToSetterMap.find(paramType);
00100 if (itFind == s_paramToSetterMap.end())
00101 {
00102 edm::TypeWithDict paramClass(typeid(*iParam));
00103 if (paramClass == edm::TypeWithDict())
00104 {
00105 fwLog(fwlog::kError) << " the type "<<typeid(*iParam).name()<< " is not known to Root" <<std::endl;
00106 }
00107 assert(paramClass != edm::TypeWithDict() );
00108
00109
00110 std::string name = paramClass.name();
00111
00112
00113
00114
00115
00116 if (name == "FWGenericParameter<bool>")
00117 name = "FWBoolParameterSetter";
00118 else if (name == "FWGenericParameter<std::string>")
00119 name = "FWStringParameterSetter";
00120 else if (name == "FWGenericParameter<std::basic_string<char> >")
00121 name = "FWStringParameterSetter";
00122 else if (name == "FWGenericParameterWithRange<double>")
00123 name = "FWDoubleParameterSetter";
00124 else if (name == "FWGenericParameterWithRange<long int>")
00125 name = "FWLongParameterSetter";
00126 else if (name == "FWGenericParameterWithRange<long>")
00127 name = "FWLongParameterSetter";
00128 else
00129 name += "Setter";
00130
00131 edm::TypeWithDict setterClass( edm::TypeWithDict::byName( name ) );
00132 if (setterClass == edm::TypeWithDict())
00133 {
00134 fwLog(fwlog::kError) << " the type "<<name<< " has no dictionary" <<std::endl;
00135 }
00136 assert(setterClass != edm::TypeWithDict());
00137
00138 s_paramToSetterMap[paramType]=setterClass;
00139 itFind = s_paramToSetterMap.find(paramType);
00140 }
00141
00142
00143
00144 edm::ObjectWithDict setterObj = itFind->second.construct();
00145
00146
00147 edm::TypeWithDict s_setterBaseType(typeid(FWParameterSetterBase));
00148 assert(bool(s_setterBaseType));
00149 edm::ObjectWithDict castSetterObj(setterObj.castObject(s_setterBaseType));
00150 boost::shared_ptr<FWParameterSetterBase> ptr(reinterpret_cast<FWParameterSetterBase*>( castSetterObj.address() ),
00151 boost::bind(&edm::TypeWithDict::destruct,itFind->second,setterObj.address(),true));
00152 return ptr;
00153 }
00154
00155
00156 void
00157 FWParameterSetterBase::setEnabled(bool)
00158 {
00159 }