-
Notifications
You must be signed in to change notification settings - Fork 0
/
BattleGameServer.h
50 lines (37 loc) · 1.84 KB
/
BattleGameServer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Created by floweryclover on 2024-01-31.
//
#ifndef BATTLEGAME_SERVER_BATTLEGAMESERVER_H
#define BATTLEGAME_SERVER_BATTLEGAMESERVER_H
#include <memory>
class ClientManager;
class GameData;
class StcRpc;
class CtsRpc;
class BattleGameServer {
public:
BattleGameServer(const BattleGameServer&) = delete;
BattleGameServer(BattleGameServer&&) = delete;
BattleGameServer& operator=(BattleGameServer&&) = delete;
~BattleGameServer() = default;
inline static BattleGameServer& GetInstance() noexcept { return const_cast<BattleGameServer&>(GetConstInstance()); };
inline static const BattleGameServer& GetConstInstance() noexcept { return *spSingleton; };
static void Initialize(const char* listenAddress, unsigned short listenPort) noexcept;
inline ClientManager& GetClientManager() noexcept { return const_cast<ClientManager&>(GetConstClientManager()); }
inline const ClientManager& GetConstClientManager() const noexcept { return *this->mpClientManager; }
inline GameData& GetGameData() noexcept { return const_cast<GameData&>(GetConstGameData()); }
inline const GameData& GetConstGameData() const noexcept { return *this->mpGameData; }
inline StcRpc& GetStcRpc() noexcept { return const_cast<StcRpc&>(GetConstStcRpc()); }
inline const StcRpc& GetConstStcRpc() const noexcept { return *this->mpStcRpc; }
inline CtsRpc& GetCtsRpc() noexcept { return const_cast<CtsRpc&>(GetConstCtsRpc()); }
inline const CtsRpc& GetConstCtsRpc() const noexcept { return *this->mpCtsRpc; }
void InvokeTick();
private:
BattleGameServer() = default;
static std::unique_ptr<BattleGameServer> spSingleton;
std::unique_ptr<ClientManager> mpClientManager;
std::unique_ptr<GameData> mpGameData;
std::unique_ptr<StcRpc> mpStcRpc;
std::unique_ptr<CtsRpc> mpCtsRpc;
};
#endif //BATTLEGAME_SERVER_BATTLEGAMESERVER_H