From 07780b06aa7b0fe049cc412309cf87e7fb10a0ef Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 30 Apr 2015 14:25:29 +0200 Subject: Implement module configuration with an option list --- brep/module | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'brep/module') diff --git a/brep/module b/brep/module index 54d41cf..d1399fb 100644 --- a/brep/module +++ b/brep/module @@ -11,6 +11,7 @@ #include +#include #include namespace brep @@ -69,10 +70,6 @@ namespace brep // class module: public web::module { - public: - virtual void - handle (request&, response&) = 0; - // Diagnostics. // protected: @@ -95,18 +92,33 @@ namespace brep module (); module (const module& ); + private: virtual void handle (request&, response&, log&); virtual void - init (const char* path); + handle (request&, response&) = 0; + + virtual void + init (const name_values&, log&); + + // Can be overriden by module implementation which has configuration + // options. + // + virtual void + init (::cli::scanner& s) + { + // Just scan options to ensure there is no misspelled ones. + // + module_options o (s, cli::unknown_mode::fail, cli::unknown_mode::fail); + } // Diagnostics implementation details. // private: log* log_ {nullptr}; // Diagnostics backend provided by the web server. - public: + private: // Extract function name from a __PRETTY_FUNCTION__. // Throw std::invalid_argument if fail to parse. // -- cgit v1.1