CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  boost::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 {
101 
102  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
103  if ( m_txtConfig) {
104  const FWConfiguration* varConfig = m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : 0;
105  if (varConfig) mode->setFrom(*varConfig);
106  }
107  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item));
108  return mode;
109 }
110 
111 
112 
114 {
116 
117  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
118  const FWConfiguration* varConfig = m_txtConfig && m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : 0;
119  if (varConfig) mode->setFrom(*varConfig);
120 
121  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item));
122  return mode;
123 }
124 
125 template <class T> T FWProxyBuilderConfiguration::value(const std::string& pname)
126 {
127  FWGenericParameter<T>* param = 0;
128 
130  {
131  if ((*i)->name() == pname)
132  {
133  param = (FWGenericParameter<T>* )(*i);
134  break;
135  }
136  }
137 
138  if (param)
139  return param->value();
140  else
141  throw std::runtime_error("Invalid parameter request.");
142 }
143 
144 // explicit template instantiation
145 
146 template bool FWProxyBuilderConfiguration::value<bool>(const std::string& name);
147 template long FWProxyBuilderConfiguration::value<long>(const std::string& name);
148 template double FWProxyBuilderConfiguration::value<double>(const std::string& name);
149 
void populateFrame(TGCompositeFrame *frame)
int i
Definition: DBlmapReader.cc:9
std::vector< FWParameterBase * >::const_iterator const_iterator
const KeyValues * keyValues() const
const_iterator begin() const
void proxyConfigChanged()
Definition: FWEventItem.cc:368
static boost::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
sigc::signal< void, T > changed_
virtual void addTo(FWConfiguration &iTo) const
virtual void setFrom(const FWConfiguration &iFrom)
FWProxyBuilderConfiguration(const FWConfiguration *c, const FWEventItem *item)
const T & max(const T &a, const T &b)
const_iterator end() const
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
std::vector< boost::shared_ptr< FWParameterSetterBase > > m_setters
virtual void setFrom(const FWConfiguration &iFrom)
void makeSetter(TGCompositeFrame *, FWParameterBase *)
const FWConfiguration * valueForKey(const std::string &iKey) const
long double T
JetCorrectorParameters::Definitions def
Definition: classes.h:6
virtual void addTo(FWConfiguration &) const