Browse Source

Improve namespace layout for "event" module

Patrick-Christopher Mattulat 2 years ago
parent
commit
b2796066bb

+ 25 - 31
include/ls_std/event/Event.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-26
- * Changed:         2022-06-29
+ * Changed:         2022-07-02
  *
  * */
 
@@ -16,38 +16,32 @@
 #include <ls_std/core/types/EventTypes.hpp>
 #include <ls_std/os/dynamic_goal.hpp>
 
-namespace ls
+namespace ls::std::event
 {
-  namespace std
+  class DYNAMIC_GOAL Event : public ls::std::core::Class
   {
-    namespace event
-    {
-      class DYNAMIC_GOAL Event : public ls::std::core::Class
-      {
-        public:
-
-          explicit Event(const ls::std::core::type::event_id &_id);
-          ~Event() override = default;
-
-          // additional functionality
-
-          bool addParameter(const ls::std::core::type::event_parameter &_eventParameter);
-          void clearParameterList();
-          ls::std::core::type::event_id getId();
-          ls::std::core::type::event_parameter_list getParameterList();
-          bool removeParameter(const ls::std::core::type::event_parameter_id &_id);
-          void setId(const ls::std::core::type::event_id &_id);
-
-        private:
-
-          ls::std::core::type::event_id id{};
-          ls::std::core::type::event_parameter_list parameterList{};
-
-          void _assignId(const ls::std::core::type::event_id &_id);
-          bool _hasParameter(const ls::std::core::type::event_id &_id);
-      };
-    }
-  }
+    public:
+
+      explicit Event(const ls::std::core::type::event_id &_id);
+      ~Event() override = default;
+
+      // additional functionality
+
+      bool addParameter(const ls::std::core::type::event_parameter &_eventParameter);
+      void clearParameterList();
+      ls::std::core::type::event_id getId();
+      ls::std::core::type::event_parameter_list getParameterList();
+      bool removeParameter(const ls::std::core::type::event_parameter_id &_id);
+      void setId(const ls::std::core::type::event_id &_id);
+
+    private:
+
+      ls::std::core::type::event_id id{};
+      ls::std::core::type::event_parameter_list parameterList{};
+
+      void _assignId(const ls::std::core::type::event_id &_id);
+      bool _hasParameter(const ls::std::core::type::event_id &_id);
+  };
 }
 
 #endif

+ 11 - 17
include/ls_std/event/EventHandler.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2022-06-29
+ * Changed:         2022-07-02
  *
  * */
 
@@ -18,29 +18,23 @@
 #include "Event.hpp"
 #include "Narrator.hpp"
 
-namespace ls
+namespace ls::std::event
 {
-  namespace std
+  class DYNAMIC_GOAL EventHandler : public ls::std::event::Narrator
   {
-    namespace event
-    {
-      class DYNAMIC_GOAL EventHandler : public ls::std::event::Narrator
-      {
-        public:
+    public:
 
-          explicit EventHandler(const ls::std::core::type::event_id &_id);
-          ~EventHandler() override = default;
+      explicit EventHandler(const ls::std::core::type::event_id &_id);
+      ~EventHandler() override = default;
 
-          ls::std::core::type::event_id getId();
+      ls::std::core::type::event_id getId();
 
-        private:
+    private:
 
-          ls::std::core::type::event_id id{};
+      ls::std::core::type::event_id id{};
 
-          void _assignId(const ls::std::core::type::event_id &_id);
-      };
-    }
-  }
+      void _assignId(const ls::std::core::type::event_id &_id);
+  };
 }
 
 #endif

+ 19 - 25
include/ls_std/event/EventManager.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2022-06-29
+ * Changed:         2022-07-02
  *
  * */
 
@@ -18,40 +18,34 @@
 #include <ls_std/core/interface/IEventSubscriber.hpp>
 #include <ls_std/os/dynamic_goal.hpp>
 
-namespace ls
+namespace ls::std::event
 {
-  namespace std
+  class DYNAMIC_GOAL EventManager : public ls::std::core::Class, public ls::std::core::interface_type::IEventSubscriber
   {
-    namespace event
-    {
-      class DYNAMIC_GOAL EventManager : public ls::std::core::Class, public ls::std::core::interface_type::IEventSubscriber
-      {
-        public:
+    public:
 
-          explicit EventManager();
-          ~EventManager() override = default;
+      explicit EventManager();
+      ~EventManager() override = default;
 
-          // implementation
+      // implementation
 
-          void subscribe(const ls::std::core::type::event_id &_id, const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener) override;
-          void unsubscribe(const ls::std::core::type::event_id &_id, const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener) override;
+      void subscribe(const ls::std::core::type::event_id &_id, const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener) override;
+      void unsubscribe(const ls::std::core::type::event_id &_id, const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener) override;
 
-          // additional functionality
+      // additional functionality
 
-          bool addEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler);
-          void fire(ls::std::event::Event _event);
-          bool hasEventHandler(const ls::std::core::type::event_id &_id);
-          bool removeEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler);
+      bool addEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler);
+      void fire(ls::std::event::Event _event);
+      bool hasEventHandler(const ls::std::core::type::event_id &_id);
+      bool removeEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler);
 
-        private:
+    private:
 
-          ::std::map<ls::std::core::type::event_id, ::std::shared_ptr<ls::std::event::EventHandler>> eventHandlers{};
+      ::std::map<ls::std::core::type::event_id, ::std::shared_ptr<ls::std::event::EventHandler>> eventHandlers{};
 
-          bool _hasEventHandler(const ls::std::core::type::event_id &_id);
-          bool _removeEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler);
-      };
-    }
-  }
+      bool _hasEventHandler(const ls::std::core::type::event_id &_id);
+      bool _removeEventHandler(const ::std::shared_ptr<ls::std::event::EventHandler> &_eventHandler);
+  };
 }
 
 #endif

+ 18 - 24
include/ls_std/event/Narrator.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-14
- * Changed:         2022-06-29
+ * Changed:         2022-07-02
  *
  * */
 
@@ -16,31 +16,25 @@
 #include <list>
 #include <memory>
 
-namespace ls
+namespace ls::std::event
 {
-  namespace std
+  class DYNAMIC_GOAL Narrator : public ls::std::core::Class
   {
-    namespace event
-    {
-      class DYNAMIC_GOAL Narrator : public ls::std::core::Class
-      {
-        public:
-
-          Narrator();
-          ~Narrator() override = default;
-
-          bool addListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener);
-          void clear();
-          ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> getListeners();
-          bool removeListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener);
-          void tell(const ls::std::core::Class &_info);
-
-        private:
-
-          ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> listeners{};
-      };
-    }
-  }
+    public:
+
+      Narrator();
+      ~Narrator() override = default;
+
+      bool addListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener);
+      void clear();
+      ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> getListeners();
+      bool removeListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener);
+      void tell(const ls::std::core::Class &_info);
+
+    private:
+
+      ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> listeners{};
+  };
 }
 
 #endif

+ 20 - 26
include/ls_std/event/serialization/SerializableJsonEvent.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-07
- * Changed:         2022-06-29
+ * Changed:         2022-07-02
  *
  * */
 
@@ -17,41 +17,35 @@
 #include <ls_std/lib/nlohmann_json/include/nlohmann/json.hpp>
 #include <ls_std/os/dynamic_goal.hpp>
 
-namespace ls
+namespace ls::std::event
 {
-  namespace std
+  class DYNAMIC_GOAL SerializableJsonEvent : public ls::std::core::Class, public ls::std::core::interface_type::ISerializable
   {
-    namespace event
-    {
-      class DYNAMIC_GOAL SerializableJsonEvent : public ls::std::core::Class, public ls::std::core::interface_type::ISerializable
-      {
-        public:
+    public:
 
-          explicit SerializableJsonEvent(const ::std::shared_ptr<ls::std::event::Event> &_value);
-          ~SerializableJsonEvent() override = default;
+      explicit SerializableJsonEvent(const ::std::shared_ptr<ls::std::event::Event> &_value);
+      ~SerializableJsonEvent() override = default;
 
-          // implementation
+      // implementation
 
-          ls::std::core::type::byte_field marshal() override;
-          void unmarshal(const ls::std::core::type::byte_field &_data) override;
+      ls::std::core::type::byte_field marshal() override;
+      void unmarshal(const ls::std::core::type::byte_field &_data) override;
 
-          // additional functionality
+      // additional functionality
 
-          ::std::shared_ptr<ls::std::event::Event> getValue();
-          void setValue(const ::std::shared_ptr<ls::std::event::Event> &_value);
+      ::std::shared_ptr<ls::std::event::Event> getValue();
+      void setValue(const ::std::shared_ptr<ls::std::event::Event> &_value);
 
-        private:
+    private:
 
-          nlohmann::json jsonObject{};
-          ::std::shared_ptr<ls::std::event::Event> value{};
+      nlohmann::json jsonObject{};
+      ::std::shared_ptr<ls::std::event::Event> value{};
 
-          void _assignValue(const ::std::shared_ptr<ls::std::event::Event> &_value);
-          void _unmarshalParameterList();
-          void _update();
-          void _updateEventParameterList();
-      };
-    }
-  }
+      void _assignValue(const ::std::shared_ptr<ls::std::event::Event> &_value);
+      void _unmarshalParameterList();
+      void _update();
+      void _updateEventParameterList();
+  };
 }
 
 #endif