Shadowrun: Awakened 29 September 2011 - Build 871
CommandParserInterface.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #ifndef __COMMAND_PARSER_INTERFACE
00010 #define __COMMAND_PARSER_INTERFACE
00011 
00012 #include "RakMemoryOverride.h"
00013 #include "RakNetTypes.h"
00014 #include "DS_OrderedList.h"
00015 #include "Export.h"
00016 
00017 namespace RakNet
00018 {
00020 class TransportInterface;
00021 
00025 struct RAK_DLL_EXPORT RegisteredCommand
00026 {
00027     const char *command;
00028     const char *commandHelp;
00029     unsigned char parameterCount;
00030 };
00031 
00033 int RAK_DLL_EXPORT RegisteredCommandComp( const char* const & key, const RegisteredCommand &data );
00034 
00038 class RAK_DLL_EXPORT CommandParserInterface
00039 {
00040 public:
00041     CommandParserInterface();
00042     virtual ~CommandParserInterface();
00043 
00047     virtual const char *GetName(void) const=0;
00048 
00052     virtual void  OnNewIncomingConnection(const SystemAddress &systemAddress, TransportInterface *transport);
00053 
00057     virtual void OnConnectionLost(const SystemAddress &systemAddress, TransportInterface *transport);
00058 
00062     virtual void SendHelp(TransportInterface *transport, const SystemAddress &systemAddress)=0;
00063 
00071     virtual bool OnCommand(const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, const SystemAddress &systemAddress, const char *originalString)=0;
00072 
00077     virtual void OnTransportChange(TransportInterface *transport);
00078 
00084     virtual bool GetRegisteredCommand(const char *command, RegisteredCommand *rc);
00085 
00094     static void ParseConsoleString(char *str, const char delineator, unsigned char delineatorToggle, unsigned *numParameters, char **parameterList, unsigned parameterListLength);
00095 
00100     virtual void SendCommandList(TransportInterface *transport, const SystemAddress &systemAddress);
00101 
00102     static const unsigned char VARIABLE_NUMBER_OF_PARAMETERS;
00103 
00104     // Currently only takes static strings - doesn't make a copy of what you pass.
00105     // parameterCount is the number of parameters that the sender has to include with the command.
00106     // Pass 255 to parameterCount to indicate variable number of parameters
00107 
00112     virtual void RegisterCommand(unsigned char parameterCount, const char *command, const char *commandHelp);
00113 
00120     virtual void ReturnResult(bool res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress);
00121     virtual void ReturnResult(char *res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress);
00122     virtual void ReturnResult(SystemAddress res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress);
00123     virtual void ReturnResult(int res, const char *command,TransportInterface *transport, const SystemAddress &systemAddress);
00124 
00131     virtual void ReturnResult(const char *command,TransportInterface *transport, const SystemAddress &systemAddress);
00132 
00133 protected:
00134     DataStructures::OrderedList<const char*, RegisteredCommand, RegisteredCommandComp> commandList;
00135 };
00136 
00137 } // namespace RakNet
00138 
00139 #endif
00140 

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net