core::Command Class Reference

`#include <Command.h>`

Inheritance diagram for core::Command:
[legend]
Collaboration diagram for core::Command:
[legend]

## Public Member Functions

virtual bool | check (std::string request)
virtual int | processCommand (std::string request, TCPSession *session, std::stringstream &data)
virtual void | output (Session *session)
void | setName (std::string name)
std::string | getName ()

## Additional Inherited Members

Public Attributes inherited from core::Object
std::string | name
std::string | tag

## Detailed Description

Command

Use the Command object in combination with a CommandList object to maintain a list of functions that can be invoked as a result of processing a request.

## Member Function Documentation

## check()

bool core::Command::check | ( | std::string | request | ) |

virtual

Implement check method to provide a special check rule upon the request to see if the command should be processed.

The default rule is to verify that the first token in the request string matches the name given on the registration of the command to the CommandList. This can be overridden by implementing the check() method to perform the test and return the condition of the command.

Parameters

  request | The request passed to the parser to check the rule.

Returns
  Return true to execute the command. Returning false will cause no action on this command.

## getName()

std::string core::Command::getName | ( |  | ) |

## output()

void core::Command::output | ( | Session * | session | ) |

virtual

Specify the output that will occur to the specified session.

Parameters

  session | The session that will receive the output.

## processCommand()

int core::Command::processCommand | ( | std::string | request,
|  | TCPSession * | session,
|  | std::stringstream & | data
| ) |  |

virtual

This method is used to implement the functionality of the requested command. This pure virtual function must be implemented in your inheriting object.

Parameters

  request | The request that was entered by the user to invoke this command.
  session | Specify the requesting session so that the execution of the command process can return its output to the session.

Returns
  Returns 0 if execution of the command was successful. Otherwise returns a non-zero value indicating an error condition.

Reimplemented in core::CommandList, core::EPoll, and core::TCPServer.

## setName()

void core::Command::setName | ( | std::string | name | ) |

Set the name of this command used in default rule checking during request parsing. NOTE: You do not need to call this under normal conditions as adding a Command to a CommandList using the add() method contains a parameter to pass the name of the Command.

Parameters

  name | Specify the name of this command for default parsing.

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

- Command.h
- Command.cpp