Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Reflex/Type.h"
00016 #include "Reflex/Object.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 void
00083 FWParameterSetterBase::update() const
00084 {
00085 if (m_frame != 0)
00086 m_frame->updateEditor();
00087 }
00088
00089
00090
00091
00092 boost::shared_ptr<FWParameterSetterBase>
00093 FWParameterSetterBase::makeSetterFor(FWParameterBase* iParam)
00094 {
00095 static std::map<edm::TypeID,ROOT::Reflex::Type> s_paramToSetterMap;
00096 edm::TypeID paramType( typeid(*iParam) );
00097 std::map<edm::TypeID,ROOT::Reflex::Type>::iterator itFind = s_paramToSetterMap.find(paramType);
00098 if( itFind == s_paramToSetterMap.end() ) {
00099 ROOT::Reflex::Type paramClass( ROOT::Reflex::Type::ByTypeInfo(typeid(*iParam)) );
00100 if(paramClass == ROOT::Reflex::Type() ) {
00101 fwLog(fwlog::kError) << " the type "<<typeid(*iParam).name()<< " is not known to REFLEX" <<std::endl;
00102 }
00103 assert(paramClass != ROOT::Reflex::Type() );
00104
00105
00106 std::string name = paramClass.Name();
00107
00108
00109
00110
00111
00112 if (name == "FWGenericParameter<bool>")
00113 name = "FWBoolParameterSetter";
00114 else if (name == "FWGenericParameter<std::string>")
00115 name = "FWStringParameterSetter";
00116 else if (name == "FWGenericParameter<std::basic_string<char> >")
00117 name = "FWStringParameterSetter";
00118 else if (name == "FWGenericParameterWithRange<double>")
00119 name = "FWDoubleParameterSetter";
00120 else if (name == "FWGenericParameterWithRange<long int>")
00121 name = "FWLongParameterSetter";
00122 else if (name == "FWGenericParameterWithRange<long>")
00123 name = "FWLongParameterSetter";
00124 else
00125 name += "Setter";
00126
00127 ROOT::Reflex::Type setterClass( ROOT::Reflex::Type::ByName( name ) );
00128 if(setterClass == ROOT::Reflex::Type() ) {
00129 fwLog(fwlog::kError) << " the type "<<name<< " is not known to REFLEX" <<std::endl;
00130 }
00131 assert(setterClass != ROOT::Reflex::Type());
00132
00133 s_paramToSetterMap[paramType]=setterClass;
00134 itFind = s_paramToSetterMap.find(paramType);
00135 }
00136
00137
00138
00139 ROOT::Reflex::Object setterObj = itFind->second.Construct();
00140
00141
00142 ROOT::Reflex::Type s_setterBaseType( ROOT::Reflex::Type::ByTypeInfo( typeid(FWParameterSetterBase) ) );
00143 assert(s_setterBaseType != ROOT::Reflex::Type());
00144 ROOT::Reflex::Object castSetterObj = setterObj.CastObject(s_setterBaseType);
00145 boost::shared_ptr<FWParameterSetterBase> ptr(reinterpret_cast<FWParameterSetterBase*>( castSetterObj.Address() ),
00146 boost::bind(&ROOT::Reflex::Type::Destruct,itFind->second,setterObj.Address(),true));
00147 return ptr;
00148 }
00149
00150
00151 void
00152 FWParameterSetterBase::setEnabled(bool)
00153 {
00154 }