CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: FWConfiguration.h,v 1.7 2011/11/18 02:57:07 amraktad Exp $
20 //
21 
22 // system include files
23 #include <vector>
24 #include <boost/scoped_ptr.hpp>
25 #include <string>
26 #include <ostream>
27 
28 // user include files
29 
30 // forward declarations
31 
33 {
34 
35 public:
36  FWConfiguration(unsigned int iVersion=1) : m_version(iVersion) {
37  }
38  FWConfiguration(const std::string& iValue) : m_stringValues(new std::vector<std::string>( 1, iValue) ), m_version(0) {
39  }
40  virtual ~FWConfiguration();
41 
42  FWConfiguration(const FWConfiguration&); // stop default
43 
44 
45  FWConfiguration& operator=(const FWConfiguration&); // stop default
46  typedef std::vector<std::pair< std::string, FWConfiguration> > KeyValues;
47  typedef KeyValues::const_iterator KeyValuesIt;
48 
49  typedef std::vector<std::string> StringValues;
50  typedef StringValues::const_iterator StringValuesIt;
51 
52  // ---------- const member functions ---------------------
53  const std::string& value(unsigned int iIndex=0) const;
54  const FWConfiguration* valueForKey(const std::string& iKey) const;
55  unsigned int version() const {
56  return m_version;
57  }
58 
59  const KeyValues* keyValues() const {
60  return m_keyValues.get();
61  }
62  const StringValues* stringValues() const {
63  return m_stringValues.get();
64  }
65 
66  // ---------- static member functions --------------------
67 
68  // ---------- member functions ---------------------------
70  FWConfiguration& addKeyValue(const std::string&, FWConfiguration&, bool iDoSwap=false);
72  void swap(FWConfiguration& );
73 
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)
void streamTo(std::ostream &, const FWConfiguration &, const std::string &name)
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