Leviathan  0.8.0.0
Leviathan game engine
Leviathan::CustomCommandHandler Class Referenceabstract

Implement this interface to be able to handle custom commands. More...

#include <CustomCommandHandler.h>

+ Inheritance diagram for Leviathan::CustomCommandHandler:

Public Member Functions

DLLEXPORT CustomCommandHandler ()
 
virtual DLLEXPORT ~CustomCommandHandler ()
 
virtual DLLEXPORT bool CanHandleCommand (const std::string &cmd) const =0
 Checks whether this handler can handle a command. More...
 
virtual DLLEXPORT void ExecuteCommand (const std::string &wholecommand, CommandSender *sender)=0
 Called by a worker thread that wants to execute a command. More...
 

Detailed Description

Implement this interface to be able to handle custom commands.

See also
CommandHandler CommandHandler::RegisterCustomCommandHandler
Todo:

Allow scripts to register these

Allow optional usage of an internal command table with descriptions etc.

Definition at line 14 of file CustomCommandHandler.h.

Constructor & Destructor Documentation

◆ CustomCommandHandler()

DLLEXPORT Leviathan::CustomCommandHandler::CustomCommandHandler ( )
inline

Definition at line 16 of file CustomCommandHandler.h.

16  {
17 
18  }

◆ ~CustomCommandHandler()

virtual DLLEXPORT Leviathan::CustomCommandHandler::~CustomCommandHandler ( )
inlinevirtual

Definition at line 19 of file CustomCommandHandler.h.

19  {
20 
21  }

Member Function Documentation

◆ CanHandleCommand()

virtual DLLEXPORT bool Leviathan::CustomCommandHandler::CanHandleCommand ( const std::string &  cmd) const
pure virtual

Checks whether this handler can handle a command.

Parameters
cmdWill be first word of the input without first preceding /, for example 'jump' or 'kickall'

Implemented in Pong::PongCommandHandler.

◆ ExecuteCommand()

virtual DLLEXPORT void Leviathan::CustomCommandHandler::ExecuteCommand ( const std::string &  wholecommand,
CommandSender sender 
)
pure virtual

Called by a worker thread that wants to execute a command.

Parameters
wholecommandWill contain exactly what the user passed in including the preceding /'s
senderThe CommandSender who executed this command, the pointer is safe to use during this call as it is locked during the call
Warning
This function can easily deadlock the engine if not used with care, expensive operations (or dangerous ones) should be queued as a task to avoid deadlocking

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