Beginning to create the placeholder classes
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
#include "account_manager.hpp"
|
||||||
|
|
||||||
|
AccountManager AccountManager::instance;
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef ACCOUNTMANAGER_HPP_
|
||||||
|
#define ACCOUNTMANAGER_HPP_
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class AccountManager {
|
||||||
|
private:
|
||||||
|
AccountManager() = default;
|
||||||
|
~AccountManager() = default;
|
||||||
|
static AccountManager instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static AccountManager* GetInstance() { return &instance; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct AccountEntry {
|
||||||
|
int index;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::list<AccountEntry> list;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,9 +6,10 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
//The abstract base class for all rooms
|
||||||
class BaseRoom {
|
class BaseRoom {
|
||||||
public:
|
public:
|
||||||
BaseRoom(std::map<std::string, std::string> args);
|
BaseRoom() = default;
|
||||||
~BaseRoom() = default;
|
~BaseRoom() = default;
|
||||||
|
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
@@ -21,13 +22,10 @@ public:
|
|||||||
MailBox* GetMailBox() { return& mailBox; }
|
MailBox* GetMailBox() { return& mailBox; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<std::string, std::string> const arguments;
|
|
||||||
MailBox mailBox;
|
MailBox mailBox;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool running = true;
|
bool running = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
int roomThread(void*);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#include "client_manager.hpp"
|
||||||
|
|
||||||
|
ClientManager ClientManager::instance;
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef CLIENTMANAGER_HPP_
|
||||||
|
#define CLIENTMANAGER_HPP_
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class ClientManager {
|
||||||
|
private:
|
||||||
|
ClientManager() = default;
|
||||||
|
~ClientManager() = default;
|
||||||
|
static ClientManager instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ClientManager* GetInstance() { return &instance; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct ClientEntry {
|
||||||
|
int index;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::list<ClientEntry> list;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
//Thread safe mailbox
|
//Thread safe messaging system
|
||||||
class MailBox {
|
class MailBox {
|
||||||
public:
|
public:
|
||||||
MailBox();
|
MailBox();
|
||||||
|
|||||||
+3
-4
@@ -12,10 +12,9 @@ int main(int, char**) {
|
|||||||
cout << "Beginning server" << endl;
|
cout << "Beginning server" << endl;
|
||||||
#endif
|
#endif
|
||||||
try {
|
try {
|
||||||
ServerApplication app;
|
ServerApplication::GetInstance()->Init();
|
||||||
app.Init();
|
ServerApplication::GetInstance()->Loop();
|
||||||
app.Loop();
|
ServerApplication::GetInstance()->Quit();
|
||||||
app.Quit();
|
|
||||||
}
|
}
|
||||||
catch(exception& e) {
|
catch(exception& e) {
|
||||||
cerr << "Fatal error: " << e.what() << endl;
|
cerr << "Fatal error: " << e.what() << endl;
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#include "player_manager.hpp"
|
||||||
|
|
||||||
|
PlayerManager PlayerManager::instance;
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef PLAYERMANAGER_HPP_
|
||||||
|
#define PLAYERMANAGER_HPP_
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class PlayerManager {
|
||||||
|
private:
|
||||||
|
PlayerManager() = default;
|
||||||
|
~PlayerManager() = default;
|
||||||
|
static PlayerManager instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static PlayerManager* GetInstance() { return &instance; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PlayerEntry {
|
||||||
|
int index;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::list<PlayerEntry> list;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,19 +1,11 @@
|
|||||||
#include "base_room.hpp"
|
#include "room_manager.hpp"
|
||||||
|
|
||||||
#include "SDL/SDL_thread.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
BaseRoom::BaseRoom(std::map<std::string, std::string> args):
|
RoomManager RoomManager::instance;
|
||||||
arguments(args)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
int roomThread(void* ptr) {
|
int roomThread(void* ptr) {
|
||||||
#ifdef DEBUG
|
|
||||||
std::cout << "Opening room" << std::endl;
|
std::cout << "Opening room" << std::endl;
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
reinterpret_cast<BaseRoom*>(ptr)->Init();
|
reinterpret_cast<BaseRoom*>(ptr)->Init();
|
||||||
reinterpret_cast<BaseRoom*>(ptr)->Loop();
|
reinterpret_cast<BaseRoom*>(ptr)->Loop();
|
||||||
@@ -23,8 +15,7 @@ int roomThread(void* ptr) {
|
|||||||
std::cerr << "Fatal room error: " << e.what() << std::endl;
|
std::cerr << "Fatal room error: " << e.what() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
std::cout << "Closing room" << std::endl;
|
std::cout << "Closing room" << std::endl;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef ROOMMANAGER_HPP_
|
||||||
|
#define ROOMMANAGER_HPP_
|
||||||
|
|
||||||
|
#include "base_room.hpp"
|
||||||
|
|
||||||
|
#include "SDL/SDL_thread.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class RoomManager {
|
||||||
|
private:
|
||||||
|
RoomManager() = default;
|
||||||
|
~RoomManager() = default;
|
||||||
|
static RoomManager instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static RoomManager* GetInstance() { return &instance; }
|
||||||
|
|
||||||
|
//open room
|
||||||
|
//close room
|
||||||
|
|
||||||
|
//get room
|
||||||
|
//set?
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct RoomHandle {
|
||||||
|
SDL_Thread* thread = nullptr;
|
||||||
|
BaseRoom* room = nullptr;
|
||||||
|
};
|
||||||
|
std::list<RoomHandle> rooms;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "server_application.hpp"
|
#include "server_application.hpp"
|
||||||
|
|
||||||
|
ServerApplication ServerApplication::instance;
|
||||||
|
|
||||||
ServerApplication::ServerApplication() {
|
ServerApplication::ServerApplication() {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
@@ -10,6 +12,10 @@ ServerApplication::~ServerApplication() {
|
|||||||
|
|
||||||
void ServerApplication::Init() {
|
void ServerApplication::Init() {
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
//Init SDL
|
||||||
|
//Init lua
|
||||||
|
//Init SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::Loop() {
|
void ServerApplication::Loop() {
|
||||||
@@ -19,11 +25,3 @@ void ServerApplication::Loop() {
|
|||||||
void ServerApplication::Quit() {
|
void ServerApplication::Quit() {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::OpenRoom(std::map<std::string, std::string> args) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerApplication::CloseRoom(RoomHandle roomHandle) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,36 +1,21 @@
|
|||||||
#ifndef SERVERAPPLICATION_HPP_
|
#ifndef SERVERAPPLICATION_HPP_
|
||||||
#define SERVERAPPLICATION_HPP_
|
#define SERVERAPPLICATION_HPP_
|
||||||
|
|
||||||
#include "base_room.hpp"
|
//The main application class
|
||||||
|
|
||||||
#include "SDL/SDL_thread.h"
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
struct RoomHandle {
|
|
||||||
SDL_Thread* thread = nullptr;
|
|
||||||
BaseRoom* room = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ServerApplication {
|
class ServerApplication {
|
||||||
public:
|
private:
|
||||||
ServerApplication();
|
ServerApplication();
|
||||||
~ServerApplication();
|
~ServerApplication();
|
||||||
|
static ServerApplication instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ServerApplication* GetInstance() { return &instance; }
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Loop();
|
void Loop();
|
||||||
void Quit();
|
void Quit();
|
||||||
|
|
||||||
bool SetRunning(bool b) { return running = b; }
|
|
||||||
bool GetRunning() const { return running; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OpenRoom(std::map<std::string, std::string>);
|
|
||||||
void CloseRoom(RoomHandle);
|
|
||||||
|
|
||||||
std::list<RoomHandle> rooms;
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user