Design Pattern Examples
Overview of object-oriented design patterns
DeviceChain Class Reference

Represents a device chain, which is a collection of DeviceNode objects. Part of the Facade Pattern example. More...

Collaboration diagram for DeviceChain:
Collaboration graph

Public Member Functions

 DeviceChain (std::string name)
 Constructor.
 
void AddNode (DeviceNode node)
 Helper method to add a DeviceNode to the device chain. DeviceNode objects that are of DeviceTypes::DEVICECONTROLLER are always inserted as the first device in the device chain, with the assumption there is only one DEVICECONTROLLER in a given device chain (this is not actually enforced, though).
 
void ResetVisibility ()
 Resets the device chain so that all devices that are not CLdevices are no longer visible in the device chain.
 
void SelectNodes (uint32_t nodeSelectMask)
 Make visible one or more devices in the device chain.
 
void DeselectNodes (uint32_t nodeSelectMask)
 Make invisible one or more devices in the device chain.
 
std::vector< uint32_t > GetIdCodesForVisibleNodes ()
 Retrieve a list of idcodes for all devices that are visible in the device chain.
 

Public Attributes

std::string Name
 The Name of this device chain.
 
bool IsLocked
 Whether this device chain is locked for access.
 

Private Member Functions

void _ShowHideNodes (uint32_t nodeSelectMask, bool makeVisible)
 Helper method to show or hide devices on the device chain.
 

Private Attributes

std::vector< DeviceNode_nodes
 The list of TAPNodes on this device chain.
 

Detailed Description

Represents a device chain, which is a collection of DeviceNode objects. Part of the Facade Pattern example.

Definition at line 69 of file Facade_ComplicatedSubSystem.cpp.

Constructor & Destructor Documentation

◆ DeviceChain()

DeviceChain ( std::string  name)
inline

Constructor.

Parameters
nameName of this device chain.

Definition at line 124 of file Facade_ComplicatedSubSystem.cpp.

Member Function Documentation

◆ _ShowHideNodes()

void _ShowHideNodes ( uint32_t  nodeSelectMask,
bool  makeVisible 
)
inlineprivate

Helper method to show or hide devices on the device chain.

Parameters
nodeSelectMaskA bit mask where the position of each bit corresponds to a device in the device chain, with bit 0 being the first device, bit 1 being the second device, and so on.
makeVisibletrue if the device is to be made visible on the device chain; otherwise false, the device cannot be seen on the device chain.

Definition at line 98 of file Facade_ComplicatedSubSystem.cpp.

References DeviceChain::_nodes.

Referenced by DeviceChain::DeselectNodes(), and DeviceChain::SelectNodes().

◆ AddNode()

void AddNode ( DeviceNode  node)
inline

Helper method to add a DeviceNode to the device chain. DeviceNode objects that are of DeviceTypes::DEVICECONTROLLER are always inserted as the first device in the device chain, with the assumption there is only one DEVICECONTROLLER in a given device chain (this is not actually enforced, though).

Parameters
nodeA DeviceNode object to add to the device chain.

Definition at line 139 of file Facade_ComplicatedSubSystem.cpp.

References DeviceChain::_nodes, DesignPatternExamples_cpp::DEVICECONTROLLER, and DeviceNode::DeviceType.

◆ DeselectNodes()

void DeselectNodes ( uint32_t  nodeSelectMask)
inline

Make invisible one or more devices in the device chain.

Parameters
nodeSelectMaska bit mask specifying which device or devices to hide, where bit 0 is the first device, bit 1 is the second, etc. Bit 0 is ignored as the first device is always visible.

Definition at line 185 of file Facade_ComplicatedSubSystem.cpp.

References DeviceChain::_ShowHideNodes().

◆ GetIdCodesForVisibleNodes()

std::vector< uint32_t > GetIdCodesForVisibleNodes ( )
inline

Retrieve a list of idcodes for all devices that are visible in the device chain.

Returns
Returns an array of uints corresponding to the idcodes of each visible device. The first idcode corresponds to the first visible device.

Definition at line 198 of file Facade_ComplicatedSubSystem.cpp.

References DeviceChain::_nodes.

◆ ResetVisibility()

void ResetVisibility ( )
inline

Resets the device chain so that all devices that are not CLdevices are no longer visible in the device chain.

Definition at line 157 of file Facade_ComplicatedSubSystem.cpp.

References DeviceChain::_nodes, and DesignPatternExamples_cpp::DEVICECONTROLLER.

◆ SelectNodes()

void SelectNodes ( uint32_t  nodeSelectMask)
inline

Make visible one or more devices in the device chain.

Parameters
nodeSelectMaska bit mask specifying which device or devices to make visible, where bit 0 is the first device, bit 1 is the second, etc. Bit 0 is ignored as the first device is always visible.

Definition at line 174 of file Facade_ComplicatedSubSystem.cpp.

References DeviceChain::_ShowHideNodes().

Member Data Documentation

◆ _nodes

std::vector<DeviceNode> _nodes
private

◆ IsLocked

bool IsLocked

Whether this device chain is locked for access.

Definition at line 86 of file Facade_ComplicatedSubSystem.cpp.

◆ Name

std::string Name

The Name of this device chain.

Definition at line 81 of file Facade_ComplicatedSubSystem.cpp.

Referenced by Visitor_Shop::PickupOrder(), Visitor_Shop::PlaceOrder(), and EntryInformation::ToString().


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