Implemented ManagerInterface in AccountManager and CharacterManager
ManagerInterface was already designed for those two anyway. The only thing left to do is to rewrite the room API, and the whole thing should work fine again. I still think map data should be saved and loaded by lua code, so the rooms will still implement lua hooks. There may be other things that can be loaded from SQL, but I don't know what.
This commit is contained in:
@@ -24,29 +24,33 @@
|
||||
|
||||
#include "character_data.hpp"
|
||||
#include "singleton.hpp"
|
||||
#include "manager_interface.hpp"
|
||||
|
||||
#include "sqlite3/sqlite3.h"
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
||||
class CharacterManager : public Singleton<CharacterManager> {
|
||||
class CharacterManager:
|
||||
public Singleton<CharacterManager>,
|
||||
public ManagerInterface<CharacterData, int, std::string, std::string>
|
||||
{
|
||||
public:
|
||||
//public access methods
|
||||
int Create(int owner, std::string handle, std::string avatar);
|
||||
int Load(int owner, std::string handle, std::string avatar);
|
||||
int Save(int uid);
|
||||
void Unload(int uid);
|
||||
void Delete(int uid);
|
||||
//common public methods
|
||||
int Create(int owner, std::string handle, std::string avatar) override;
|
||||
int Load(int owner, std::string handle, std::string avatar) override;
|
||||
int Save(int uid) override;
|
||||
void Unload(int uid) override;
|
||||
void Delete(int uid) override;
|
||||
|
||||
void UnloadAll();
|
||||
void UnloadIf(std::function<bool(std::pair<int, CharacterData>)> fn);
|
||||
void UnloadAll() override;
|
||||
void UnloadIf(std::function<bool(std::pair<const int, CharacterData>)> fn) override;
|
||||
|
||||
//accessors and mutators
|
||||
CharacterData* Get(int uid);
|
||||
int GetLoadedCount();
|
||||
int GetTotalCount();
|
||||
std::map<int, CharacterData>* GetContainer();
|
||||
CharacterData* Get(int uid) override;
|
||||
int GetLoadedCount() override;
|
||||
int GetTotalCount() override;
|
||||
std::map<int, CharacterData>* GetContainer() override;
|
||||
|
||||
sqlite3* SetDatabase(sqlite3* db);
|
||||
sqlite3* GetDatabase();
|
||||
@@ -57,7 +61,6 @@ private:
|
||||
CharacterManager() = default;
|
||||
~CharacterManager() = default;
|
||||
|
||||
std::map<int, CharacterData> characterMap;
|
||||
sqlite3* database = nullptr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user