CMS 3D CMS Logo

FWConfiguration.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWConfiguration_h
2 #define Fireworks_Core_FWConfiguration_h
3 // -*- C++ -*-
4 //
5 // Package: Core
6 // Class : FWConfiguration
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri Feb 22 15:54:22 EST 2008
19 //
20 
21 // system include files
22 #include <vector>
23 #include <boost/scoped_ptr.hpp>
24 #include <string>
25 #include <ostream>
26 
27 // user include files
28 
29 // forward declarations
30 
32 {
33 
34 public:
35  FWConfiguration(unsigned int iVersion=1) : m_version(iVersion) {
36  }
37  FWConfiguration(const std::string& iValue) : m_stringValues(new std::vector<std::string>( 1, iValue) ), m_version(0) {
38  }
39  virtual ~FWConfiguration();
40 
41  FWConfiguration(const FWConfiguration&); // stop default
42 
43 
44  FWConfiguration& operator=(const FWConfiguration&); // stop default
45  typedef std::vector<std::pair< std::string, FWConfiguration> > KeyValues;
46  typedef KeyValues::const_iterator KeyValuesIt;
47 
48  typedef std::vector<std::string> StringValues;
49  typedef StringValues::const_iterator StringValuesIt;
50 
51  // ---------- const member functions ---------------------
52  const std::string& value(unsigned int iIndex=0) const;
53  const FWConfiguration* valueForKey(const std::string& iKey) const;
54  unsigned int version() const {
55  return m_version;
56  }
57 
58  const KeyValues* keyValues() const {
59  return m_keyValues.get();
60  }
61  const StringValues* stringValues() const {
62  return m_stringValues.get();
63  }
64 
65  // ---------- static member functions --------------------
66 
67  // ---------- member functions ---------------------------
69  FWConfiguration& addKeyValue(const std::string&, FWConfiguration&, bool iDoSwap=false);
71  void swap(FWConfiguration& );
72 
73  static void streamTo(std::ostream& oTo, const FWConfiguration& iConfig, const std::string &name);
74 
75 private:
76 
77  // ---------- member data --------------------------------
78 
79  boost::scoped_ptr<std::vector<std::string> > m_stringValues;
80  boost::scoped_ptr<std::vector<std::pair< std::string, FWConfiguration> > > m_keyValues;
81  unsigned int m_version;
82 
83 };
84 
85 void streamTo(std::ostream&, const FWConfiguration&, const std::string &name);
86 
87 #endif
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
const StringValues * stringValues() const
FWConfiguration(unsigned int iVersion=1)
const KeyValues * keyValues() const
FWConfiguration(const std::string &iValue)
boost::scoped_ptr< std::vector< std::string > > m_stringValues
unsigned int version() const
FWConfiguration & operator=(const FWConfiguration &)
void swap(FWConfiguration &)
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const std::string & value(unsigned int iIndex=0) const
FWConfiguration & addValue(const std::string &)
virtual ~FWConfiguration()
unsigned int m_version
KeyValues::const_iterator KeyValuesIt
std::vector< std::string > StringValues
const FWConfiguration * valueForKey(const std::string &iKey) const
StringValues::const_iterator StringValuesIt
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)