CodeSubWars 0.4.7b
ARSTD::CommandProcessor Class Reference

#include <CommandProcessor.h>

Inherits ARSTD::ICommandHandler.

Public Member Functions

void execute (std::shared_ptr< Command > pCommand)
 
virtual void repeat ()
 
virtual bool push ()
 
virtual bool pop ()
 
virtual void cleanupHistory ()
 
void cleanup ()
 
void skipCurrent ()
 
bool isBusy ()
 
double getCurrentCommandProgress () const
 
std::string getCurrentCommandName () const
 
unsigned int getNumWaitingCommands () const
 

Detailed Description

This class encapsulates the management of commands. If commands are executed by the commandprocessor, they will be stored and executed one after another till all done.

Member Function Documentation

◆ cleanup()

void ARSTD::CommandProcessor::cleanup ( )

Removes all (executed and waiting) stored commands from the queue.

Postcondition
isBusy() is false

◆ cleanupHistory()

void ARSTD::CommandProcessor::cleanupHistory ( )
virtual

Removes only executed commands that are stored.

◆ execute()

void ARSTD::CommandProcessor::execute ( std::shared_ptr< Command pCommand)

Execute the given command. If other commands are currently executed this command will be stored and executed next.

Parameters
pCommandThe command that will be added to the execution queue.

◆ getCurrentCommandName()

std::string ARSTD::CommandProcessor::getCurrentCommandName ( ) const

Returns the name of the currently executing command.

Returns
The current executing command name. If the processor is not busy "" is returned.

◆ getCurrentCommandProgress()

double ARSTD::CommandProcessor::getCurrentCommandProgress ( ) const

Returns the progress of the currently executing command.

Returns
The progress of the executing command in range [0, 1]. If the processor is not busy -1 is returned.

◆ getNumWaitingCommands()

unsigned int ARSTD::CommandProcessor::getNumWaitingCommands ( ) const

Returns the number of commands that currently waits of its execution.

Returns
The number of currently waiting commands.

◆ isBusy()

bool ARSTD::CommandProcessor::isBusy ( )

Returns true if the processor is currently executing a command otherwise false.

Returns
True if currently executing a command otherwise false.

◆ pop()

bool ARSTD::CommandProcessor::pop ( )
virtual

Restores the topmost context from a stack and makes it current.

Returns
True on success.

◆ push()

bool ARSTD::CommandProcessor::push ( )
virtual

Copies the current context to a stack.

Returns
True on success.

◆ repeat()

void ARSTD::CommandProcessor::repeat ( )
virtual

Repeates all commands that were previously executed.

◆ skipCurrent()

void ARSTD::CommandProcessor::skipCurrent ( )

Removes the currently executing command and do the next (if available).


Generated at Sun Aug 7 2022 for project CodeSubWars. www.codesubwars.org