Wyatt  1.0.1
Public Member Functions | Protected Attributes | List of all members
Command Class Referenceabstract
Inheritance diagram for Command:
Inheritance graph
[legend]

Public Member Functions

 Command ()
 
virtual ~Command ()
 
void init ()
 
virtual bool execute ()=0
 
virtual bool cleanup (bool canceled)=0
 
void cancel ()
 
void stop ()
 
bool isRunning ()
 
bool isInitialized ()
 
void setIsRunning (bool value)
 
bool isFinished ()
 

Protected Attributes

std::mutex m_lock
 Lock for managing access to member variables in a thread-safe manner.
 

Detailed Description

Definition at line 6 of file Command.h.

Constructor & Destructor Documentation

Command::Command ( )

Create a new command.

Definition at line 7 of file Command.cpp.

Command::~Command ( )
virtual

Destroy the command object.

Definition at line 12 of file Command.cpp.

Member Function Documentation

void Command::cancel ( )

This method is called when a command is canceled. Cancellation only comes from the command manager, so this method should never be directly called. You do not necessarily need to override this function in your command - it will call stop() by default. Only override this if you need custom behavior for when the command is stopped prematurely.

Definition at line 23 of file Command.cpp.

virtual bool Command::cleanup ( bool  canceled)
pure virtual

This method is called to cleanup the command (whenever the stop method is called).

Parameters
canceledtrue if command was canceled, false otherwise.
Returns
True if successful.

Implemented in DriveMotorRPM, DriveRobotCommand, and SimpleIteratorCommand.

virtual bool Command::execute ( )
pure virtual

This method is called periodically during the command execution. Think of it like the Arduino's loop() function. While the command is executing this will be called repeatedly. Do not include while loops in here.

Returns
false if the command is done, true if it needs to continue.

Implemented in DriveMotorRPM, DriveRobotCommand, and SimpleIteratorCommand.

void Command::init ( )

Initialize the command.

Definition at line 16 of file Command.cpp.

bool Command::isFinished ( )

Returns if a command is finished or not.

Returns
true if finished, false otherwise

Definition at line 64 of file Command.cpp.

bool Command::isInitialized ( )

Get if the command is initialized.

Returns
true if init() has been run, false otherwise.

Definition at line 49 of file Command.cpp.

bool Command::isRunning ( )

Get if the command is running or not.

Returns
true if running, false otherwise.

Definition at line 41 of file Command.cpp.

void Command::setIsRunning ( bool  value)

Set the running state of this command.

Parameters
valuebool, running or not

Definition at line 57 of file Command.cpp.

void Command::stop ( )

This method is called when a command has completed execution. Use this method to clean up anything that the command needs to clean before it is destroyed.

Definition at line 32 of file Command.cpp.


The documentation for this class was generated from the following files: