Planeshift
cmdbase.h
Go to the documentation of this file.
1
/*
2
* cmdbase.h - Author: Keith Fulton
3
*
4
* Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5
*
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation (version 2 of the License)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*
18
*/
19
25
#ifndef __CMDBASE_H__
26
#define __CMDBASE_H__
27
28
#include "
net/subscriber.h
"
29
#include "
net/messages.h
"
30
#include <iutil/objreg.h>
31
32
#include <ivaria/reporter.h>
33
34
class
CmdHandler
;
// needed for circular includes
35
class
ClientMsgHandler
;
36
class
Client
;
// dummy blind definition. Only used on server.
37
42
class
psCmdBase
:
public
iNetSubscriber
,
public
iCmdSubscriber
43
{
44
protected
:
45
ClientMsgHandler
*
msgqueue
;
46
CmdHandler
*
cmdsource
;
47
iObjectRegistry *
objreg
;
48
49
public
:
50
psCmdBase
(
ClientMsgHandler
*mh,
CmdHandler
*ch, iObjectRegistry* obj);
51
52
virtual
~psCmdBase
() {}
53
virtual
bool
Setup
(
ClientMsgHandler
* mh,
CmdHandler
* ch);
54
55
// iCmdSubscriber interface
56
virtual
const
char
*
HandleCommand
(
const
char
*cmd) = 0;
57
58
// iNetSubscriber interface
59
virtual
void
HandleMessage
(
MsgEntry
*msg,
Client
*) {
HandleMessage
(msg); }
60
virtual
void
HandleMessage
(
MsgEntry
*msg) = 0;
61
virtual
bool
Verify
(
MsgEntry
*,
unsigned
int
,
Client
*& ) {
return
true
; }
62
63
// Wrapper for csReport
64
void
Report
(
int
severity,
const
char
*
msgtype
,
const
char
* description, ... );
65
};
66
67
class
psClientNetSubscriber
:
public
iNetSubscriber
68
{
69
public
:
70
virtual
~psClientNetSubscriber
() {}
71
72
// iNetSubscriber interface
73
virtual
void
HandleMessage
(
MsgEntry
*msg,
Client
*) {
HandleMessage
(msg); }
74
virtual
void
HandleMessage
(
MsgEntry
*msg) = 0;
75
virtual
bool
Verify
(
MsgEntry
*,
unsigned
int
,
Client
*& ) {
return
true
; }
76
77
};
78
81
#endif
82
iCmdSubscriber
This interface must be implemented by objects that want to receive command line strings messages...
Definition:
subscriber.h:52
messages.h
psCmdBase::HandleMessage
virtual void HandleMessage(MsgEntry *msg, Client *)
Interprets a received message and executes the command.
Definition:
cmdbase.h:59
subscriber.h
CmdHandler
Definition:
cmdhandler.h:54
psCmdBase::~psCmdBase
virtual ~psCmdBase()
Definition:
cmdbase.h:52
psCmdBase::Verify
virtual bool Verify(MsgEntry *, unsigned int, Client *&)
Definition:
cmdbase.h:61
MsgEntry
The structure of 1 queue entry (pointer to a message)
Definition:
message.h:143
ClientMsgHandler
Handles messages to be sent out, connects to server and send those.
Definition:
clientmsghandler.h:38
psCmdBase::Report
void Report(int severity, const char *msgtype, const char *description,...)
iNetSubscriber
This interface must be implemented by objects that want to receive network messages.
Definition:
subscriber.h:37
psCmdBase::psCmdBase
psCmdBase(ClientMsgHandler *mh, CmdHandler *ch, iObjectRegistry *obj)
psClientNetSubscriber::Verify
virtual bool Verify(MsgEntry *, unsigned int, Client *&)
Definition:
cmdbase.h:75
psCmdBase::msgqueue
ClientMsgHandler * msgqueue
Definition:
cmdbase.h:45
Client
This class collects data of a netclient.
Definition:
client.h:95
psCmdBase::objreg
iObjectRegistry * objreg
Definition:
cmdbase.h:47
msgtype
uint8_t msgtype
Definition:
message.h:56
psClientNetSubscriber::~psClientNetSubscriber
virtual ~psClientNetSubscriber()
Definition:
cmdbase.h:70
psCmdBase::HandleCommand
virtual const char * HandleCommand(const char *cmd)=0
Interprets a received message and executes the command.
psCmdBase::cmdsource
CmdHandler * cmdsource
Definition:
cmdbase.h:46
psCmdBase
Definition:
cmdbase.h:42
psClientNetSubscriber
Definition:
cmdbase.h:67
psClientNetSubscriber::HandleMessage
virtual void HandleMessage(MsgEntry *msg, Client *)
Interprets a received message and executes the command.
Definition:
cmdbase.h:73
psCmdBase::Setup
virtual bool Setup(ClientMsgHandler *mh, CmdHandler *ch)
common
net
cmdbase.h
Generated on Sat Jun 19 2021 05:00:23 for Planeshift by
1.8.11