Design Pattern Examples
Overview of object-oriented design patterns
Facade_Interface.c File Reference

Implementation of the IDeviceNetworkHighLevel interface and the simplified implementation on top of the complex system for the Facade Pattern. More...

Include dependency graph for Facade_Interface.c:

Go to the source code of this file.

Functions

static bool _InitializeLowLevelSystem (void)
 Make sure we have access to the low-level system.
 
static int NumChains (void)
 The number of device chains available from the sub-system.
 
static void GetIdcodes (int chainIndex, UIntArray *idcodes)
 Returns a list of all idcodes from all selected devices in the given device chain.
 
static void EnableDevicesInDeviceChain (int chainIndex, uint32_t selectMask)
 Make visible certain devices in the given device chain. The selectMask value has a bit set for each device to make visible.
 
static void DisableDevicesInDeviceChain (int chainIndex)
 Resets the given device chain so that all devices except the first are no longer visible.
 
IDeviceNetworkHighLevelFacade_GetHighLevelDeviceService (void)
 Retrieve a set of function pointers to the high-level device service used in the Facade Pattern example.
 

Variables

static IDeviceNetworkLowLevel_lowlevelSystem = NULL
 
IDeviceNetworkHighLevel highlevelService
 Definition of the IDeviceNetworkHighLevel interface, using function pointers to each function.
 

Detailed Description

Implementation of the IDeviceNetworkHighLevel interface and the simplified implementation on top of the complex system for the Facade Pattern.

Definition in file Facade_Interface.c.

Function Documentation

◆ _InitializeLowLevelSystem()

static bool _InitializeLowLevelSystem ( void  )
static

Make sure we have access to the low-level system.

Returns
Returns true if the low-level system is available; otherwise, return false, cannot use the low-level system.

Definition at line 17 of file Facade_Interface.c.

References _lowlevelSystem, and Facade_GetLowLevelDeviceService().

Referenced by DisableDevicesInDeviceChain(), EnableDevicesInDeviceChain(), GetIdcodes(), and NumChains().

◆ DisableDevicesInDeviceChain()

static void DisableDevicesInDeviceChain ( int  chainIndex)
static

Resets the given device chain so that all devices except the first are no longer visible.

Parameters
chainIndexIndex of the device chain to access (0..NumChains-1).

Definition at line 72 of file Facade_Interface.c.

References _InitializeLowLevelSystem(), _lowlevelSystem, IDeviceNetworkLowLevel::LockDeviceChain, IDeviceNetworkLowLevel::ResetDeviceChain, and IDeviceNetworkLowLevel::UnlockDeviceChain.

◆ EnableDevicesInDeviceChain()

static void EnableDevicesInDeviceChain ( int  chainIndex,
uint32_t  selectMask 
)
static

Make visible certain devices in the given device chain. The selectMask value has a bit set for each device to make visible.

Parameters
chainIndexIndex of the device chain to access (0..NumChains-1).
selectMaskA bit mask where each bit corresponds to a device, up to the number of devices in the given device chain. Bit 0 is ignored as the first device is always visible.

Definition at line 59 of file Facade_Interface.c.

References _InitializeLowLevelSystem(), _lowlevelSystem, IDeviceNetworkLowLevel::EnableDevicesInDeviceChain, IDeviceNetworkLowLevel::LockDeviceChain, and IDeviceNetworkLowLevel::UnlockDeviceChain.

◆ Facade_GetHighLevelDeviceService()

IDeviceNetworkHighLevel * Facade_GetHighLevelDeviceService ( void  )

Retrieve a set of function pointers to the high-level device service used in the Facade Pattern example.

Returns
Returns an IDeviceNetworkHighLevel interface representing a simplified access to the full device network.

Definition at line 106 of file Facade_Interface.c.

References highlevelService.

Referenced by Facade_Exercise().

◆ GetIdcodes()

static void GetIdcodes ( int  chainIndex,
UIntArray idcodes 
)
static

Returns a list of all idcodes from all selected devices in the given device chain.

Parameters
chainIndexIndex of the device chain to access (0..NumChains-1).
idcodesA UIntArray that is filled in with the idcodes of the selected devices. This UIntArray object needs to be initialized before use with UIntArray_Initialize() and freed after use with UIntArray_Clear().

Definition at line 46 of file Facade_Interface.c.

References _InitializeLowLevelSystem(), _lowlevelSystem, IDeviceNetworkLowLevel::GetIdcodes, IDeviceNetworkLowLevel::LockDeviceChain, and IDeviceNetworkLowLevel::UnlockDeviceChain.

◆ NumChains()

static int NumChains ( void  )
static

The number of device chains available from the sub-system.

Definition at line 33 of file Facade_Interface.c.

References _InitializeLowLevelSystem(), _lowlevelSystem, and IDeviceNetworkLowLevel::GetNumChains.

Variable Documentation

◆ _lowlevelSystem

◆ highlevelService

IDeviceNetworkHighLevel highlevelService
Initial value:
=
{
}
static void DisableDevicesInDeviceChain(int chainIndex)
Resets the given device chain so that all devices except the first are no longer visible.
static int NumChains(void)
The number of device chains available from the sub-system.
static void GetIdcodes(int chainIndex, UIntArray *idcodes)
Returns a list of all idcodes from all selected devices in the given device chain.
static void EnableDevicesInDeviceChain(int chainIndex, uint32_t selectMask)
Make visible certain devices in the given device chain. The selectMask value has a bit set for each d...

Definition of the IDeviceNetworkHighLevel interface, using function pointers to each function.

The function pointers set here must be in the same order they are defined in the IDeviceNetworkHighLevel structure representing the interface.

Definition at line 96 of file Facade_Interface.c.

Referenced by Facade_GetHighLevelDeviceService().