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 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
32 FWCompositeParameter::FWCompositeParameter(FWParameterizable* iParent, const std::string& iName, unsigned int iVersion)
33  : FWParameterBase(iParent, iName), m_version(iVersion) {}
34 
35 // FWCompositeParameter::FWCompositeParameter(const FWCompositeParameter& rhs)
36 // {
37 // // do actual copying here;
38 // }
39 
41 
42 //
43 // assignment operators
44 //
45 // const FWCompositeParameter& FWCompositeParameter::operator=(const FWCompositeParameter& rhs)
46 // {
47 // //An exception safe implementation is
48 // FWCompositeParameter temp(rhs);
49 // swap(rhs);
50 //
51 // return *this;
52 // }
53 
54 //
55 // member functions
56 //
58  //need a way to handle versioning
59  const FWConfiguration* mine = iFrom.valueForKey(name());
60  const FWConfiguration::KeyValues* keyVals = mine->keyValues();
61 
62  assert(nullptr != mine);
63  assert(mine->version() == m_version);
64  assert(nullptr != keyVals);
65 
66  for (const_iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
67  (*it)->setFrom(*mine);
68  }
69 }
70 
71 //
72 // const member functions
73 //
76 
77  for (const_iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
78  (*it)->addTo(conf);
79  }
80  // std::for_each(begin(), end(),
81  // std::bind(&FWParameterBase::addTo, std::placeholders::_1,conf));
82 
83  oTo.addKeyValue(name(), conf, true);
84 }
85 
86 //
87 // static member functions
88 //
const_iterator begin() const
FWCompositeParameter(FWParameterizable *iParent, const std::string &iName, unsigned int iVersion=1)
std::vector< FWParameterBase * >::const_iterator const_iterator
assert(be >=bs)
const_iterator end() const
const std::string & name() const
void addTo(FWConfiguration &) const override
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
void setFrom(const FWConfiguration &) override
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const FWConfiguration * valueForKey(const std::string &iKey) const
const KeyValues * keyValues() const
unsigned int version() const