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 ()
 
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
 
 FWParameterSetterBase (const FWParameterSetterBase &)=delete
 
const FWParameterSetterBaseoperator= (const FWParameterSetterBase &)=delete
 

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) {}

◆ ~FWParameterSetterBase()

FWParameterSetterBase::~FWParameterSetterBase ( )
virtual

Definition at line 47 of file FWParameterSetterBase.cc.

47 {}

◆ FWParameterSetterBase() [2/2]

FWParameterSetterBase::FWParameterSetterBase ( const FWParameterSetterBase )
privatedelete

Member Function Documentation

◆ attach() [1/2]

virtual void FWParameterSetterBase::attach ( FWParameterBase )
privatepure virtual

◆ attach() [2/2]

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

Definition at line 65 of file FWParameterSetterBase.cc.

65  {
66  m_frame = iFrame;
67  attach(iBase);
68 }

References m_frame.

◆ 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.

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 == "FWGenericParameter<std::string>")
104  name = "FWStringParameterSetter";
105  else if (name == "FWGenericParameter<std::basic_string<char> >")
106  name = "FWStringParameterSetter";
107  else if (name == "FWGenericParameterWithRange<double>")
108  name = "FWDoubleParameterSetter";
109  else if (name == "FWGenericParameterWithRange<long int>")
110  name = "FWLongParameterSetter";
111  else if (name == "FWGenericParameterWithRange<long>")
112  name = "FWLongParameterSetter";
113  else
114  name += "Setter";
115 
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, boost::bind(&edm::TypeWithDict::destruct, itFind->second, setterObj.address(), true));
135  return ptr;
136 }

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

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

◆ operator=()

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

◆ 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 61 of file FWParameterSetterBase.h.

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

edm::TypeWithDict::byName
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
edm::TypeWithDict::destruct
void destruct(void *address, bool dealloc=true) const
Definition: TypeWithDict.cc:798
edm::ObjectWithDict::address
void * address() const
Definition: ObjectWithDict.cc:27
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FWParameterSetterBase
Definition: FWParameterSetterBase.h:31
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
FWParameterSetterBase::attach
void attach(FWParameterBase *, FWParameterSetterEditorBase *)
Definition: FWParameterSetterBase.cc:65
cms::cuda::assert
assert(be >=bs)
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::TypeWithDict
Definition: TypeWithDict.h:38
FWParameterSetterEditorBase::updateEditor
virtual void updateEditor()
Definition: FWParameterSetterEditorBase.cc:55
FWParameterSetterBase::m_frame
FWParameterSetterEditorBase * m_frame
Definition: FWParameterSetterBase.h:61
edm::TypeID
Definition: TypeID.h:22
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
fwlog::kError
Definition: fwLog.h:35