Design Pattern Examples
Overview of object-oriented design patterns
Observer_NumberProducer.h
Go to the documentation of this file.
1
8
9#pragma once
10#ifndef __OBSERVER_NUMBERPRODUCER_H__
11#define __OBSERVER_NUMBERPRODUCER_H__
12
14
22typedef struct
23{
27 uint32_t number;
28
34
44
51
69
77
83
84#endif //__OBSERVER_NUMBERPRODUCER_H__
85
Declaration of the NumberChangedFunctionList structure along with its support functions,...
void(* NumberChangedFunction)(uint32_t)
Alias for a function that receives notifications about a number change.
bool NumberProducer_SubscribeToNumberChanged(NumberProducer *producer, NumberChangedFunction observer)
Subscribe to the given NumberProducer to received changes to that producer's number....
void NumberProducer_UpdateNumber(NumberProducer *producer)
Update the number in the given NumberProducer object, triggering a call to all observer in the produc...
void NumberProducer_UnsubscribeFromNumberChanged(NumberProducer *producer, NumberChangedFunction observer)
Unsubscribe from the Given NumberProducer so the given observer will no longer be called when the pro...
void NumberProducer_Destroy(NumberProducer *producer)
Destroy the given instance of a NumberProducer object. After this function returns,...
NumberProducer * NumberProducer_Create(uint32_t number)
Create an instance of the NumberProducer structure and initialize the structure with the specified nu...
Represents a dynamic list of function pointers of the type NumberChangedFunction.
Represents the Subject in this example. In this case, a structure that contains a list of observers a...
NumberChangedFunctionList observerList
The list of observers subscribed to this class instance.
uint32_t number
The number being maintained.