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

Implementation of the Facade_Exercise() function as used in the Facade Pattern. More...

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Facade_Interface.h"
#include "Facade_Exercise.h"
Include dependency graph for Facade_Exercise.c:

Go to the source code of this file.

Functions

static void _Facade_ShowIdCodes (int chainIndex, UIntArray *idcodes)
 Helper function to present a formatted list of idcodes for a particular device chain. The output is on a single line.
 
void Facade_Exercise (void)
 Example of using the Facade Pattern.
 

Detailed Description

Implementation of the Facade_Exercise() function as used in the Facade Pattern.

Definition in file Facade_Exercise.c.

Function Documentation

◆ _Facade_ShowIdCodes()

static void _Facade_ShowIdCodes ( int  chainIndex,
UIntArray idcodes 
)
static

Helper function to present a formatted list of idcodes for a particular device chain. The output is on a single line.

Parameters
chainIndexIndex of the device chain being displayed.
idcodesArray of 32-bit idcodes to be printed in hex.

Definition at line 25 of file Facade_Exercise.c.

References UIntArray::data, and UIntArray::length.

Referenced by DesignPatternExamples_cpp::Facade_Exercise(), and Facade_Exercise().

◆ Facade_Exercise()

void Facade_Exercise ( void  )

Example of using the Facade Pattern.

The Facade pattern is used when a simplified version of an interface on a complicated sub-system is needed in situations where the whole complicated sub-system does not need to be exposed.

In this example, the complicated subsystem is a representation of a device network complete with scan chains, device idcodes, and device devices that can be selected and deselected. The Facade exposed by this complex network exposes only the scan chain, getting device idcodes based on an index into those scan chains, resetting the scan chains and selecting a device to appear in the scan chain.

Definition at line 58 of file Facade_Exercise.c.

References _Facade_ShowIdCodes(), IDeviceNetworkHighLevel::DisableDevicesInDeviceChain, IDeviceNetworkHighLevel::EnableDevicesInDeviceChain, Facade_GetHighLevelDeviceService(), IDeviceNetworkHighLevel::GetIdcodes, IDeviceNetworkHighLevel::NumChains, UIntArray_Clear(), and UIntArray_Initialize().