summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-02-11 16:06:47 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-02-11 16:06:47 +0100
commite37add3fab8f39b18a69453ee1533e09e7f156de (patch)
tree967d8a7fbe98b63c5b7fda580a6cc8edeff1f88e /include
parenteeb18ee6e3b1b07574a7f0fda2c0c20ac3f773df (diff)
Allow dynrefs to have an OnCapture() hook
Diffstat (limited to 'include')
-rw-r--r--include/dynref.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/dynref.h b/include/dynref.h
index a3d2f9966..2069a87eb 100644
--- a/include/dynref.h
+++ b/include/dynref.h
@@ -24,8 +24,18 @@
class CoreExport dynamic_reference_base : public interfacebase, public insp::intrusive_list_node<dynamic_reference_base>
{
+ public:
+ class CaptureHook
+ {
+ public:
+ /** Called when the target of the dynamic_reference has been acquired
+ */
+ virtual void OnCapture() = 0;
+ };
+
private:
std::string name;
+ CaptureHook* hook;
void resolve();
protected:
ServiceProvider* value;
@@ -35,6 +45,12 @@ class CoreExport dynamic_reference_base : public interfacebase, public insp::int
~dynamic_reference_base();
inline const std::string& GetProvider() { return name; }
void SetProvider(const std::string& newname);
+
+ /** Set handler to call when the target object becomes available
+ * @param h Handler to call
+ */
+ void SetCaptureHook(CaptureHook* h) { hook = h; }
+
void check();
operator bool() { return (value != NULL); }
static void reset_all();