Represents an operation that can be applied to a TextObject. This class can handle two kinds of operations, one that takes no additional parameters and one that takes two additional string parameters. More...
#include <Command_Classes.h>
Public Member Functions | |
Command (Command_TextObject::shared_ptr_t source, const std::string &commandName, two_parameter_operation operation, const std::string &argument1, const std::string &argument2) | |
Constructor for a command that applies an operation to a TextObject, where the operation takes two parameters. | |
Command (Command_TextObject::shared_ptr_t source, const std::string &commandName, no_parameter_operation operation) | |
Constructor for a command that applies an operation to a TextObject but does not take any additional parameters. | |
void | Execute () |
Execute the command on the TextObject. | |
std::string | ToString () |
Convert this command to a string representation. | |
Private Attributes | |
Command_TextObject::shared_ptr_t | _receiver |
std::string | _commandName |
two_parameter_operation | _two_parameter_operation |
no_parameter_operation | _no_parameter_operation |
std::string | _argument1 |
std::string | _argument2 |
Represents an operation that can be applied to a TextObject. This class can handle two kinds of operations, one that takes no additional parameters and one that takes two additional string parameters.
In a real program, the commands would be represented by an interface and concrete classes for each type of operation (based on additional parameters) would be used. This requires the calling entity to instantiate the appropriate concrete class as opposed to letting the C# compiler figure out the correct constructor based on parameters. Or the calling entity could use a class factory to create the concrete classes.
It is also conceivable to make this Command class general case in terms of passing in 0 or more arguments along with a delegate that takes 0 or more arguments. This complicates the actual calling of the delegate and obscures some of the functionality here but it would reduce the API to a single constructor and delegate. But then it's up to the user to get the right number of parameters into the command for the delegate.
Definition at line 117 of file Command_Classes.h.
|
inline |
Constructor for a command that applies an operation to a TextObject, where the operation takes two parameters.
source | The TextObject to apply the operation to. |
commandName | Easy-to-read name of the command. |
operation | The operation to apply to the TextObject. |
argument1 | First argument to the operation (after the TextObject). |
argument2 | Second argument to the operation (after the TextObject). |
Definition at line 148 of file Command_Classes.h.
References Command::_argument1, Command::_argument2, Command::_commandName, Command::_receiver, and Command::_two_parameter_operation.
|
inline |
Constructor for a command that applies an operation to a TextObject but does not take any additional parameters.
source | The TextObject to apply the operation to. |
commandName | Easy-to-read name of the command. |
operation | The operation to apply to the TextObject. |
Definition at line 165 of file Command_Classes.h.
References Command::_commandName, Command::_no_parameter_operation, and Command::_receiver.
|
inline |
Execute the command on the TextObject.
Definition at line 176 of file Command_Classes.h.
References Command::_argument1, Command::_argument2, Command::_no_parameter_operation, Command::_receiver, and Command::_two_parameter_operation.
|
inline |
Convert this command to a string representation.
Definition at line 192 of file Command_Classes.h.
References Command::_argument1, Command::_argument2, Command::_commandName, Command::_no_parameter_operation, Command::_two_parameter_operation, and Helpers::formatstring().
|
private |
Definition at line 133 of file Command_Classes.h.
Referenced by Command::Command(), Command::Execute(), and Command::ToString().
|
private |
Definition at line 136 of file Command_Classes.h.
Referenced by Command::Command(), Command::Execute(), and Command::ToString().
|
private |
Definition at line 124 of file Command_Classes.h.
Referenced by Command::Command(), and Command::ToString().
|
private |
Definition at line 130 of file Command_Classes.h.
Referenced by Command::Command(), Command::Execute(), and Command::ToString().
|
private |
Definition at line 121 of file Command_Classes.h.
Referenced by Command::Command(), and Command::Execute().
|
private |
Definition at line 127 of file Command_Classes.h.
Referenced by Command::Command(), Command::Execute(), and Command::ToString().