diff options
author | randomdan <randomdan@localhost> | 2011-12-01 13:06:26 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-12-01 13:06:26 +0000 |
commit | 6291c6f085a1ad209f29458c013cf15273216a66 (patch) | |
tree | 3d3e959a56a26b303503fc3d9239843818e5f806 | |
parent | Control what application engine data is added to the output presenter (diff) | |
download | project2-6291c6f085a1ad209f29458c013cf15273216a66.tar.bz2 project2-6291c6f085a1ad209f29458c013cf15273216a66.tar.xz project2-6291c6f085a1ad209f29458c013cf15273216a66.zip |
Allow specifying default CGI output options in the config file
-rw-r--r-- | project2/cgi/cgiOutputOptions.cpp | 26 | ||||
-rw-r--r-- | project2/cgi/cgiOutputOptions.h | 28 |
2 files changed, 52 insertions, 2 deletions
diff --git a/project2/cgi/cgiOutputOptions.cpp b/project2/cgi/cgiOutputOptions.cpp index 6e22641..abda276 100644 --- a/project2/cgi/cgiOutputOptions.cpp +++ b/project2/cgi/cgiOutputOptions.cpp @@ -1,5 +1,12 @@ #include "cgiOutputOptions.h" +bool OutputOptions::core; +bool OutputOptions::session; +bool OutputOptions::timing; +bool OutputOptions::environment; +bool OutputOptions::url; +bool OutputOptions::parameters; + OutputOptions::OutputOptions(const xmlpp::Element * p) : Core(p, "core", false, true), Session(p, "session", false, true), @@ -10,10 +17,29 @@ OutputOptions::OutputOptions(const xmlpp::Element * p) : { } +OutputOptionsLoader::OutputOptionsLoader() : + opts("CGI default output options") +{ + opts.add_options() + ("cgi.output.core", po::value(&OutputOptions::core), "Core messages") + ("cgi.output.session", po::value(&OutputOptions::core), "Session values") + ("cgi.output.timing", po::value(&OutputOptions::core), "Timing") + ("cgi.output.environment", po::value(&OutputOptions::core), "Environment") + ("cgi.output.url", po::value(&OutputOptions::core), "URL breakdown") + ("cgi.output.parameters", po::value(&OutputOptions::core), "Parameters") + ; +} + OutputOptionsPtr OutputOptionsLoader::createFrom(const xmlpp::Element * e) const { return new OutputOptions(e); } +po::options_description * +OutputOptionsLoader::options() +{ + return &opts; +} + DECLARE_CUSTOM_COMPONENT_LOADER("outputoptions", OutputOptions, OutputOptionsLoader, OutputOptionsLoader) diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h index 48579cd..540764e 100644 --- a/project2/cgi/cgiOutputOptions.h +++ b/project2/cgi/cgiOutputOptions.h @@ -1,9 +1,14 @@ -#include "intrusivePtrBase.h" +#ifndef OUTPUTOPTIONS_H +#define OUTPUTOPTIONS_H +#include "intrusivePtrBase.h" +#include <boost/program_options.hpp> #include "variables.h" + namespace xmlpp { class Element; } + class OutputOptions : public IntrusivePtrBase { public: OutputOptions(const xmlpp::Element *); @@ -14,9 +19,28 @@ class OutputOptions : public IntrusivePtrBase { const Variable Environment; const Variable URL; const Variable Parameters; + + private: + // defaults + friend class OutputOptionsLoader; + static bool core; + static bool session; + static bool timing; + static bool environment; + static bool url; + static bool parameters; }; typedef boost::intrusive_ptr<OutputOptions> OutputOptionsPtr; + +namespace po = boost::program_options; class OutputOptionsLoader : public ComponentLoader { public: - virtual OutputOptionsPtr createFrom(const xmlpp::Element * e) const; + OutputOptionsLoader(); + OutputOptionsPtr createFrom(const xmlpp::Element * e) const; + po::options_description * options(); + + private: + po::options_description opts; }; + +#endif |