CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< FWParameterSetterBase
makeSetterFor (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::FWParameterSetterBase ( )

Definition at line 40 of file FWParameterSetterBase.cc.

40 : m_frame(nullptr) {}
FWParameterSetterEditorBase * m_frame
FWParameterSetterBase::~FWParameterSetterBase ( )
virtual

Definition at line 47 of file FWParameterSetterBase.cc.

47 {}
FWParameterSetterBase::FWParameterSetterBase ( const FWParameterSetterBase )
delete

Member Function Documentation

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
virtual void FWParameterSetterBase::attach ( FWParameterBase )
privatepure virtual
virtual TGFrame* FWParameterSetterBase::build ( TGFrame *  iParent,
bool  labelBack = true 
)
pure virtual
FWParameterSetterEditorBase* FWParameterSetterBase::frame ( ) const
inlineprotected
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(), fwLog, fwlog::kError, mergeVDriftHistosByStation::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 == "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 
116  edm::TypeWithDict setterClass(edm::TypeWithDict::byName(name));
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 }
void * address() const
assert(be >=bs)
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
#define fwLog(_level_)
Definition: fwLog.h:45
void destruct(void *address, bool dealloc=true) const
const FWParameterSetterBase& FWParameterSetterBase::operator= ( const FWParameterSetterBase )
delete
void FWParameterSetterBase::setEnabled ( bool  )
virtual

Reimplemented in FWEnumParameterSetter, FWDoubleParameterSetter, and FWBoolParameterSetter.

Definition at line 139 of file FWParameterSetterBase.cc.

139 {}
void FWParameterSetterBase::update ( ) const
protected

Member Data Documentation

FWParameterSetterEditorBase* FWParameterSetterBase::m_frame
private

Definition at line 62 of file FWParameterSetterBase.h.

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