summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-09-13 19:48:56 -0700
committerSamuel Just <sam.just@inktank.com>2013-09-25 19:18:42 -0700
commitfde0f864a62af39a0854af39e4e329ff80f35cf9 (patch)
treea0fb29acfed176a94e2ada43024f573a239b2e18
parent52c7f2796397b5e3aa24c24bf0c6615cadf927c6 (diff)
downloadceph-fde0f864a62af39a0854af39e4e329ff80f35cf9.tar.gz
Context: add GenContext templated on the callback argument
Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r--src/include/Context.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/include/Context.h b/src/include/Context.h
index 9ec4414a047..663313ceec1 100644
--- a/src/include/Context.h
+++ b/src/include/Context.h
@@ -28,6 +28,26 @@
#define mydout(cct, v) lgeneric_subdout(cct, context, v)
/*
+ * GenContext - abstract callback class
+ */
+template <typename T>
+class GenContext {
+ GenContext(const GenContext& other);
+ const GenContext& operator=(const GenContext& other);
+
+ protected:
+ virtual void finish(T t) = 0;
+
+ public:
+ GenContext() {}
+ virtual ~GenContext() {} // we want a virtual destructor!!!
+ virtual void complete(T t) {
+ finish(t);
+ delete this;
+ }
+};
+
+/*
* Context - abstract callback class
*/
class Context {