Design Pattern Examples
Overview of object-oriented design patterns
Facade_Interface.c
Go to the documentation of this file.
1
5
7
8#include "Facade_Interface.h"
9
11
18{
19 if (_lowlevelSystem == NULL)
20 {
22 }
23
24 return _lowlevelSystem != NULL;
25}
26
27
28//====================================================================
29// IDeviceNetworkHighLevel methods
30//====================================================================
31
33static int NumChains(void)
34{
35 int numChains = 0;
36
38 {
39 numChains = _lowlevelSystem->GetNumChains();
40 }
41
42 return numChains;
43}
44
46static void GetIdcodes(int chainIndex, UIntArray* idcodes)
47{
49 {
50 if (_lowlevelSystem->LockDeviceChain(chainIndex))
51 {
52 _lowlevelSystem->GetIdcodes(chainIndex, idcodes);
54 }
55 }
56}
57
59static void EnableDevicesInDeviceChain(int chainIndex, uint32_t selectMask)
60{
62 {
63 if (_lowlevelSystem->LockDeviceChain(chainIndex))
64 {
65 _lowlevelSystem->EnableDevicesInDeviceChain(chainIndex, selectMask);
67 }
68 }
69}
70
72static void DisableDevicesInDeviceChain(int chainIndex)
73{
75 {
76 if (_lowlevelSystem->LockDeviceChain(chainIndex))
77 {
80 }
81 }
82}
83
84
85//#############################################################################
86//#############################################################################
87
97{
102};
103
104//-----------------------------------------------------------------------------
105
107{
108 return &highlevelService;
109}
IDeviceNetworkLowLevel * Facade_GetLowLevelDeviceService(void)
Retrieve a set of function pointers to the low-level device service used in the Facade Pattern exampl...
Declaration of the IDeviceNetworkLowLevel interface representing the complex system for the Facade Pa...
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.
IDeviceNetworkHighLevel * Facade_GetHighLevelDeviceService(void)
Retrieve a set of function pointers to the high-level device service used in the Facade Pattern examp...
static void GetIdcodes(int chainIndex, UIntArray *idcodes)
Returns a list of all idcodes from all selected devices in the given device chain.
static IDeviceNetworkLowLevel * _lowlevelSystem
static bool _InitializeLowLevelSystem(void)
Make sure we have access to the low-level system.
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...
IDeviceNetworkHighLevel highlevelService
Definition of the IDeviceNetworkHighLevel interface, using function pointers to each function.
Declaration of the IDeviceNetworkHighLevel interface representing the high-level system used in the F...
Represents a high level view of a complex network of device chains. A device chain can be thought of ...
Represents a network of device chains and the low level access to that network. In general,...
bool(* UnlockDeviceChain)(int chainIndex)
Unlock the specified device chain to release exclusive access.
void(* ResetDeviceChain)(int chainIndex)
Reset the visibility of all devices on the specified device chain.
bool(* LockDeviceChain)(int chainIndex)
Lock the specified device chain for exclusive access.
void(* GetIdcodes)(int chainIndex, UIntArray *idcodes)
Retrieve a list of idcodes of all visible devices in the given device chain.
void(* EnableDevicesInDeviceChain)(int chainIndex, uint32_t devicesSelectMask)
Make visible the specified devices on the specified device chain.
int(* GetNumChains)(void)
Retrieve the number of device chains available in the network.
Represents an array of 32-bit unsigned integers. The data field points to a block of memory allocated...
Definition: uintarray.h:24