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

Declaration of the MoveCommand structure along with the support functions, MoveCommand_Create() and MoveCommand_Destroy(), as used in the Null Object Pattern. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MoveCommand
 Represents a move command. A move command has a name and the command character that represents the command in the initial string of movement commands. More...
 

Macros

#define __NULLOBJECT_MOVECOMMAND_H__
 

Typedefs

typedef void(* ExecuteFunction) (void)
 Alias for a function that executes a move command.
 

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

Declaration of the MoveCommand structure along with the support functions, MoveCommand_Create() and MoveCommand_Destroy(), as used in the Null Object Pattern.

Definition in file NullObject_MoveCommand.h.

Macro Definition Documentation

◆ __NULLOBJECT_MOVECOMMAND_H__

#define __NULLOBJECT_MOVECOMMAND_H__

Definition at line 9 of file NullObject_MoveCommand.h.

Typedef Documentation

◆ ExecuteFunction

typedef void(* ExecuteFunction) (void)

Alias for a function that executes a move command.

Definition at line 14 of file NullObject_MoveCommand.h.

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.