aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services.cxx4
-rw-r--r--web/apache/service31
2 files changed, 17 insertions, 18 deletions
diff --git a/services.cxx b/services.cxx
index 746aefa..2da5bca 100644
--- a/services.cxx
+++ b/services.cxx
@@ -11,7 +11,7 @@ using namespace brep;
using web::apache::service;
static const search search_mod;
-service<search> AP_MODULE_DECLARE_DATA search_srv ("search", search_mod);
+service AP_MODULE_DECLARE_DATA search_srv ("search", search_mod);
static const view view_mod;
-service<view> AP_MODULE_DECLARE_DATA view_srv ("view", view_mod);
+service AP_MODULE_DECLARE_DATA view_srv ("view", view_mod);
diff --git a/web/apache/service b/web/apache/service
index 3c7a398..2b97108 100644
--- a/web/apache/service
+++ b/web/apache/service
@@ -13,32 +13,31 @@ namespace web
{
namespace apache
{
- class service_common
- {
- //@@ Implementation that calls handle() below goes here.
- //
-
- virtual void
- handle (request&, response&, log&) = 0;
- };
-
- template <typename M>
- class service: public service_common
+ class service
{
public:
// Note that the module exemplar is stored by-reference.
//
- service (const std::string& name, const M& exemplar);
+ template <typename M>
+ service (const std::string& name, const M& exemplar)
+ : exemplar_ (exemplar), handle_ (&handle_impl<M>) {}
- virtual void
- handle (request& rq, response& rs, log& l)
+ //@@ Implementation calls handle_ function pointer below:
+ //
+ // handle_ (rq, rs, l, exemplar_);
+ //
+
+ private:
+ template <typename M>
+ static void
+ handle_impl (request& rq, response& rs, log& l, const module& exemplar)
{
- M m (exemplar_);
+ M m (static_cast<const M&> (exemplar));
m.handle (rq, rs, l);
}
- private:
const M& exemplar_;
+ void (*handle_) (request&, response&, log&, const module&);
};
}
}