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 // $Id: FWProxyBuilderConfiguration.cc,v 1.8 2011/08/20 03:39:20 amraktad Exp $
12 //
13 
14 // system include files
15 
16 // user include files
17 #include <iostream>
18 #include <stdexcept>
19 #include <boost/bind.hpp>
20 
21 #include "TGFrame.h"
22 
32 
33 
35  m_txtConfig(c),
36  m_item(item)
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  boost::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 //______________________________________________________________________________
98 
99 template <class T> FWGenericParameter<T>* FWProxyBuilderConfiguration::assertParam(const std::string& name, T def )
100 {
102 
103  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
104  if ( m_txtConfig) {
105  const FWConfiguration* varConfig = m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : 0;
106  if (varConfig) mode->setFrom(*varConfig);
107  }
108  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item));
109  return mode;
110 }
111 
112 
113 
115 {
117 
118  // std::cout << "FWProxyBuilderConfiguration::getVarParameter(). No parameter with name " << name << std::endl;
119  const FWConfiguration* varConfig = m_txtConfig && m_txtConfig->keyValues() ? m_txtConfig->valueForKey("Var") : 0;
120  if (varConfig) mode->setFrom(*varConfig);
121 
122  mode->changed_.connect(boost::bind(&FWEventItem::proxyConfigChanged, (FWEventItem*)m_item));
123  return mode;
124 }
125 
126 template <class T> T FWProxyBuilderConfiguration::value(const std::string& pname)
127 {
128  FWGenericParameter<T>* param = 0;
129 
131  {
132  if ((*i)->name() == pname)
133  {
134  param = (FWGenericParameter<T>* )(*i);
135  break;
136  }
137  }
138 
139  if (param)
140  return param->value();
141  else
142  throw std::runtime_error("Invalid parameter request.");
143 }
144 
145 // explicit template instantiation
146 
147 template bool FWProxyBuilderConfiguration::value<bool>(const std::string& name);
148 template long FWProxyBuilderConfiguration::value<long>(const std::string& name);
149 template double FWProxyBuilderConfiguration::value<double>(const std::string& name);
150 
152 template FWGenericParameterWithRange<long>* FWProxyBuilderConfiguration::assertParam(const std::string& name, long def,long min, long max);
153 template FWGenericParameterWithRange<double>* FWProxyBuilderConfiguration::assertParam(const std::string& name, double def,double min, double max);
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:369
#define min(a, b)
Definition: mlp_lapack.h:161
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:10
virtual void addTo(FWConfiguration &) const