OrocosComponentLibrary  2.7.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
RealCommand Class Reference

Real command which can be executed. More...

#include <command.hpp>

Inheritance diagram for RealCommand:
Command

List of all members.

Public Member Functions

 RealCommand (std::string name, TcpReportingInterpreter *parent, unsigned int minargs=0, unsigned int maxargs=0, const char *syntax=0)
virtual bool correctSyntax (unsigned int argc, std::string *args)
 Return true if the syntax is correct, false otherwise.
const char * getSyntax () const
 Return syntax information.
virtual RealCommandgetRealCommand (const std::vector< Command * > &cmds) const
 Returns this.
void execute (int argc, std::string *args)
 Execute this command.
virtual bool is (std::string &cmd) const
bool operator== (const std::string &cmp) const
 Compare on name.
bool operator!= (const std::string &cmp) const
bool operator< (const Command &cmp) const
const std::string & getName () const
 Get the name of this command.

Static Public Member Functions

static Commandfind (const std::vector< Command * > &cmds, const std::string &cmp)
 Find the command with the given name in the vector.

Protected Member Functions

virtual void maincode (int argc, std::string *args)=0
 Main code to be implemented by children.
bool sendError102 () const
 Send the correct syntax to the client.
bool sendOK () const
 Send the message 101 OK to the client.
void toupper (std::string *args, int index) const
 Convert the parameter with the given index to upper-case.
void toupper (std::string *args, int start, int stop) const
 Convert all parameters between the start and stop index to upper-case.
Socketsocket () const
 Return the socket for this command.

Protected Attributes

TcpReportingInterpreter_parent
unsigned int _minargs
unsigned int _maxargs
const char * _syntax
std::string _name

Detailed Description

Real command which can be executed.

Definition at line 144 of file command.hpp.


Member Function Documentation

bool correctSyntax ( unsigned int  argc,
std::string *  args 
) [virtual]

Return true if the syntax is correct, false otherwise.

Send an error message to the client on incorrect syntax.

Definition at line 487 of file command.cpp.

References RealCommand::sendError102().

Referenced by RealCommand::execute().

bool sendError102 ( ) const [protected]

Send the correct syntax to the client.

Return false.

Definition at line 470 of file command.cpp.

References RealCommand::socket().

Referenced by RealCommand::correctSyntax().

bool sendOK ( ) const [protected]

Send the message 101 OK to the client.

Return true.

Definition at line 481 of file command.cpp.

References RealCommand::socket().

Socket & socket ( ) const [inline, protected]

Return the socket for this command.

Fast shortcut for _parent->getConnection()->getSocket()

Definition at line 522 of file command.cpp.

References TcpReportingInterpreter::getConnection(), and Datasender::getSocket().

Referenced by RealCommand::sendError102(), and RealCommand::sendOK().

void toupper ( std::string *  args,
int  index 
) const [protected]

Convert the parameter with the given index to upper-case.

The caller has to make sure that the given index is a valid index.

Definition at line 509 of file command.cpp.

Referenced by RealCommand::toupper().

void toupper ( std::string *  args,
int  start,
int  stop 
) const [protected]

Convert all parameters between the start and stop index to upper-case.

The caller has to make sure that both start and stop are valid indexes. stop must be strictly greater than start.

Definition at line 514 of file command.cpp.

References RealCommand::toupper().


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