Browse Source

Remove "logic" dependency from "event" module

Patrick-Christopher Mattulat 2 years ago
parent
commit
cfc3fc02e2

+ 2 - 2
include/ls_std/event/EventHandler.hpp

@@ -15,7 +15,7 @@
 #include <memory>
 #include <ls_std/core/interface/IListener.hpp>
 #include "Event.hpp"
-#include <ls_std/logic/Narrator.hpp> // FIXME: dependency to "logic" module
+#include "Narrator.hpp"
 
 namespace ls
 {
@@ -23,7 +23,7 @@ namespace ls
   {
     namespace event
     {
-      class EventHandler : public ls::std::logic::Narrator
+      class EventHandler : public ls::std::event::Narrator
       {
         public:
 

+ 2 - 2
include/ls_std/logic/Narrator.hpp → include/ls_std/event/Narrator.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2022-05-11
+ * Changed:         2022-05-12
  *
  * */
 
@@ -19,7 +19,7 @@ namespace ls
 {
   namespace std
   {
-    namespace logic
+    namespace event
     {
       class Narrator : public ls::std::core::Class
       {

+ 1 - 1
include/ls_std/ls_std.hpp

@@ -50,6 +50,7 @@
 #include "event/Event.hpp"
 #include "event/EventHandler.hpp"
 #include "event/EventManager.hpp"
+#include "event/Narrator.hpp"
 
 #include "io/kv/KvDocument.hpp"
 #include "io/kv/KvFileReader.hpp"
@@ -80,7 +81,6 @@
 #include "logic/serialization/SerializableJsonState.hpp"
 #include "logic/serialization/SerializableJsonStateConnection.hpp"
 #include "logic/serialization/SerializableJsonStateMachine.hpp"
-#include "logic/Narrator.hpp"
 #include "logic/State.hpp"
 #include "logic/StateConnection.hpp"
 #include "logic/StateMachine.hpp"

+ 1 - 1
source/ls_std/event/EventHandler.cpp

@@ -10,7 +10,7 @@
 #include <ls_std/event/EventHandler.hpp>
 #include <ls_std/core/exception/IllegalArgumentException.hpp>
 
-ls::std::event::EventHandler::EventHandler(const ls::std::core::type::event_id& _id) : ls::std::logic::Narrator()
+ls::std::event::EventHandler::EventHandler(const ls::std::core::type::event_id& _id) : ls::std::event::Narrator()
 {
   this->_assignId(_id);
 }

+ 8 - 8
source/ls_std/logic/Narrator.cpp

@@ -3,18 +3,18 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2022-05-11
+ * Changed:         2022-05-12
  *
  * */
 
 #include <ls_std/core/utils/STLUtils.hpp>
-#include <ls_std/logic/Narrator.hpp>
+#include <ls_std/event/Narrator.hpp>
 #include <ls_std/core/exception/IllegalArgumentException.hpp>
 
-ls::std::logic::Narrator::Narrator() : ls::std::core::Class("Narrator")
+ls::std::event::Narrator::Narrator() : ls::std::core::Class("Narrator")
 {}
 
-bool ls::std::logic::Narrator::addListener(const ::std::shared_ptr<ls::std::core::IListener> &_listener)
+bool ls::std::event::Narrator::addListener(const ::std::shared_ptr<ls::std::core::IListener> &_listener)
 {
   bool wasAdded{};
 
@@ -34,17 +34,17 @@ bool ls::std::logic::Narrator::addListener(const ::std::shared_ptr<ls::std::core
   return wasAdded;
 }
 
-void ls::std::logic::Narrator::clear()
+void ls::std::event::Narrator::clear()
 {
   this->listeners.clear();
 }
 
-std::list<std::shared_ptr<ls::std::core::IListener>> ls::std::logic::Narrator::getListeners()
+std::list<std::shared_ptr<ls::std::core::IListener>> ls::std::event::Narrator::getListeners()
 {
   return this->listeners;
 }
 
-bool ls::std::logic::Narrator::removeListener(const ::std::shared_ptr<ls::std::core::IListener> &_listener)
+bool ls::std::event::Narrator::removeListener(const ::std::shared_ptr<ls::std::core::IListener> &_listener)
 {
   bool wasRemoved{};
 
@@ -64,7 +64,7 @@ bool ls::std::logic::Narrator::removeListener(const ::std::shared_ptr<ls::std::c
   return wasRemoved;
 }
 
-void ls::std::logic::Narrator::tell(const ls::std::core::Class &_info)
+void ls::std::event::Narrator::tell(const ls::std::core::Class &_info)
 {
   for (const auto &listener : this->listeners)
   {

+ 10 - 10
test/cases/logic/NarratorTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2022-05-11
+ * Changed:         2022-05-12
  *
  * */
 
@@ -44,7 +44,7 @@ namespace
   TEST_F(NarratorTest, addListener)
   {
     this->createCars();
-    ls::std::logic::Narrator paintingMachine{};
+    ls::std::event::Narrator paintingMachine{};
 
     ASSERT_TRUE(paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes1)));
     ASSERT_TRUE(paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes2)));
@@ -54,7 +54,7 @@ namespace
   TEST_F(NarratorTest, addListener_listener_already_exists)
   {
     this->createCars();
-    ls::std::logic::Narrator paintingMachine{};
+    ls::std::event::Narrator paintingMachine{};
 
     ASSERT_TRUE(paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes1)));
     ASSERT_FALSE(paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes1)));
@@ -65,7 +65,7 @@ namespace
     EXPECT_THROW({
                    try
                    {
-                     ls::std::logic::Narrator paintingMachine{};
+                     ls::std::event::Narrator paintingMachine{};
                      paintingMachine.addListener(nullptr);
                    }
                    catch (const ls::std::core::IllegalArgumentException &_exception)
@@ -78,7 +78,7 @@ namespace
   TEST_F(NarratorTest, clear)
   {
     this->createCars();
-    ls::std::logic::Narrator paintingMachine{};
+    ls::std::event::Narrator paintingMachine{};
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes1));
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes2));
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes3));
@@ -90,14 +90,14 @@ namespace
 
   TEST_F(NarratorTest, getListeners)
   {
-    ls::std::logic::Narrator narrator{};
+    ls::std::event::Narrator narrator{};
     ASSERT_TRUE(narrator.getListeners().empty());
   }
 
   TEST_F(NarratorTest, removeListener)
   {
     this->createCars();
-    ls::std::logic::Narrator paintingMachine{};
+    ls::std::event::Narrator paintingMachine{};
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes1));
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes2));
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes3));
@@ -111,7 +111,7 @@ namespace
   TEST_F(NarratorTest, removeListener_no_listener_available)
   {
     this->createCars();
-    ls::std::logic::Narrator paintingMachine{};
+    ls::std::event::Narrator paintingMachine{};
     ASSERT_FALSE(paintingMachine.removeListener(this->mercedes2));
   }
 
@@ -120,7 +120,7 @@ namespace
     EXPECT_THROW({
                    try
                    {
-                     ls::std::logic::Narrator paintingMachine{};
+                     ls::std::event::Narrator paintingMachine{};
                      paintingMachine.removeListener(nullptr);
                    }
                    catch (const ls::std::core::IllegalArgumentException &_exception)
@@ -133,7 +133,7 @@ namespace
   TEST_F(NarratorTest, tell)
   {
     this->createCars();
-    ls::std::logic::Narrator paintingMachine{};
+    ls::std::event::Narrator paintingMachine{};
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes1));
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes2));
     paintingMachine.addListener(std::dynamic_pointer_cast<ls::std::core::IListener>(this->mercedes3));