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 
32 
34  m_txtConfig(c),
35  m_item(item)
36 {
37 }
38 
40 {
41  delete m_txtConfig;
42 }
43 
44 
45 //______________________________________________________________________________
46 
47 void
49 {
50  if (begin() != end()) {
51  FWConfiguration vTmp;
53  iTo.addKeyValue("Var",vTmp, true);
54  }
55 }
56 
57 
58 void
60 {
61  /*
62  for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it)
63  std::cout << it->first << "FWProxyBuilderConfiguration::setFrom " << std::endl;
64  }*/
65 }
66 
67 
68 //______________________________________________________________________________
69 
70 void
72 {
73  // std::cout << "make setter " << pb->name() << std::endl;
74 
75  std::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(pb) );
76  ptr->attach(pb, this);
77  TGFrame* tmpFrame = ptr->build(frame, false);
78  frame->AddFrame(tmpFrame, new TGLayoutHints(kLHintsExpandX));
79  m_setters.push_back(ptr);
80 }
81 
82 void
83 FWProxyBuilderConfiguration::populateFrame(TGCompositeFrame* settersFrame)
84 {
85  // std::cout << "populate \n";
86 
87  TGCompositeFrame* frame = new TGVerticalFrame(settersFrame);
88  settersFrame->AddFrame(frame, new TGLayoutHints(kLHintsExpandX) );//|kLHintsExpandY
89 
90  for(const_iterator it =begin(); it != end(); ++it)
91  makeSetter(frame, *it);
92 
93  settersFrame->MapSubwindows();
94 }
95 
96 //______________________________________________________________________________
97 
99 {
100  for ( const_iterator i = begin(); i != end(); ++i) {
101  if ((*i)->name() == name) {
102  return nullptr;
103  }
104  }
105 
107 
108  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
109  if ( m_txtConfig) {
110  const FWConfiguration* varConfig = m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : nullptr;
111  if (varConfig) mode->setFrom(*varConfig);
112  }
113  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item));
114  return mode;
115 }
116 
117 
118 
120 {
121  for ( const_iterator i = begin(); i != end(); ++i) {
122  if ((*i)->name() == name) {
123  return nullptr;
124  }
125  }
126 
128 
129  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
130  const FWConfiguration* varConfig = m_txtConfig && m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : nullptr;
131  if (varConfig) mode->setFrom(*varConfig);
132 
133  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item));
134  return mode;
135 }
136 
138 {
139  FWGenericParameter<T>* param = nullptr;
140 
142  {
143  if ((*i)->name() == pname)
144  {
145  param = (FWGenericParameter<T>* )(*i);
146  break;
147  }
148  }
149 
150  if (param)
151  return param->value();
152  else
153  throw std::runtime_error("Invalid parameter request.");
154 }
155 
156 // explicit template instantiation
157 
158 template bool FWProxyBuilderConfiguration::value<bool>(const std::string& name);
159 template long FWProxyBuilderConfiguration::value<long>(const std::string& name);
160 template double FWProxyBuilderConfiguration::value<double>(const std::string& name);
161 
void populateFrame(TGCompositeFrame *frame)
void addTo(FWConfiguration &) const override
std::vector< FWParameterBase * >::const_iterator const_iterator
const KeyValues * keyValues() const
const_iterator begin() const
void proxyConfigChanged()
Definition: FWEventItem.cc:370
void setFrom(const FWConfiguration &iFrom) override
sigc::signal< void, T > changed_
FWProxyBuilderConfiguration(const FWConfiguration *c, const FWEventItem *item)
const_iterator end() const
T min(T a, T b)
Definition: MathUtil.h:58
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)
static std::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
void addTo(FWConfiguration &iTo) const override
void makeSetter(TGCompositeFrame *, FWParameterBase *)
const FWConfiguration * valueForKey(const std::string &iKey) const
long double T
JetCorrectorParameters::Definitions def
Definition: classes.h:6