|
Stride Reference Manual
- generated for commit 9643b11
|
Template for Subject/Observer (or Publish/Subscribe). More...
#include <Subject.h>


Public Types | |
| using | EventType = E |
| using | CallbackType = std::function< void(const EventType &)> |
Public Member Functions | |
| Subject () | |
| virtual | ~Subject () |
| template<typename U > | |
| void | Register (const std::shared_ptr< U > &u, CallbackType f) |
| template<typename U > | |
| void | Unregister (const std::shared_ptr< U > &u) |
| void | UnregisterAll () |
| void | Notify (const EventType &e) |
Private Attributes | |
| std::map< std::weak_ptr< const void >, CallbackType, std::owner_less< std::weak_ptr< const void > > > | m_observers |
Template for Subject/Observer (or Publish/Subscribe).
Offers flexibility in defining event types and having customized callbacks. Despite the shared_ptrs in the Register/Unregister, the Subject takes no ownership of the observer object and only stores a weak_ptr.
Definition at line 37 of file util/Subject.h.
| using stride::util::Subject< E >::EventType = E |
Definition at line 40 of file util/Subject.h.
| using stride::util::Subject< E >::CallbackType = std::function<void(const EventType&)> |
Definition at line 41 of file util/Subject.h.
|
inline |
Definition at line 44 of file util/Subject.h.
|
inlinevirtual |
Definition at line 46 of file util/Subject.h.
|
inline |
Definition at line 49 of file util/Subject.h.
|
inline |
Definition at line 55 of file util/Subject.h.
|
inline |
Definition at line 60 of file util/Subject.h.
Referenced by stride::util::Subject< stride::sim_event::Id >::~Subject().

|
inline |
Definition at line 62 of file util/Subject.h.
|
private |
Definition at line 75 of file util/Subject.h.
Referenced by stride::util::Subject< stride::sim_event::Id >::Notify(), stride::util::Subject< stride::sim_event::Id >::Register(), stride::util::Subject< stride::sim_event::Id >::Unregister(), and stride::util::Subject< stride::sim_event::Id >::UnregisterAll().