8#include "helpers/formatstring.h"
40 std::cout << std::endl;
41 std::cout <<
"Observer Exercise" << std::endl;
56 if (eventNotifier !=
nullptr)
66 for (
int index = 0; index < 10; ++index)
71 numberProducer->Update();
74 if (eventNotifier !=
nullptr)
83 std::cout <<
" Done." << std::endl;
Implementation for the ObserverForDecimal, ObserverForHexaDecimal, and ObserverForBinary classes used...
Declaration of the Observer_Exercise() function as used in the Observer Pattern.
The namespace containing all Design Pattern Examples implemented in C++.
void Observer_Exercise()
Example of using the Observer design pattern.
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....
Represents a Subject that takes observers implementing the IObserverNumberChanged interface.
virtual void UnsubscribeFromNumberChanged(IObserverNumberChanged::shared_ptr_t observer)=0
virtual void SubscribeToNumberChanged(IObserverNumberChanged::shared_ptr_t observer)=0
std::shared_ptr< INumberProducer > shared_ptr_t
Alias to make it easier to use this shared pointer.
std::shared_ptr< IObserverNumberChanged > shared_ptr_t
Alias to make it easier to use this shared pointer.