aboutsummaryrefslogtreecommitdiff
path: root/brep/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-16 20:02:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-25 20:35:10 +0200
commit2700ed6a3e1092a064f28b07f8e2c4e5b9b830e7 (patch)
treea54ffc979dde42e609bc9877120fa010887c6b66 /brep/module
parent48a3c47d34c2acc0a39e2db5acfd437dace499c1 (diff)
Implement new URL path schema for the web interface
Diffstat (limited to 'brep/module')
-rw-r--r--brep/module29
1 files changed, 19 insertions, 10 deletions
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 <string>
-#include <utility> // move()
-#include <cstdint>
-
#include <web/module>
+#include <brep/types>
+#include <brep/utility>
#include <brep/options>
#include <brep/diagnostics>
@@ -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 <class F> void level1 (const F& f) const {if (verb_ >= 1) f ();}
template <class F> 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