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

Implementation of the MoveCommand structure's support functions, MoveCommand_Create() and MoveCommand_Destroy(), as used in the Null Object Pattern. More...

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

Go to the source code of this file.

Functions

MoveCommandMoveCommand_Create (char commandToken, const char *commandName, ExecuteFunction executeFunction)
 Create a MoveCommand object and initialize it with the given arguments.
 
void MoveCommand_Destroy (MoveCommand *moveCommand)
 Destroy the specified MoveCommand object. After this function returns, the pointer to the MoveCommand is no longer valid.
 

Detailed Description

Implementation of the MoveCommand structure's support functions, MoveCommand_Create() and MoveCommand_Destroy(), as used in the Null Object Pattern.

Definition in file NullObject_MoveCommand.c.

Function Documentation

◆ MoveCommand_Create()

MoveCommand * MoveCommand_Create ( char  commandToken,
const char *  commandName,
ExecuteFunction  executeFunction 
)

Create a MoveCommand object and initialize it with the given arguments.

Parameters
commandTokenThe character representing the command when it appears in a string.
commandNameThe name of the command.
executeFunctionThe function to call to execute the move command.
Returns
Returns the initialize MoveCommand object if successful; otherwise, returns NULL to indicate an out of memory condition (or missing arguments).

Definition at line 15 of file NullObject_MoveCommand.c.

References MoveCommand::commandName, MoveCommand::commandToken, and MoveCommand::Execute.

Referenced by _MoveProcessor_ParseMoves().

◆ MoveCommand_Destroy()

void MoveCommand_Destroy ( MoveCommand moveCommand)

Destroy the specified MoveCommand object. After this function returns, the pointer to the MoveCommand is no longer valid.

Parameters
moveCommandThe MoveCommand object to destroy.

Definition at line 36 of file NullObject_MoveCommand.c.

References MoveCommand::commandName, MoveCommand::commandToken, and MoveCommand::Execute.