SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CommandParserInterface.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20
21 #ifndef __COMMAND_PARSER_INTERFACE
22 #define __COMMAND_PARSER_INTERFACE
23
24 #include "memoryoverride.h"
25 #include "types.h"
26 #include "DS_OrderedList.h"
27 #include "Export.h"
28
29 namespace SLNet
30 {
32 class TransportInterface;
33
37 struct RAK_DLL_EXPORT RegisteredCommand
38 {
39 const char *command;
40 const char *commandHelp;
41 unsigned char parameterCount;
42 };
43
45 int RAK_DLL_EXPORT RegisteredCommandComp( const char* const & key, const RegisteredCommand &data );
46
50 class RAK_DLL_EXPORT CommandParserInterface
51 {
52 public:
53 CommandParserInterface();
54 virtual ~CommandParserInterface();
55
59 virtual const char *GetName(void) const=0;
60
64 virtual void OnNewIncomingConnection(const SystemAddress &systemAddress, TransportInterface *transport);
65
69 virtual void OnConnectionLost(const SystemAddress &systemAddress, TransportInterface *transport);
70
74 virtual void SendHelp(TransportInterface *transport, const SystemAddress &systemAddress)=0;
75
83 virtual bool OnCommand(const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, const SystemAddress &systemAddress, const char *originalString)=0;
84
89 virtual void OnTransportChange(TransportInterface *transport);
90
96 virtual bool GetRegisteredCommand(const char *command, RegisteredCommand *rc);
97
106 static void ParseConsoleString(char *str, const char delineator, unsigned char delineatorToggle, unsigned *numParameters, char **parameterList, unsigned parameterListLength);
107
112 virtual void SendCommandList(TransportInterface *transport, const SystemAddress &systemAddress);
113
114 static const unsigned char VARIABLE_NUMBER_OF_PARAMETERS;
115
116 // Currently only takes static strings - doesn't make a copy of what you pass.
117 // parameterCount is the number of parameters that the sender has to include with the command.
118 // Pass 255 to parameterCount to indicate variable number of parameters
119
124 virtual void RegisterCommand(unsigned char parameterCount, const char *command, const char *commandHelp);
125
132 virtual void ReturnResult(bool res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress);
133 virtual void ReturnResult(char *res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress);
134 virtual void ReturnResult(SystemAddress res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress);
135 virtual void ReturnResult(int res, const char *command,TransportInterface *transport, const SystemAddress &systemAddress);
136
143 virtual void ReturnResult(const char *command,TransportInterface *transport, const SystemAddress &systemAddress);
144
145 protected:
146 DataStructures::OrderedList<const char*, RegisteredCommand, RegisteredCommandComp> commandList;
147 };
148
149 } // namespace SLNet
150
151 #endif
152