Design Pattern Examples
Overview of object-oriented design patterns
INumberProducer Struct Referenceabstract

Represents the Subject to the observers. This is the minimum needed by observers to get access to the data provided by the Subject class. More...

#include <ObserverSubject_NumberProducer.h>

Inheritance diagram for INumberProducer:
Inheritance graph
Collaboration diagram for INumberProducer:
Collaboration graph

Public Types

using shared_ptr_t = std::shared_ptr< INumberProducer >
 Alias to make it easier to use this shared pointer.
 

Public Member Functions

virtual ~INumberProducer ()
 Virtual destructor required for interfaces in abstract classes.
 
virtual void Update ()=0
 Update the number then notify all observers.
 
virtual uint32_t FetchNumber ()=0
 Return the current value from the Subject.
 

Detailed Description

Represents the Subject to the observers. This is the minimum needed by observers to get access to the data provided by the Subject class.

An interface is used to represent the Subject to the observers so the observers do not have too much knowledge about the Subject, allowing more freedom to change the Subject class implementation without affecting observers. This interface would naturally have to change if the observers needed more data from the Subject.

Definition at line 107 of file ObserverSubject_NumberProducer.h.

Member Typedef Documentation

◆ shared_ptr_t

using shared_ptr_t = std::shared_ptr<INumberProducer>

Alias to make it easier to use this shared pointer.

Definition at line 112 of file ObserverSubject_NumberProducer.h.

Constructor & Destructor Documentation

◆ ~INumberProducer()

virtual ~INumberProducer ( )
inlinevirtual

Virtual destructor required for interfaces in abstract classes.

Definition at line 117 of file ObserverSubject_NumberProducer.h.

Member Function Documentation

◆ FetchNumber()

virtual uint32_t FetchNumber ( )
pure virtual

Return the current value from the Subject.

Returns
Returns an unsigned integer that is the current value.

Implemented in ObserverSubject_NumberProducer.

◆ Update()

virtual void Update ( )
pure virtual

Update the number then notify all observers.

Implemented in ObserverSubject_NumberProducer.


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