From 2700ed6a3e1092a064f28b07f8e2c4e5b9b830e7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Nov 2015 20:02:06 +0200 Subject: Implement new URL path schema for the web interface --- brep/module | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'brep/module') diff --git a/brep/module b/brep/module index 0743598..295744d 100644 --- a/brep/module +++ b/brep/module @@ -5,12 +5,10 @@ #ifndef BREP_MODULE #define BREP_MODULE -#include -#include // move() -#include - #include +#include +#include #include #include @@ -40,7 +38,7 @@ namespace brep { diag_data data; - server_error (diag_data&& d): data (std::move (d)) {} + server_error (diag_data&& d): data (move (d)) {} }; // Every module member function that needs to produce any diagnostics @@ -81,11 +79,15 @@ namespace brep // // While uint8 is more than enough, use uint16 for the ease of printing. // - std::uint16_t verb_ {0}; + uint16_t verb_ {0}; template void level1 (const F& f) const {if (verb_ >= 1) f ();} template void level2 (const F& f) const {if (verb_ >= 2) f ();} + // Set to true when the module is successfully initialized. + // + bool loaded_ {false}; + // Implementation details. // protected: @@ -117,12 +119,19 @@ namespace brep bool name_; }; - private: + public: + // Can be called normally by the web server or our custom request + // dispatching mechanism. + // virtual void - handle (request&, response&, log&); + handle (request&, response&) = 0; + + bool + loaded () const noexcept {return loaded_;} + private: virtual void - handle (request&, response&) = 0; + handle (request&, response&, log&); virtual void init (const name_values&, log&); @@ -147,7 +156,7 @@ namespace brep // Extract function name from a __PRETTY_FUNCTION__. // Throw std::invalid_argument if fail to parse. // - static std::string + static string func_name (const char* pretty_name); void -- cgit v1.1