CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
FWParameterSetterBase Class Referenceabstract

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

Inheritance diagram for FWParameterSetterBase:
FWBoolParameterSetter FWDoubleParameterSetter FWEnumParameterSetter FWLongParameterSetter FWStringParameterSetter

Public Member Functions

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

Static Public Member Functions

static std::shared_ptr< FWParameterSetterBasemakeSetterFor (FWParameterBase *)
 

Protected Member Functions

FWParameterSetterEditorBaseframe () const
 
void update () const
 

Private Member Functions

virtual void attach (FWParameterBase *)=0
 

Private Attributes

FWParameterSetterEditorBasem_frame
 

Detailed Description

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

Usage: <usage>

Definition at line 31 of file FWParameterSetterBase.h.

Constructor & Destructor Documentation

◆ FWParameterSetterBase() [1/2]

FWParameterSetterBase::FWParameterSetterBase ( )

Definition at line 40 of file FWParameterSetterBase.cc.

40 : m_frame(nullptr) {}
FWParameterSetterEditorBase * m_frame

◆ ~FWParameterSetterBase()

FWParameterSetterBase::~FWParameterSetterBase ( )
virtual

Definition at line 47 of file FWParameterSetterBase.cc.

47 {}

◆ FWParameterSetterBase() [2/2]

FWParameterSetterBase::FWParameterSetterBase ( const FWParameterSetterBase )
delete

Member Function Documentation

◆ attach() [1/2]

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

Definition at line 65 of file FWParameterSetterBase.cc.

References m_frame.

65  {
66  m_frame = iFrame;
67  attach(iBase);
68 }
void attach(FWParameterBase *, FWParameterSetterEditorBase *)
FWParameterSetterEditorBase * m_frame

◆ attach() [2/2]

virtual void FWParameterSetterBase::attach ( FWParameterBase )
privatepure virtual

◆ build()

virtual TGFrame* FWParameterSetterBase::build ( TGFrame *  iParent,
bool  labelBack = true 
)
pure virtual

◆ frame()

FWParameterSetterEditorBase* FWParameterSetterBase::frame ( ) const
inlineprotected

◆ makeSetterFor()

std::shared_ptr< FWParameterSetterBase > FWParameterSetterBase::makeSetterFor ( FWParameterBase iParam)
static

Definition at line 83 of file FWParameterSetterBase.cc.

References edm::ObjectWithDict::address(), cms::cuda::assert(), edm::TypeWithDict::byName(), edm::TypeWithDict::destruct(), edm::TypeWithDict::friendlyClassName(), fwLog, fwlog::kError, fwlog::kWarning, Skims_PA_cff::name, FWParameterBase::name(), edm::TypeWithDict::name(), AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

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

83  {
84  static std::map<edm::TypeID, edm::TypeWithDict> s_paramToSetterMap;
85  edm::TypeID paramType(typeid(*iParam));
86  std::map<edm::TypeID, edm::TypeWithDict>::iterator itFind = s_paramToSetterMap.find(paramType);
87  if (itFind == s_paramToSetterMap.end()) {
88  edm::TypeWithDict paramClass(typeid(*iParam));
89  if (paramClass == edm::TypeWithDict()) {
90  fwLog(fwlog::kError) << " the type " << typeid(*iParam).name() << " is not known to Root" << std::endl;
91  }
92  assert(paramClass != edm::TypeWithDict());
93 
94  //the corresponding setter has the same name but with 'Setter' at the end
95  std::string name = paramClass.name();
96  // FIXME: there was a convention between parameter class names and associated
97  // setters. The following works around the problem introduced by
98  // the generic parameter class but it is clear that a better
99  // way of doing the binding is required. Notice that there are only 5
100  // different type of FW*Parameter.
101  if (name == "FWGenericParameter<bool>")
102  name = "FWBoolParameterSetter";
103  else if (name == "FWGenericParameterWithRange<double>")
104  name = "FWDoubleParameterSetter";
105  else if (name == "FWGenericParameterWithRange<long int>")
106  name = "FWLongParameterSetter";
107  else if (name == "FWGenericParameterWithRange<long>")
108  name = "FWLongParameterSetter";
109  else if (paramClass.friendlyClassName() == "StringFWGenericParameter")
110  name = "FWStringParameterSetter";
111  else {
112  name += "Setter";
113  fwLog(fwlog::kWarning) << "can't find setter type for " << iParam->name() << ", guessing to " << name << "\n";
114  }
116 
117  if (setterClass == edm::TypeWithDict()) {
118  fwLog(fwlog::kError) << " the type " << name << " has no dictionary" << std::endl;
119  }
120  assert(setterClass != edm::TypeWithDict());
121 
122  s_paramToSetterMap[paramType] = setterClass;
123  itFind = s_paramToSetterMap.find(paramType);
124  }
125  //create the instance we want
126  //NOTE: 'construct' will use 'malloc' to allocate the memory if the object is not of class type.
127  // This means the object cannot be deleted using 'delete'! So we must call destruct on the object.
128  edm::ObjectWithDict setterObj = itFind->second.construct();
129 
130  //make it into the base class
131  FWParameterSetterBase* p = static_cast<FWParameterSetterBase*>(setterObj.address());
132  //Make a shared pointer to the base class that uses a destructor for the derived class, in order to match the above construct call.
133  std::shared_ptr<FWParameterSetterBase> ptr(
134  p, std::bind(&edm::TypeWithDict::destruct, itFind->second, setterObj.address(), true));
135  return ptr;
136 }
assert(be >=bs)
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
const std::string & name() const
void destruct(void *address, bool dealloc=true) const
#define fwLog(_level_)
Definition: fwLog.h:45
void * address() const

◆ operator=()

const FWParameterSetterBase& FWParameterSetterBase::operator= ( const FWParameterSetterBase )
delete

◆ setEnabled()

void FWParameterSetterBase::setEnabled ( bool  )
virtual

Reimplemented in FWEnumParameterSetter, FWDoubleParameterSetter, and FWBoolParameterSetter.

Definition at line 139 of file FWParameterSetterBase.cc.

139 {}

◆ update()

void FWParameterSetterBase::update ( ) const
protected

Member Data Documentation

◆ m_frame

FWParameterSetterEditorBase* FWParameterSetterBase::m_frame
private

Definition at line 62 of file FWParameterSetterBase.h.

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