summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h')
-rw-r--r--src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h62
1 files changed, 12 insertions, 50 deletions
diff --git a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h
index ff21b01c58..3d236b9c0f 100644
--- a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h
+++ b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,11 +34,6 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_DISPATCHER_H_
#include <list>
-#include <map>
-
-#include "utils/lock.h"
-#include "utils/singleton.h"
-
#include "application_manager/event_engine/event.h"
namespace application_manager {
@@ -46,15 +41,14 @@ namespace event_engine {
class EventObserver;
-class EventDispatcher : public utils::Singleton<EventDispatcher> {
+class EventDispatcher {
public:
-
/*
* @brief Delivers the event to all subscribers
*
* @param event Received event
*/
- void raise_event(const Event& event);
+ virtual void raise_event(const Event& event) = 0;
/*
* @brief Subscribe the observer to event
@@ -63,9 +57,9 @@ class EventDispatcher : public utils::Singleton<EventDispatcher> {
* @param hmi_correlation_id The event HMI correlation ID
* @param observer The observer to subscribe for event
*/
- void add_observer(const Event::EventID& event_id,
- int32_t hmi_correlation_id,
- EventObserver* const observer);
+ virtual void add_observer(const Event::EventID& event_id,
+ int32_t hmi_correlation_id,
+ EventObserver& observer) = 0;
/*
* @brief Unsubscribes the observer from specific event
@@ -73,55 +67,23 @@ class EventDispatcher : public utils::Singleton<EventDispatcher> {
* @param event_id The event ID to unsubscribe from
* @param observer The observer to be unsubscribed
*/
- void remove_observer(const Event::EventID& event_id,
- EventObserver* const observer);
+ virtual void remove_observer(const Event::EventID& event_id,
+ EventObserver& observer) = 0;
/*
* @brief Unsubscribes the observer from all events
*
* @param observer The observer to be unsubscribed
*/
- void remove_observer(EventObserver* const observer);
-
- protected:
-
- private:
-
- /*
- * @brief Default constructor
- */
- EventDispatcher();
+ virtual void remove_observer(EventObserver& observer) = 0;
/*
* @brief Destructor
*/
- virtual ~EventDispatcher();
-
- /*
- * @brief removes observer
- * when occurs unsubscribe from event
- * @param observer to be removed
- */
- void remove_observer_from_list(EventObserver* const observer);
-
- DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
-
- FRIEND_BASE_SINGLETON_CLASS(EventDispatcher);
-
- // Data types section
- typedef std::list<EventObserver*> ObserverList;
- typedef std::map<int32_t, ObserverList> ObserversMap;
- typedef std::map<Event::EventID, ObserversMap> EventObserverMap;
-
- // Members section
- sync_primitives::Lock state_lock_;
- sync_primitives::Lock observer_list_lock_;
- EventObserverMap observers_;
- ObserverList observers_list_;
-
+ virtual ~EventDispatcher(){};
};
-}
-}
+} // namespace event_engine
+} // namespace application_manager
#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_DISPATCHER_H_