#include <CommandProcessor.h>
Inheritance diagram for CommandProcessor::
Public Methods | |
CommandProcessor () | |
virtual | ~CommandProcessor () |
void | processCommands () |
The template method. More... | |
void | setParser (CommandParser *parser) |
void | startThread () |
Call this function to start the processor thread. More... | |
virtual void | stopThread () |
std::vector< Command *> | getCommandList () |
virtual void | toStream (std::ostream &out) |
Command * | matchCommand (std::string command) |
Match a command string to its command object. More... | |
void | addCommand (Command *command) |
Add a command to internal command list. More... | |
Protected Methods | |
virtual void | init () |
Subclasses can override this to do their own initialization if they need to. More... | |
virtual void | readCommand (std::string *input)=0 |
virtual void | displayResponse (std::string *output)=0 |
virtual void | generateError (std::string *input, std::ostream &output) |
Static Private Methods | |
void * | daemonThread (void *) |
Private Attributes | |
CommandParser * | m_parser |
pthread_t | m_daemonThreadId |
int | m_commandsProcessed |
std::vector< Command *> | m_commandList |
The "processCommands" function is the Template Method. Subclasses must override readCommand() and displayResponse(), and optionally init().
To add a new command to the command processor, define a subclass of Command, and make sure to override the pure virtual functions. Then, add the command in the setParser function inside of CommandProcessor. Then you are done.
Definition at line 11 of file CommandProcessor.h.
|
Definition at line 15 of file CommandProcessor.cpp. |
|
Definition at line 14 of file CommandProcessor.h. |
|
Add a command to internal command list.
Definition at line 63 of file CommandProcessor.cpp. Referenced by GlobalObjects::init(), and GlobalObjects::initializeCommands().
|
|
Definition at line 43 of file CommandProcessor.cpp. |
|
Reimplemented in FileHandleCommandProcessor, HttpTestCommandProcessor, and ProxyCommandProcessor. Referenced by processCommands().
|
|
Reimplemented in ProxyCommandProcessor. Definition at line 138 of file CommandProcessor.cpp. Referenced by processCommands().
|
|
Definition at line 132 of file CommandProcessor.cpp. |
|
Subclasses can override this to do their own initialization if they need to.
Reimplemented in FileHandleCommandProcessor. Definition at line 96 of file CommandProcessor.cpp. Referenced by processCommands().
|
|
Match a command string to its command object.
Definition at line 76 of file CommandProcessor.cpp. |
|
The template method. Reads in commands, parses them, executes them, and then displays the output. Definition at line 105 of file CommandProcessor.cpp. Referenced by daemonThread().
|
|
Reimplemented in FileHandleCommandProcessor, HttpTestCommandProcessor, and ProxyCommandProcessor. Referenced by processCommands().
|
|
Definition at line 54 of file CommandProcessor.cpp. Referenced by CommandProcessor(), and GlobalObjects::init().
|
|
Call this function to start the processor thread.
Definition at line 25 of file CommandProcessor.cpp. Referenced by GlobalObjects::init().
|
|
Reimplemented in HttpTestCommandProcessor, and ProxyCommandProcessor. Definition at line 34 of file CommandProcessor.cpp. Referenced by ProxyCommandProcessor::stopThread(), and HttpTestCommandProcessor::stopThread().
|
|
Reimplemented from BasicObject. Reimplemented in HttpTestCommandProcessor, and ProxyCommandProcessor. Definition at line 144 of file CommandProcessor.cpp. Referenced by ProxyCommandProcessor::toStream(), and HttpTestCommandProcessor::toStream().
|
|
Definition at line 35 of file CommandProcessor.h. |
|
Definition at line 34 of file CommandProcessor.h. |
|
Definition at line 33 of file CommandProcessor.h. |
|
Definition at line 32 of file CommandProcessor.h. |