CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Fireworks/Core/interface/FWConfiguration.h

Go to the documentation of this file.
00001 #ifndef Fireworks_Core_FWConfiguration_h
00002 #define Fireworks_Core_FWConfiguration_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Core
00006 // Class  :     FWConfiguration
00007 //
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Fri Feb 22 15:54:22 EST 2008
00019 // $Id: FWConfiguration.h,v 1.7 2011/11/18 02:57:07 amraktad Exp $
00020 //
00021 
00022 // system include files
00023 #include <vector>
00024 #include <boost/scoped_ptr.hpp>
00025 #include <string>
00026 #include <ostream>
00027 
00028 // user include files
00029 
00030 // forward declarations
00031 
00032 class FWConfiguration
00033 {
00034 
00035 public:
00036    FWConfiguration(unsigned int iVersion=1) : m_version(iVersion) {
00037    }
00038    FWConfiguration(const std::string& iValue) : m_stringValues(new std::vector<std::string>( 1, iValue) ), m_version(0) {
00039    }
00040    virtual ~FWConfiguration();
00041 
00042    FWConfiguration(const FWConfiguration&);    // stop default
00043 
00044 
00045    FWConfiguration& operator=(const FWConfiguration&);    // stop default
00046    typedef std::vector<std::pair< std::string, FWConfiguration> > KeyValues;
00047    typedef KeyValues::const_iterator KeyValuesIt;
00048 
00049    typedef std::vector<std::string> StringValues;
00050    typedef StringValues::const_iterator StringValuesIt;
00051 
00052    // ---------- const member functions ---------------------
00053    const std::string& value(unsigned int iIndex=0) const;
00054    const FWConfiguration* valueForKey(const std::string& iKey) const;
00055    unsigned int version() const {
00056       return m_version;
00057    }
00058 
00059    const KeyValues* keyValues() const {
00060       return m_keyValues.get();
00061    }
00062    const StringValues* stringValues() const {
00063       return m_stringValues.get();
00064    }
00065 
00066    // ---------- static member functions --------------------
00067 
00068    // ---------- member functions ---------------------------
00069    FWConfiguration& addKeyValue(const std::string&, const FWConfiguration&);
00070    FWConfiguration& addKeyValue(const std::string&, FWConfiguration&, bool iDoSwap=false);
00071    FWConfiguration& addValue(const std::string&);
00072    void swap(FWConfiguration& );
00073 
00074 
00075 private:
00076 
00077    // ---------- member data --------------------------------
00078 
00079    boost::scoped_ptr<std::vector<std::string> > m_stringValues;
00080    boost::scoped_ptr<std::vector<std::pair< std::string, FWConfiguration> > > m_keyValues;
00081    unsigned int m_version;
00082 
00083 };
00084 
00085 void streamTo(std::ostream&, const FWConfiguration&, const std::string &name);
00086 
00087 #endif