CMS 3D CMS Logo

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 //
12 
13 // system include files
14 #include <cassert>
15 #include <algorithm>
16 
17 // user include files
20 
21 
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
34  const std::string& iName,
35  unsigned int iVersion) :
36  FWParameterBase(iParent,iName),
37  m_version(iVersion)
38 {
39 }
40 
41 // FWCompositeParameter::FWCompositeParameter(const FWCompositeParameter& rhs)
42 // {
43 // // do actual copying here;
44 // }
45 
47 {
48 }
49 
50 //
51 // assignment operators
52 //
53 // const FWCompositeParameter& FWCompositeParameter::operator=(const FWCompositeParameter& rhs)
54 // {
55 // //An exception safe implementation is
56 // FWCompositeParameter temp(rhs);
57 // swap(rhs);
58 //
59 // return *this;
60 // }
61 
62 //
63 // member functions
64 //
65 void
67 {
68  //need a way to handle versioning
69  const FWConfiguration* mine = iFrom.valueForKey(name());
70  const FWConfiguration::KeyValues* keyVals = mine->keyValues();
71 
72  assert(nullptr!=mine);
73  assert(mine->version()==m_version);
74  assert(nullptr != keyVals);
75 
76  for(const_iterator it =begin(), itEnd = end();
77  it != itEnd;
78  ++it) {
79  (*it)->setFrom(*mine);
80  }
81 }
82 
83 //
84 // const member functions
85 //
86 void
88 {
90 
91  for(const_iterator it =begin(), itEnd = end();
92  it != itEnd;
93  ++it) {
94  (*it)->addTo(conf);
95  }
96 // std::for_each(begin(), end(),
97 // boost::bind(&FWParameterBase::addTo,_1,conf));
98 
99  oTo.addKeyValue(name(),conf,true);
100 }
101 
102 //
103 // static member functions
104 //
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
void addTo(FWConfiguration &) const override
const_iterator end() const
void setFrom(const FWConfiguration &) override
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const FWConfiguration * valueForKey(const std::string &iKey) const
const std::string & name() const