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

Implementation of the MoveCommandList structure's support functions, MoveCommandList_Initialize(), MoveCommandList_Clear(), and MoveCommandList_Add(), as used in the Null Object Pattern. More...

#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include "NullObject_MoveCommandList.h"
Include dependency graph for NullObject_MoveCommandList.c:

Go to the source code of this file.

Functions

void MoveCommandList_Initialize (MoveCommandList *commandList)
 Initialize the given MoveCommandList object. This should be the first function called for an uninitialized MoveCommandList object.
 
void MoveCommandList_Clear (MoveCommandList *commandList)
 Clear the given MoveCommandList, freeing up any allocated resources, so the list can be reused.
 
bool MoveCommandList_Add (MoveCommandList *commandList, MoveCommand *moveCommand)
 Add a given MoveCommand object to the given MoveCommandList object. The MoveCommandList takes ownership and thus responsibility for freeing the memory of the MoveCommand object.
 

Detailed Description

Implementation of the MoveCommandList structure's support functions, MoveCommandList_Initialize(), MoveCommandList_Clear(), and MoveCommandList_Add(), as used in the Null Object Pattern.

Definition in file NullObject_MoveCommandList.c.

Function Documentation

◆ MoveCommandList_Add()

bool MoveCommandList_Add ( MoveCommandList commandList,
MoveCommand moveCommand 
)

Add a given MoveCommand object to the given MoveCommandList object. The MoveCommandList takes ownership and thus responsibility for freeing the memory of the MoveCommand object.

Parameters
commandListThe MoveCommandList object to add to.
moveCommandThe MoveCommand to add.
Returns
Returns true if the command was added successfully; otherwise, returns false (out of memory or a null argument was passed in).

Definition at line 45 of file NullObject_MoveCommandList.c.

References MoveCommandList::commands, and MoveCommandList::commands_count.

Referenced by _MoveProcessor_ParseMoves().

◆ MoveCommandList_Clear()

void MoveCommandList_Clear ( MoveCommandList commandList)

Clear the given MoveCommandList, freeing up any allocated resources, so the list can be reused.

Parameters
commandListThe MoveCommandList to clear.

Definition at line 29 of file NullObject_MoveCommandList.c.

References MoveCommandList::commands, MoveCommandList::commands_count, and MoveCommandList_Initialize().

Referenced by _MoveProcessor_ParseMoves(), MoveProcessor_ExecuteMoveList(), and MoveProcessor_ShowMoveList().

◆ MoveCommandList_Initialize()

void MoveCommandList_Initialize ( MoveCommandList commandList)

Initialize the given MoveCommandList object. This should be the first function called for an uninitialized MoveCommandList object.

Parameters
commandListThe MoveCommandList object to initialize.

Definition at line 17 of file NullObject_MoveCommandList.c.

References MoveCommandList::commands, and MoveCommandList::commands_count.

Referenced by MoveCommandList_Clear(), MoveProcessor_ExecuteMoveList(), and MoveProcessor_ShowMoveList().