CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/Fireworks/Core/src/FWCompositeParameter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWCompositeParameter
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Fri Mar  7 14:36:57 EST 2008
00011 // $Id: FWCompositeParameter.cc,v 1.4 2010/06/18 10:17:15 yana Exp $
00012 //
00013 
00014 // system include files
00015 #include <assert.h>
00016 #include <algorithm>
00017 
00018 // user include files
00019 #include "Fireworks/Core/interface/FWCompositeParameter.h"
00020 #include "Fireworks/Core/interface/FWConfiguration.h"
00021 
00022 
00023 //
00024 // constants, enums and typedefs
00025 //
00026 
00027 //
00028 // static data member definitions
00029 //
00030 
00031 //
00032 // constructors and destructor
00033 //
00034 FWCompositeParameter::FWCompositeParameter(FWParameterizable* iParent,
00035                                            const std::string& iName,
00036                                            unsigned int iVersion) :
00037    FWParameterBase(iParent,iName),
00038    m_version(iVersion)
00039 {
00040 }
00041 
00042 // FWCompositeParameter::FWCompositeParameter(const FWCompositeParameter& rhs)
00043 // {
00044 //    // do actual copying here;
00045 // }
00046 
00047 FWCompositeParameter::~FWCompositeParameter()
00048 {
00049 }
00050 
00051 //
00052 // assignment operators
00053 //
00054 // const FWCompositeParameter& FWCompositeParameter::operator=(const FWCompositeParameter& rhs)
00055 // {
00056 //   //An exception safe implementation is
00057 //   FWCompositeParameter temp(rhs);
00058 //   swap(rhs);
00059 //
00060 //   return *this;
00061 // }
00062 
00063 //
00064 // member functions
00065 //
00066 void
00067 FWCompositeParameter::setFrom(const FWConfiguration& iFrom)
00068 {
00069    //need a way to handle versioning
00070    const FWConfiguration* mine = iFrom.valueForKey(name());
00071    const FWConfiguration::KeyValues* keyVals = mine->keyValues();
00072 
00073    assert(0!=mine);
00074    assert(mine->version()==m_version);
00075    assert(0 != keyVals);
00076 
00077    for(const_iterator it =begin(), itEnd = end();
00078        it != itEnd;
00079        ++it) {
00080       (*it)->setFrom(*mine);
00081    }
00082 }
00083 
00084 //
00085 // const member functions
00086 //
00087 void
00088 FWCompositeParameter::addTo(FWConfiguration& oTo) const
00089 {
00090    FWConfiguration conf(m_version);
00091 
00092    for(const_iterator it =begin(), itEnd = end();
00093        it != itEnd;
00094        ++it) {
00095       (*it)->addTo(conf);
00096    }
00097 //   std::for_each(begin(), end(),
00098 //                 boost::bind(&FWParameterBase::addTo,_1,conf));
00099 
00100    oTo.addKeyValue(name(),conf,true);
00101 }
00102 
00103 //
00104 // static member functions
00105 //