CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

FWParameterSetterBase Class Reference

#include <Fireworks/Core/interface/FWParameterSetterBase.h>

Inheritance diagram for FWParameterSetterBase:
FWBoolParameterSetter FWDoubleParameterSetter FWEnumParameterSetter FWLongParameterSetter FWStringParameterSetter

List of all members.

Public Member Functions

void attach (FWParameterBase *, FWParameterSetterEditorBase *)
virtual TGFrame * build (TGFrame *iParent, bool labelBack=true)=0
 FWParameterSetterBase ()
virtual void setEnabled (bool)
virtual ~FWParameterSetterBase ()

Static Public Member Functions

static boost::shared_ptr
< FWParameterSetterBase
makeSetterFor (FWParameterBase *)

Protected Member Functions

FWParameterSetterEditorBaseframe () const
void update () const

Private Member Functions

virtual void attach (FWParameterBase *)=0
 FWParameterSetterBase (const FWParameterSetterBase &)
const FWParameterSetterBaseoperator= (const FWParameterSetterBase &)

Private Attributes

FWParameterSetterEditorBasem_frame

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 32 of file FWParameterSetterBase.h.


Constructor & Destructor Documentation

FWParameterSetterBase::FWParameterSetterBase ( )

Definition at line 41 of file FWParameterSetterBase.cc.

                                             :
   m_frame(0)
{
}
FWParameterSetterBase::~FWParameterSetterBase ( ) [virtual]

Definition at line 51 of file FWParameterSetterBase.cc.

{
}
FWParameterSetterBase::FWParameterSetterBase ( const FWParameterSetterBase ) [private]

Member Function Documentation

void FWParameterSetterBase::attach ( FWParameterBase iBase,
FWParameterSetterEditorBase iFrame 
)

Definition at line 72 of file FWParameterSetterBase.cc.

References m_frame.

{
   m_frame=iFrame;
   attach(iBase);
}
virtual void FWParameterSetterBase::attach ( FWParameterBase ) [private, pure virtual]
virtual TGFrame* FWParameterSetterBase::build ( TGFrame *  iParent,
bool  labelBack = true 
) [pure virtual]
FWParameterSetterEditorBase* FWParameterSetterBase::frame ( ) const [inline, protected]
boost::shared_ptr< FWParameterSetterBase > FWParameterSetterBase::makeSetterFor ( FWParameterBase iParam) [static]

Definition at line 95 of file FWParameterSetterBase.cc.

References fwLog, fwlog::kError, and mergeVDriftHistosByStation::name.

Referenced by FWViewEnergyScaleEditor::addParam(), ViewerParameterGUI::addParam(), FWGeometryTableView::FWGeometryTableView(), CmsShowCommonPopup::makeSetter(), and FWProxyBuilderConfiguration::makeSetter().

{
   static std::map<edm::TypeID,ROOT::Reflex::Type> s_paramToSetterMap;
   edm::TypeID paramType( typeid(*iParam) );
   std::map<edm::TypeID,ROOT::Reflex::Type>::iterator itFind = s_paramToSetterMap.find(paramType);
   if (itFind == s_paramToSetterMap.end())
   {
      ROOT::Reflex::Type paramClass( ROOT::Reflex::Type::ByTypeInfo(typeid(*iParam)) );
      if (paramClass == ROOT::Reflex::Type())
      {
         fwLog(fwlog::kError) << " the type "<<typeid(*iParam).name()<< " is not known to REFLEX" <<std::endl;
      }
      assert(paramClass != ROOT::Reflex::Type() );

      //the corresponding setter has the same name but with 'Setter' at the end
      std::string name = paramClass.Name();
      // FIXME: there was a convention between parameter class names and associated
      //        setters. The following works around the problem introduced by
      //        the generic parameter class but it is clear that a better 
      //        way of doing the binding is required. Notice that there are only 5 
      //        different type of FW*Parameter.
      if (name == "FWGenericParameter<bool>")
         name = "FWBoolParameterSetter";
      else if (name == "FWGenericParameter<std::string>")
         name = "FWStringParameterSetter";
      else if (name == "FWGenericParameter<std::basic_string<char> >")
         name = "FWStringParameterSetter"; 
      else if (name == "FWGenericParameterWithRange<double>")
         name = "FWDoubleParameterSetter";
      else if (name == "FWGenericParameterWithRange<long int>")
         name = "FWLongParameterSetter";
      else if (name == "FWGenericParameterWithRange<long>")
         name = "FWLongParameterSetter";
      else
         name += "Setter";

      ROOT::Reflex::Type setterClass( ROOT::Reflex::Type::ByName( name ) );
      if (setterClass == ROOT::Reflex::Type())
      {
         fwLog(fwlog::kError) << " the type "<<name<< " is not known to REFLEX" <<std::endl;
      }
      assert(setterClass != ROOT::Reflex::Type());

      s_paramToSetterMap[paramType]=setterClass;
      itFind = s_paramToSetterMap.find(paramType);
   }
   //create the instance we want
   //NOTE: for some odd reason Reflex 'Construct' uses 'malloc' to allocate the memory.  This means the object
   // can not be deleted using 'delete'!  So we must call Type::Destruct on the object
   ROOT::Reflex::Object setterObj = itFind->second.Construct();

   //make it into the base class
   ROOT::Reflex::Type s_setterBaseType( ROOT::Reflex::Type::ByTypeInfo( typeid(FWParameterSetterBase) ) );
   assert(s_setterBaseType != ROOT::Reflex::Type());
   ROOT::Reflex::Object castSetterObj = setterObj.CastObject(s_setterBaseType);
   boost::shared_ptr<FWParameterSetterBase> ptr(reinterpret_cast<FWParameterSetterBase*>( castSetterObj.Address() ),
                                                boost::bind(&ROOT::Reflex::Type::Destruct,itFind->second,setterObj.Address(),true));
   return ptr;
}
const FWParameterSetterBase& FWParameterSetterBase::operator= ( const FWParameterSetterBase ) [private]
void FWParameterSetterBase::setEnabled ( bool  ) [virtual]

Reimplemented in FWEnumParameterSetter, FWBoolParameterSetter, and FWDoubleParameterSetter.

Definition at line 157 of file FWParameterSetterBase.cc.

{
}
void FWParameterSetterBase::update ( void  ) const [protected]

Member Data Documentation

Definition at line 63 of file FWParameterSetterBase.h.

Referenced by attach(), frame(), and update().