The Subject class manages a list of observers and notifies them of events.
More...
#include <subject.hpp>
|
| void | addObserver (IObserver *observer) |
| | Adds an observer to the list of observers.
|
| |
| void | removeObserver (IObserver *observer) |
| | Removes an observer from the list.
|
| |
| void | notify (const std::string &message) |
| | Notifies all registered observers of an event.
|
| |
|
| std::vector< IObserver * > | observers |
| | Container storing pointers to the registered observers.
|
| |
The Subject class manages a list of observers and notifies them of events.
The Subject class provides methods to add and remove observers, as well as to notify all registered observers by calling their onNotify() method.
◆ addObserver()
| void observer::Subject::addObserver |
( |
IObserver * |
observer | ) |
|
|
inline |
Adds an observer to the list of observers.
- Parameters
-
| observer | A pointer to an object implementing the IObserver interface. |
◆ notify()
| void observer::Subject::notify |
( |
const std::string & |
message | ) |
|
|
inline |
Notifies all registered observers of an event.
This method calls the onNotify() function on each observer, passing the provided message.
- Parameters
-
| message | A string describing the event. |
◆ removeObserver()
| void observer::Subject::removeObserver |
( |
IObserver * |
observer | ) |
|
|
inline |
Removes an observer from the list.
- Parameters
-
| observer | A pointer to the observer to remove. |
◆ observers
| std::vector<IObserver*> observer::Subject::observers |
|
private |
Container storing pointers to the registered observers.
The documentation for this class was generated from the following file: