diff Framework/Toolbox/ObserversRegistry.h @ 90:64e60018943f wasm

fix and observer refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 May 2017 11:04:18 +0200
parents c2dc924f1a63
children 81f73efd81a1
line wrap: on
line diff
--- a/Framework/Toolbox/ObserversRegistry.h	Fri May 26 18:27:59 2017 +0200
+++ b/Framework/Toolbox/ObserversRegistry.h	Mon May 29 11:04:18 2017 +0200
@@ -92,5 +92,41 @@
     {
       return observers_.empty();
     }
+
+    void Apply(const Source& source,
+               void (Observer::*method) (const Source&))
+    {
+      for (typename Observers::const_iterator it = observers_.begin();
+           it != observers_.end(); ++it)
+      {
+        ((*it)->*method) (source);
+      }
+    }
+
+    template <typename Argument0>
+    void Apply(const Source& source,
+               void (Observer::*method) (const Source&, const Argument0&),
+               const Argument0& argument0)
+    {
+      for (typename Observers::const_iterator it = observers_.begin();
+           it != observers_.end(); ++it)
+      {
+        ((*it)->*method) (source, argument0);
+      }
+    }
+
+    template <typename Argument0,
+              typename Argument1>
+    void Apply(const Source& source,
+               void (Observer::*method) (const Source&, const Argument0&, const Argument1&),
+               const Argument0& argument0,
+               const Argument1& argument1)
+    {
+      for (typename Observers::const_iterator it = observers_.begin();
+           it != observers_.end(); ++it)
+      {
+        ((*it)->*method) (source, argument0, argument1);
+      }
+    }
   };
 }