CMS 3D CMS Logo

FWProxyBuilderConfiguration.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWProxyBuilderConfiguration
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author:
10 // Created: Wed Jul 27 00:58:43 CEST 2011
11 //
12 
13 // system include files
14 
15 // user include files
16 #include <iostream>
17 #include <stdexcept>
18 #include <boost/bind.hpp>
19 
20 #include "TGFrame.h"
21 
31 
33  : m_txtConfig(c), m_item(item), m_keepEntries(false) {}
34 
36 
37 //______________________________________________________________________________
38 
40  if (begin() != end()) {
41  FWConfiguration vTmp;
43  iTo.addKeyValue("Var", vTmp, true);
44  }
45 }
46 
48  /*
49  for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it)
50  std::cout << it->first << "FWProxyBuilderConfiguration::setFrom " << std::endl;
51  }*/
52 }
53 
54 //______________________________________________________________________________
55 
57  // std::cout << "make setter " << pb->name() << std::endl;
58 
59  std::shared_ptr<FWParameterSetterBase> ptr(FWParameterSetterBase::makeSetterFor(pb));
60  ptr->attach(pb, this);
61  TGFrame* tmpFrame = ptr->build(frame, false);
62  frame->AddFrame(tmpFrame, new TGLayoutHints(kLHintsExpandX));
63  m_setters.push_back(ptr);
64 }
65 
66 void FWProxyBuilderConfiguration::populateFrame(TGCompositeFrame* settersFrame) {
67  // std::cout << "populate \n";
68 
69  TGCompositeFrame* frame = new TGVerticalFrame(settersFrame);
70  settersFrame->AddFrame(frame, new TGLayoutHints(kLHintsExpandX)); //|kLHintsExpandY
71 
72  for (const_iterator it = begin(); it != end(); ++it)
73  makeSetter(frame, *it);
74 
75  settersFrame->MapSubwindows();
76 }
77 
79 
80 //______________________________________________________________________________
81 
82 template <class T>
84  for (const_iterator i = begin(); i != end(); ++i) {
85  if ((*i)->name() == name) {
86  return nullptr;
87  }
88  }
89 
91 
92  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
93  if (m_txtConfig) {
94  const FWConfiguration* varConfig = m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : nullptr;
95  if (varConfig)
96  mode->setFrom(*varConfig);
97  }
98  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item, m_keepEntries));
99  return mode;
100 }
101 
102 template <class T>
104  for (const_iterator i = begin(); i != end(); ++i) {
105  if ((*i)->name() == name) {
106  return nullptr;
107  }
108  }
109 
111 
112  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
113  const FWConfiguration* varConfig =
114  m_txtConfig && m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : nullptr;
115  if (varConfig)
116  mode->setFrom(*varConfig);
117 
118  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item, m_keepEntries));
119  return mode;
120 }
121 
122 template <class T>
124  FWGenericParameter<T>* param = nullptr;
125 
127  if ((*i)->name() == pname) {
128  param = (FWGenericParameter<T>*)(*i);
129  break;
130  }
131  }
132 
133  if (param)
134  return param->value();
135  else
136  throw std::runtime_error("Invalid parameter request.");
137 }
138 
139 // explicit template instantiation
140 
141 template bool FWProxyBuilderConfiguration::value<bool>(const std::string& name);
142 template long FWProxyBuilderConfiguration::value<long>(const std::string& name);
143 template double FWProxyBuilderConfiguration::value<double>(const std::string& name);
144 
147  long def,
148  long min,
149  long max);
151  double def,
152  double min,
153  double max);
FWModelChangeManager.h
FWParameterizable::const_iterator
std::vector< FWParameterBase * >::const_iterator const_iterator
Definition: FWParameterizable.h:34
mps_fire.i
i
Definition: mps_fire.py:355
funct::false
false
Definition: Factorize.h:34
FWGenericParameterWithRange
Definition: FWGenericParameterWithRange.h:27
FWProxyBuilderConfiguration::m_setters
std::vector< std::shared_ptr< FWParameterSetterBase > > m_setters
Definition: FWProxyBuilderConfiguration.h:69
min
T min(T a, T b)
Definition: MathUtil.h:58
FWParameterBase
Definition: FWParameterBase.h:31
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
FWEventItem::proxyConfigChanged
void proxyConfigChanged(bool k=false)
Definition: FWEventItem.cc:330
FWParameterizable::end
const_iterator end() const
Definition: FWParameterizable.h:38
FWParameterizable::begin
const_iterator begin() const
Definition: FWParameterizable.h:36
FWGenericParameter
Definition: FWGenericParameter.h:31
FWItemChangeSignal.h
FWProxyBuilderConfiguration::FWProxyBuilderConfiguration
FWProxyBuilderConfiguration(const FWConfiguration *c, const FWEventItem *item)
Definition: FWProxyBuilderConfiguration.cc:32
FWParameterBase.h
FWProxyBuilderConfiguration::keepEntries
void keepEntries(bool b)
Definition: FWProxyBuilderConfiguration.cc:78
FWConfiguration::valueForKey
const FWConfiguration * valueForKey(const std::string &iKey) const
Definition: FWConfiguration.cc:121
b
double b
Definition: hdecay.h:118
unpackData-CaloStage2.pname
pname
Definition: unpackData-CaloStage2.py:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWProxyBuilderConfiguration::assertParam
FWGenericParameter< T > * assertParam(const std::string &name, T def)
Definition: FWProxyBuilderConfiguration.cc:83
FWProxyBuilderConfiguration::~FWProxyBuilderConfiguration
~FWProxyBuilderConfiguration() override
Definition: FWProxyBuilderConfiguration.cc:35
FWProxyBuilderConfiguration::setFrom
void setFrom(const FWConfiguration &iFrom) override
Definition: FWProxyBuilderConfiguration.cc:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
FWProxyBuilderConfiguration.h
FWEnumParameter.h
FWGenericParameter.h
FWProxyBuilderConfiguration::m_keepEntries
bool m_keepEntries
Definition: FWProxyBuilderConfiguration.h:67
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
fwLog.h
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
FWEventItem.h
FWParameterSetterBase::makeSetterFor
static std::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
Definition: FWParameterSetterBase.cc:83
FWGenericParameter::value
T value() const
Definition: FWGenericParameter.h:50
FWConfiguration::addKeyValue
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
Definition: FWConfiguration.cc:57
FWEventItem
Definition: FWEventItem.h:56
FWConfigurableParameterizable::addTo
void addTo(FWConfiguration &) const override
Definition: FWConfigurableParameterizable.cc:67
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
T
long double T
Definition: Basic3DVectorLD.h:48
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
FWConfiguration::keyValues
const KeyValues * keyValues() const
Definition: FWConfiguration.h:51
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
FWProxyBuilderConfiguration::addTo
void addTo(FWConfiguration &iTo) const override
Definition: FWProxyBuilderConfiguration.cc:39
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
FWConfiguration
Definition: FWConfiguration.h:31
FWProxyBuilderConfiguration::m_item
const FWEventItem * m_item
Definition: FWProxyBuilderConfiguration.h:65
FWProxyBuilderConfiguration::populateFrame
void populateFrame(TGCompositeFrame *frame)
Definition: FWProxyBuilderConfiguration.cc:66
FWProxyBuilderConfiguration::makeSetter
void makeSetter(TGCompositeFrame *, FWParameterBase *)
Definition: FWProxyBuilderConfiguration.cc:56
FWConfiguration.h
FWProxyBuilderConfiguration::m_txtConfig
const FWConfiguration * m_txtConfig
Definition: FWProxyBuilderConfiguration.h:64