Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:30

0001 #ifndef Fireworks_Core_FWConfiguration_h
0002 #define Fireworks_Core_FWConfiguration_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Core
0006 // Class  :     FWConfiguration
0007 //
0008 /**\class FWConfiguration FWConfiguration.h Fireworks/Core/interface/FWConfiguration.h
0009 
0010    Description: <one line class summary>
0011 
0012    Usage:
0013     <usage>
0014 
0015  */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Fri Feb 22 15:54:22 EST 2008
0019 //
0020 
0021 // system include files
0022 #include <vector>
0023 #include <memory>
0024 #include <string>
0025 #include <ostream>
0026 
0027 // user include files
0028 
0029 // forward declarations
0030 
0031 class FWConfiguration {
0032 public:
0033   FWConfiguration(unsigned int iVersion = 1) : m_version(iVersion) {}
0034   FWConfiguration(const std::string& iValue) : m_stringValues(new std::vector<std::string>(1, iValue)), m_version(0) {}
0035   virtual ~FWConfiguration();
0036 
0037   FWConfiguration(const FWConfiguration&);  // stop default
0038 
0039   FWConfiguration& operator=(const FWConfiguration&);  // stop default
0040   typedef std::vector<std::pair<std::string, FWConfiguration> > KeyValues;
0041   typedef KeyValues::const_iterator KeyValuesIt;
0042 
0043   typedef std::vector<std::string> StringValues;
0044   typedef StringValues::const_iterator StringValuesIt;
0045 
0046   // ---------- const member functions ---------------------
0047   const std::string& value(unsigned int iIndex = 0) const;
0048   const FWConfiguration* valueForKey(const std::string& iKey) const;
0049   unsigned int version() const { return m_version; }
0050 
0051   const KeyValues* keyValues() const { return m_keyValues.get(); }
0052   const StringValues* stringValues() const { return m_stringValues.get(); }
0053 
0054   // ---------- static member functions --------------------
0055 
0056   // ---------- member functions ---------------------------
0057   FWConfiguration& addKeyValue(const std::string&, const FWConfiguration&);
0058   FWConfiguration& addKeyValue(const std::string&, FWConfiguration&, bool iDoSwap = false);
0059   FWConfiguration& addValue(const std::string&);
0060   void swap(FWConfiguration&);
0061 
0062   static void streamTo(std::ostream& oTo, const FWConfiguration& iConfig, const std::string& name);
0063 
0064 private:
0065   // ---------- member data --------------------------------
0066 
0067   std::unique_ptr<std::vector<std::string> > m_stringValues;
0068   std::unique_ptr<std::vector<std::pair<std::string, FWConfiguration> > > m_keyValues;
0069   unsigned int m_version;
0070 };
0071 
0072 void streamTo(std::ostream&, const FWConfiguration&, const std::string& name);
0073 
0074 #endif