Console Class Reference

#include <Console.h>

List of all members.

Public Member Functions

 Console (Server *server)
virtual ~Console ()
void startConsole (ConsoleData *data)
void setServer (Server *myServer)

Static Public Member Functions

int startThread (void *data)

Private Attributes

ConsoleData data
CommandManagercmdManager


Detailed Description

Manages console-like interaction: accepts admin commands and performs maintenance actions.

Todo:
Finish implementation.

TODO Error handling.

Definition at line 29 of file Console.h.


Constructor & Destructor Documentation

Console::Console Server server  ) 
 

Constructor.

Author:
stonedz
Since:
pre-alpha
Parameters:
server A Server pointer to bind the console to.

Definition at line 6 of file Console.cpp.

References cmdManager, data, and CommandManager::setServer().

00007         :cmdManager(CommandManager::getInstance())
00008 {
00009         this->data.self = this;
00010         this->data.running = true;
00011         this->data.banner = "\n:: Welcome to Last Online ::\n\npre-alpha version\nPlease refer to http://last-online.sourceforge.net for more informations.";
00012 
00013         this->data.myThread = SDL_CreateThread(this->startThread, &(this->data));
00014 
00015         this->cmdManager->setServer(server);    // Sets the Command Manager server.
00016 }

Console::~Console  )  [virtual]
 

Virtual destructor.

Author:
stonedz
Since:
pre-alpha

Definition at line 18 of file Console.cpp.

00019 {
00020 }


Member Function Documentation

void Console::setServer Server myServer  ) 
 

Sets the CommandManager's server.

Author:
stonedz
Since:
pre-alpha
Parameters:
myServer A valid Server pointer.
See also:
cmdManager
Todo:
TODO This is a bit tricky, we should change it.

Definition at line 41 of file Console.cpp.

References cmdManager, and CommandManager::setServer().

00041                                        {
00042         this->cmdManager->setServer(myServer); // Sets the CommandManager's Server.
00043 }

void Console::startConsole ConsoleData *  data  ) 
 

Starts the console.

Author:
stonedz
Since:
pre-alpha

Definition at line 29 of file Console.cpp.

References cmdManager, and CommandManager::processCommand().

00029                                             {
00030                 bool exit = false;
00031 
00032                 std::string selection;
00033                 std::cout << data->banner.c_str() << std::endl;
00034                 do{
00035                         std::cout << std::endl << "> ";
00036                         std::getline(std::cin, selection);
00037                         this->cmdManager->processCommand(selection);
00038                 }while(!exit);
00039 }

int Console::startThread void *  data  )  [static]
 

It's a wrapper to use SDL's threads.

This is because SDL_threads are written in pure C, and a function or a static method is needed in order to create a thread. It passes the control to the startListen method

Author:
stonedz
Since:
pre-alpha
See also:
startConsole
Returns:
The thread

Definition at line 22 of file Console.cpp.

00022                                    {
00023         ConsoleData * trueData =  reinterpret_cast<ConsoleData *>(data);
00024         trueData->self->startConsole(trueData);
00025 
00026         return 1;
00027 }


Member Data Documentation

CommandManager* Console::cmdManager [private]
 

Command manager.

Definition at line 85 of file Console.h.

Referenced by Console(), setServer(), and startConsole().

struct ConsoleData Console::data [private]
 

Contains console's data

Definition at line 84 of file Console.h.

Referenced by Console().


The documentation for this class was generated from the following files:
Generated on Mon Dec 3 04:30:13 2007 for lo-testserver by  doxygen 1.3.9.1