Event-Driven Programming in C++ 1.0
A case study on event-driven programming in C++
Loading...
Searching...
No Matches
TestObserver Class Reference

A test observer that records notification messages. More...

Inheritance diagram for TestObserver:
observer::IObserver

Public Member Functions

void onNotify (const std::string &message) override
 Callback method invoked when the subject notifies the observer.
 
const std::vector< std::string > & getMessages () const
 Retrieves the messages received by this observer.
 
- Public Member Functions inherited from observer::IObserver
virtual ~IObserver ()=default
 Virtual destructor.
 

Private Attributes

std::vector< std::string > messages
 Container to store received notification messages.
 

Detailed Description

A test observer that records notification messages.

This class implements the IObserver interface and stores any messages it receives in a vector. It is used to verify that notifications are delivered correctly.

Member Function Documentation

◆ getMessages()

const std::vector< std::string > & TestObserver::getMessages ( ) const
inline

Retrieves the messages received by this observer.

Returns
A constant reference to the vector of received messages.

◆ onNotify()

void TestObserver::onNotify ( const std::string &  message)
inlineoverridevirtual

Callback method invoked when the subject notifies the observer.

The received message is appended to an internal vector for later verification.

Parameters
messageThe message provided by the subject.

Implements observer::IObserver.

Member Data Documentation

◆ messages

std::vector<std::string> TestObserver::messages
private

Container to store received notification messages.


The documentation for this class was generated from the following file: