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 public:
33  FWConfiguration(unsigned int iVersion = 1) : m_version(iVersion) {}
34  FWConfiguration(const std::string& iValue) : m_stringValues(new std::vector<std::string>(1, iValue)), m_version(0) {}
35  virtual ~FWConfiguration();
36 
37  FWConfiguration(const FWConfiguration&); // stop default
38 
39  FWConfiguration& operator=(const FWConfiguration&); // stop default
40  typedef std::vector<std::pair<std::string, FWConfiguration> > KeyValues;
41  typedef KeyValues::const_iterator KeyValuesIt;
42 
43  typedef std::vector<std::string> StringValues;
44  typedef StringValues::const_iterator StringValuesIt;
45 
46  // ---------- const member functions ---------------------
47  const std::string& value(unsigned int iIndex = 0) const;
48  const FWConfiguration* valueForKey(const std::string& iKey) const;
49  unsigned int version() const { return m_version; }
50 
51  const KeyValues* keyValues() const { return m_keyValues.get(); }
52  const StringValues* stringValues() const { return m_stringValues.get(); }
53 
54  // ---------- static member functions --------------------
55 
56  // ---------- member functions ---------------------------
58  FWConfiguration& addKeyValue(const std::string&, FWConfiguration&, bool iDoSwap = false);
60  void swap(FWConfiguration&);
61 
62  static void streamTo(std::ostream& oTo, const FWConfiguration& iConfig, const std::string& name);
63 
64 private:
65  // ---------- member data --------------------------------
66 
67  boost::scoped_ptr<std::vector<std::string> > m_stringValues;
68  boost::scoped_ptr<std::vector<std::pair<std::string, FWConfiguration> > > m_keyValues;
69  unsigned int m_version;
70 };
71 
72 void streamTo(std::ostream&, const FWConfiguration&, const std::string& name);
73 
74 #endif
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 &)
boost::scoped_ptr< std::vector< std::pair< std::string, FWConfiguration > > > m_keyValues
void swap(FWConfiguration &)
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
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
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)