A structure for managing commands. More...
#include <commandQueue.h>
Public Member Functions | |
CommandQueue () | |
Defaut Constructor. | |
CommandQueue (unsigned int max_size) | |
Constructor. | |
void | execute (CommandPtr) |
Executes a command. If the command has an undo function, then adds the command to the queue. | |
unsigned int | setMaxSize (unsigned int size) |
void | undo () |
Undoes the last command by poping the tail of the queue, invoke the undo function of the command. | |
~CommandQueue () | |
Destructor. | |
Static Public Attributes | |
static const unsigned int | DEFAULT_MAX_SIZE_ = 200 |
The default maximal size of the depth limit. | |
Private Member Functions | |
CommandQueue (const CommandQueue &) | |
Copy constructor - object is non-copyable. | |
void | enforceDequeLimit () |
Enforces the depth limit of the command queue. If the depth is larger than the depth limit, a deque operation will be invoked. | |
CommandQueue & | operator= (const CommandQueue &) |
Equal operator - object is non-copyable. | |
Private Attributes | |
std::deque< CommandPtr > | command_deque_ |
The internal representation of this object. | |
unsigned int | depth_limit_ |
The depth limit of the command queue. |
A structure for managing commands.
A command queue object provides a dequeue of commands as well as operations to manipulate the commands in the queue. Operations include executing and undoing the commands in the queue. A command queue object is non-copyable.
Definition at line 53 of file commandQueue.h.
Defaut Constructor.
Creates a command queue object and makes its depth limit be the default value.
Definition at line 44 of file commandQueue.cpp.
CommandQueue::CommandQueue | ( | unsigned int | max_size | ) |
Constructor.
Create a command queue with specified depth limit.
max_size | the value to be used to set the depth limit of this object. |
Definition at line 48 of file commandQueue.cpp.
CommandQueue::~CommandQueue | ( | ) | [inline] |
Destructor.
Definition at line 68 of file commandQueue.h.
CommandQueue::CommandQueue | ( | const CommandQueue & | ) | [inline, private] |
Copy constructor - object is non-copyable.
Definition at line 99 of file commandQueue.h.
void CommandQueue::enforceDequeLimit | ( | ) | [private] |
Enforces the depth limit of the command queue. If the depth is larger than the depth limit, a deque operation will be invoked.
Definition at line 53 of file commandQueue.cpp.
void CommandQueue::execute | ( | CommandPtr | command_ptr | ) |
Executes a command. If the command has an undo function, then adds the command to the queue.
command_ptr | a shared pointer pointing to a command object whose execute function will be invoked by this object. |
Definition at line 61 of file commandQueue.cpp.
CommandQueue& CommandQueue::operator= | ( | const CommandQueue & | ) | [inline, private] |
Equal operator - object is non-copyable.
Definition at line 106 of file commandQueue.h.
unsigned int CommandQueue::setMaxSize | ( | unsigned int | size | ) |
Changes the command history limit.
If the passed size is smaller than the current size then the oldest commands are removed (their undo functions are not called).
size | The new maximum number of commands that may exist in this queue for undo purposes. |
Definition at line 84 of file commandQueue.cpp.
void CommandQueue::undo | ( | ) |
Undoes the last command by poping the tail of the queue, invoke the undo function of the command.
Definition at line 74 of file commandQueue.cpp.
std::deque<CommandPtr> CommandQueue::command_deque_ [private] |
The internal representation of this object.
Definition at line 117 of file commandQueue.h.
const unsigned int CommandQueue::DEFAULT_MAX_SIZE_ = 200 [static] |
The default maximal size of the depth limit.
Definition at line 95 of file commandQueue.h.
unsigned int CommandQueue::depth_limit_ [private] |
The depth limit of the command queue.
Definition at line 120 of file commandQueue.h.