9#ifndef __OBSERVER_CLASS_H__
10#define __OBSERVER_CLASS_H__
16#include "helpers/formatstring.h"
17#include "helpers/uint32_to_binary.h"
48 "The ObserverForDecimal constructor requires a valid INumberProducer object.");
96 throw Helpers::argumentnull_error(
"numberProducer",
"The ObserverForHexaDecimal constructor requires a valid INumberProducer object.");
The IObserverNumberChanged, IEventNotifications, and INumberProducer interfaces, and the ObserverSubj...
Implementation of the argumentnull_error exception.
Represents an observer that prints out the current number from the Subject in binary.
ObserverForBinary(INumberProducer::shared_ptr_t numberProducer)
Constructor.
INumberProducer::shared_ptr_t _numberProducer
The number producer from which to get the current number.
void NumberChanged()
Called whenever the number is changed in the number producer. This observer instance must first be su...
Represents an observer that prints out the current number from the Subject in decimal.
INumberProducer::shared_ptr_t _numberProducer
The number producer from which to get the current number.
void NumberChanged()
Called whenever the number is changed in the number producer. This observer instance must first be su...
ObserverForDecimal(INumberProducer::shared_ptr_t numberProducer)
Constructor.
Represents an observer that prints out the current number from the Subject in hexadecimal.
INumberProducer::shared_ptr_t _numberProducer
The number producer from which to get the current number.
ObserverForHexaDecimal(INumberProducer::shared_ptr_t numberProducer)
Constructor.
void NumberChanged()
Called whenever the number is changed in the number producer. This observer instance must first be su...
Exception for arguments that are null.
The namespace containing all Design Pattern Examples implemented in C++.
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....
std::string uint32_to_binary(uint32_t number)
Function to convert a 32-bit unsigned integer into a string representation containing all 32 bits.
std::shared_ptr< INumberProducer > shared_ptr_t
Alias to make it easier to use this shared pointer.
Represents an observer to the Subject class. An observer implements this interface and then subscribe...