diff options
Diffstat (limited to 'project2/sessionXml.cpp')
-rw-r--r-- | project2/sessionXml.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/project2/sessionXml.cpp b/project2/sessionXml.cpp index fc552a9..c1e2158 100644 --- a/project2/sessionXml.cpp +++ b/project2/sessionXml.cpp @@ -7,6 +7,7 @@ #include <stdio.h> #include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> +#include <boost/program_options.hpp> /// Session implementation that stores its contents in an XML file on the local filesystem class SessionXml : public Session { @@ -31,8 +32,29 @@ class SessionXml : public Session { friend class SessionContainerXml; }; -const char * xmlFile = "/tmp/project2sessions.xml"; -DECLARE_COMPONENT_LOADER("xml", SessionContainerXml, SessionContainerLoader); +namespace po = boost::program_options; +class CustomSessionContainerLoaderXml : public SessionContainerLoaderImpl<SessionContainerXml> { + public: + CustomSessionContainerLoaderXml() : + opts("SessionXML options") + { + opts.add_options() + ("session.xml.path", po::value(&SessionContainerXml::xmlFile)->default_value("/tmp/project2sessions.xml"), + "Path of the XML file in which to store session information") + ; + } + po::options_description * + options() + { + return &opts; + } + + private: + po::options_description opts; +}; + +std::string SessionContainerXml::xmlFile; +DECLARE_CUSTOM_COMPONENT_LOADER("xml", SessionContainerXml, CustomSessionContainerLoaderXml, SessionContainerLoader); SessionContainerXml::SessionContainerXml() { |