frepple::utils::CommandList Class Reference
A container command to group a series of commands together. More...
#include <utils.h>

Public Member Functions | |
void | add (Command *c) |
CommandList () | |
bool | empty () const |
void | execute () |
bool | getAbortOnError () const |
Command * | getFirstCommand () const |
Command * | getLastCommand () const |
int | getMaxParallel () const |
int | getNumberOfCommands () const |
void | setAbortOnError (bool b) |
void | setMaxParallel (int b) |
void | undo (Command *c) |
void | undo () |
bool | undoable (const Command *c) const |
bool | undoable () const |
virtual | ~CommandList () |
Detailed Description
A container command to group a series of commands together.
This class implements the "composite" design pattern in order to get an efficient and intuitive hierarchical grouping of tasks.
A command list can be executed in three different modes:
- Run the commands in parallel with each other, in seperate threads.
This is achieved by setting the sequential field to false. - Run the commands in sequence, and abort the command sequence when one of the commands in the list fails.
This mode requires the sequential field to be set to true, and the AbortOnError field to true. - Run the commands in sequence, and continue the command sequence when some commands in the sequence fail.
This mode requires the sequential field to be set to true, and the AbortOnError field to false. Currently Pthreads and Windows threads are supported as the implementation of the multithreading.
Definition at line 3842 of file utils.h.
Constructor & Destructor Documentation
frepple::utils::CommandList::CommandList | ( | ) | [inline, explicit] |
frepple::utils::CommandList::~CommandList | ( | ) | [virtual] |
Destructor.
A commandlist should only be deleted when all of its commands have been committed or undone. If this is not the case a warning will be printed.
Definition at line 369 of file utils/actions.cpp.
Member Function Documentation
void frepple::utils::CommandList::add | ( | Command * | c | ) |
Append an additional command to the end of the list.
Definition at line 77 of file utils/actions.cpp.
bool frepple::utils::CommandList::empty | ( | ) | const [inline] |
void frepple::utils::CommandList::execute | ( | ) | [virtual] |
Commits all actions on its list. At the end it also clear the list of actions.
Implements frepple::utils::Command.
Reimplemented in frepple::SolverMRP::SolverMRPdata.
Definition at line 167 of file utils/actions.cpp.
bool frepple::utils::CommandList::getAbortOnError | ( | ) | const |
Returns whether or not a single failure aborts the complete command list.
Definition at line 63 of file utils/actions.cpp.
Command* frepple::utils::CommandList::getFirstCommand | ( | ) | const [inline] |
Command* frepple::utils::CommandList::getLastCommand | ( | ) | const [inline] |
int frepple::utils::CommandList::getMaxParallel | ( | ) | const [inline] |
int frepple::utils::CommandList::getNumberOfCommands | ( | ) | const [inline] |
void frepple::utils::CommandList::setAbortOnError | ( | bool | b | ) | [inline] |
void frepple::utils::CommandList::setMaxParallel | ( | int | b | ) | [inline] |
void frepple::utils::CommandList::undo | ( | Command * | c | ) |
Undoes all actions in the list beyond the argument and clear the list of actions.
As soon as one of the actions on the list is not undo-able or the execution is not sequential, the undo is aborted and a warning message is printed.
There is no need that the actions have actually been executed before the undo() is called.
Definition at line 102 of file utils/actions.cpp.
void frepple::utils::CommandList::undo | ( | ) | [inline, virtual] |
Undoes all actions on the list. At the end it also clears the list of actions. If one of the actions on the list is not undo-able, the whole list is non-undoable and a warning message will be printed.
Reimplemented from frepple::utils::Command.
bool frepple::utils::CommandList::undoable | ( | const Command * | c | ) | const |
Returns true when all commands beyond the argument can be undone.
Definition at line 140 of file utils/actions.cpp.
bool frepple::utils::CommandList::undoable | ( | ) | const [inline, virtual] |
Returns whether this command can be undone or not.
Reimplemented from frepple::utils::Command.
The documentation for this class was generated from the following files:
Documentation generated for frePPLe by
