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 20:04:15 -0700
commitf9867dce8de8b7c1dbea3472bf4d39f32bb399e1 (patch)
tree0bcaee76bc5278bae306c000c0fa5b3b98198883
parent03eb3eb697e4d41fd96fdf360ca56486d4e02181 (diff)
downloadceph-f9867dce8de8b7c1dbea3472bf4d39f32bb399e1.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 {