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 <functional>
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(std::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(std::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);
void populateFrame(TGCompositeFrame *frame)
void proxyConfigChanged(bool k=false)
Definition: FWEventItem.cc:330
int def(FILE *, FILE *, int)
const_iterator begin() const
void addTo(FWConfiguration &iTo) const override
std::vector< FWParameterBase * >::const_iterator const_iterator
const_iterator end() const
FWProxyBuilderConfiguration(const FWConfiguration *c, const FWEventItem *item)
std::vector< std::shared_ptr< FWParameterSetterBase > > m_setters
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
void setFrom(const FWConfiguration &iFrom) override
FWGenericParameter< T > * assertParam(const std::string &name, T def)
double b
Definition: hdecay.h:120
const FWConfiguration * valueForKey(const std::string &iKey) const
static std::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
void makeSetter(TGCompositeFrame *, FWParameterBase *)
long double T
const KeyValues * keyValues() const
void addTo(FWConfiguration &) const override