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

Declaration of the MoveCommandList structure along with the support functions, MoveCommandList_Initialize(), MoveCommandList_Clear(), and MoveCommandList_Add(), as used in the Null Object Pattern. More...

#include <stdbool.h>
#include "NullObject_MoveCommand.h"
Include dependency graph for NullObject_MoveCommandList.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MoveCommandList
 Represents a list of MoveCommand objects. More...
 

Macros

#define __NULLOBJECT_MOVECOMMANDLIST_H__
 

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

Declaration of the MoveCommandList structure along with the support functions, MoveCommandList_Initialize(), MoveCommandList_Clear(), and MoveCommandList_Add(), as used in the Null Object Pattern.

Definition in file NullObject_MoveCommandList.h.

Macro Definition Documentation

◆ __NULLOBJECT_MOVECOMMANDLIST_H__

#define __NULLOBJECT_MOVECOMMANDLIST_H__

Definition at line 10 of file NullObject_MoveCommandList.h.

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().