]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Context: add GenContext templated on the callback argument
authorSamuel Just <sam.just@inktank.com>
Sat, 14 Sep 2013 02:48:56 +0000 (19:48 -0700)
committerSamuel Just <sam.just@inktank.com>
Thu, 26 Sep 2013 02:18:42 +0000 (19:18 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/include/Context.h

index 9ec4414a047c0b4aa8bac7f2b15b74062aa1607e..663313ceec172fa9b507446e5b67ee04c7025153 100644 (file)
 
 #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
  */