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