changeset 456:b70fcc134ba4

moved LambdaCallable (currently still disable because it does not work in WASM)
author Alain Mazy <alain@mazy.be>
date Wed, 23 Jan 2019 13:58:51 +0100
parents e3a6e3bf5c7c
children 3b4df9925db6 4d8ac609fc33
files Framework/Messages/ICallable.h UnitTestsSources/TestMessageBroker.cpp
diffstat 2 files changed, 37 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Messages/ICallable.h	Mon Jan 21 22:41:24 2019 +0100
+++ b/Framework/Messages/ICallable.h	Wed Jan 23 13:58:51 2019 +0100
@@ -89,4 +89,41 @@
       return &observer_;
     }
   };
+
+#if 0 /* __cplusplus >= 201103L*/
+
+#include <functional>
+
+  template <typename TMessage>
+  class LambdaCallable : public MessageHandler<TMessage>
+  {
+  private:
+
+    IObserver&      observer_;
+    std::function<void (const TMessage&)> lambda_;
+
+  public:
+    LambdaCallable(IObserver& observer,
+                    std::function<void (const TMessage&)> lambdaFunction) :
+             observer_(observer),
+             lambda_(lambdaFunction)
+    {
+    }
+
+    virtual void Apply(const IMessage& message)
+    {
+      lambda_(dynamic_cast<const TMessage&>(message));
+    }
+
+    virtual MessageType GetMessageType() const
+    {
+      return static_cast<MessageType>(TMessage::Type);
+    }
+
+    virtual IObserver* GetObserver() const
+    {
+      return &observer_;
+    }
+  };
+#endif //__cplusplus >= 201103L
 }
--- a/UnitTestsSources/TestMessageBroker.cpp	Mon Jan 21 22:41:24 2019 +0100
+++ b/UnitTestsSources/TestMessageBroker.cpp	Wed Jan 23 13:58:51 2019 +0100
@@ -314,45 +314,6 @@
 
 #if __cplusplus >= 201103L
 
-#include <functional>
-
-namespace OrthancStone {
-
-  template <typename TMessage>
-  class LambdaCallable : public MessageHandler<TMessage>
-  {
-  private:
-
-    IObserver&      observer_;
-    std::function<void (const TMessage&)> lambda_;
-
-  public:
-    LambdaCallable(IObserver& observer,
-                    std::function<void (const TMessage&)> lambdaFunction) :
-             observer_(observer),
-             lambda_(lambdaFunction)
-    {
-    }
-
-    virtual void Apply(const IMessage& message)
-    {
-      lambda_(dynamic_cast<const TMessage&>(message));
-    }
-
-    virtual MessageType GetMessageType() const
-    {
-      return static_cast<MessageType>(TMessage::Type);
-    }
-
-    virtual IObserver* GetObserver() const
-    {
-      return &observer_;
-    }
-  };
-
-
-}
-
 TEST(MessageBroker, TestLambdaSimpleUseCase)
 {
   MessageBroker broker;