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-19 12:16:38 -0700
commitaa327138df10822557dd27ae057f1cde48ebe0cf (patch)
tree565f531f4fde2cb53dc785a3a2c380b488f25277
parent5421d6da2ca34d122c1de8faec13522801fe77fb (diff)
downloadceph-aa327138df10822557dd27ae057f1cde48ebe0cf.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 {