CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWCompositeParameter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWCompositeParameter
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Fri Mar 7 14:36:57 EST 2008
11 // $Id: FWCompositeParameter.cc,v 1.4 2010/06/18 10:17:15 yana Exp $
12 //
13 
14 // system include files
15 #include <assert.h>
16 #include <algorithm>
17 
18 // user include files
21 
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
35  const std::string& iName,
36  unsigned int iVersion) :
37  FWParameterBase(iParent,iName),
38  m_version(iVersion)
39 {
40 }
41 
42 // FWCompositeParameter::FWCompositeParameter(const FWCompositeParameter& rhs)
43 // {
44 // // do actual copying here;
45 // }
46 
48 {
49 }
50 
51 //
52 // assignment operators
53 //
54 // const FWCompositeParameter& FWCompositeParameter::operator=(const FWCompositeParameter& rhs)
55 // {
56 // //An exception safe implementation is
57 // FWCompositeParameter temp(rhs);
58 // swap(rhs);
59 //
60 // return *this;
61 // }
62 
63 //
64 // member functions
65 //
66 void
68 {
69  //need a way to handle versioning
70  const FWConfiguration* mine = iFrom.valueForKey(name());
71  const FWConfiguration::KeyValues* keyVals = mine->keyValues();
72 
73  assert(0!=mine);
74  assert(mine->version()==m_version);
75  assert(0 != keyVals);
76 
77  for(const_iterator it =begin(), itEnd = end();
78  it != itEnd;
79  ++it) {
80  (*it)->setFrom(*mine);
81  }
82 }
83 
84 //
85 // const member functions
86 //
87 void
89 {
91 
92  for(const_iterator it =begin(), itEnd = end();
93  it != itEnd;
94  ++it) {
95  (*it)->addTo(conf);
96  }
97 // std::for_each(begin(), end(),
98 // boost::bind(&FWParameterBase::addTo,_1,conf));
99 
100  oTo.addKeyValue(name(),conf,true);
101 }
102 
103 //
104 // static member functions
105 //
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
std::vector< FWParameterBase * >::const_iterator const_iterator
const KeyValues * keyValues() const
const_iterator begin() const
FWCompositeParameter(FWParameterizable *iParent, const std::string &iName, unsigned int iVersion=1)
unsigned int version() const
const_iterator end() const
virtual void setFrom(const FWConfiguration &)
tuple conf
Definition: dbtoconf.py:185
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const FWConfiguration * valueForKey(const std::string &iKey) const
virtual void addTo(FWConfiguration &) const
const std::string & name() const