summaryrefslogtreecommitdiff
path: root/project2/config.h
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-04 14:39:54 +0000
committerrandomdan <randomdan@localhost>2011-02-04 14:39:54 +0000
commit99e694337f0b7dd3749b142e8abe77b70754cff8 (patch)
tree52fe3919b6d4e4cc71c98f30e2e0640abaaee63b /project2/config.h
parentDon't construct the dir end iterator every iteration (diff)
downloadproject2-99e694337f0b7dd3749b142e8abe77b70754cff8.tar.bz2
project2-99e694337f0b7dd3749b142e8abe77b70754cff8.tar.xz
project2-99e694337f0b7dd3749b142e8abe77b70754cff8.zip
Add concept of runtime configuration, set by HTTP hostname or environment variable depending on engine
Use it in ArtfulSeller, although there is currently only one platform
Diffstat (limited to 'project2/config.h')
-rw-r--r--project2/config.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/project2/config.h b/project2/config.h
new file mode 100644
index 0000000..9f6cd5d
--- /dev/null
+++ b/project2/config.h
@@ -0,0 +1,43 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include <string>
+#include <libxml++/nodes/element.h>
+#include "intrusivePtrBase.h"
+#include <boost/function.hpp>
+
+class Configuration {
+ public:
+ class Platform : public virtual IntrusivePtrBase {
+ public:
+ typedef std::map<Glib::ustring, const Glib::ustring> Values;
+
+ Platform(const xmlpp::Element * instanceRoot);
+ const Glib::ustring & getValue(const Glib::ustring & key) const;
+
+ private:
+ Values values;
+ };
+ typedef boost::intrusive_ptr<const Platform> PlatformPtr;
+
+ typedef std::map<Glib::ustring, PlatformPtr> Platforms;
+
+ Configuration(const Glib::ustring & engineKeys);
+ virtual ~Configuration() = 0;
+
+ PlatformPtr getCurrentConfig() const;
+
+ protected:
+ virtual Glib::ustring resolveCurrentConfig() const = 0;
+ void load() const;
+
+ private:
+ virtual void loadEngineSection(const xmlpp::Element *) const = 0;
+
+ mutable bool loaded;
+ mutable Platforms platforms;
+ const Glib::ustring engineKeys;
+};
+
+#endif
+