add StateMachine

This commit is contained in:
2025-08-09 11:23:17 +02:00
parent ac3e949323
commit cba790f804
23 changed files with 174 additions and 244 deletions

View File

@@ -1,30 +1,21 @@
#pragma once
#include <memory>
#include <server/IServerSocket.h>
#include <server/IServerState.h>
#include <chrono>
#include <td/common/StateMachine.h>
namespace td {
namespace server {
class Server {
class ServerState;
class Server : public StateMachine<Server, void, float> {
private:
std::shared_ptr<IServerSocket> m_Socket;
std::shared_ptr<IServerState> m_State;
std::chrono::time_point<std::chrono::system_clock> m_LastTime;
public:
Server(const std::shared_ptr<IServerSocket>& a_Socket) : m_Socket(a_Socket), m_LastTime(std::chrono::system_clock::now()) {}
Server(const std::shared_ptr<IServerSocket>& a_Socket) : m_Socket(a_Socket) {}
void Update();
void UpdateState(const std::shared_ptr<IServerState>& a_State);
private:
void Update(float a_Delta);
friend class IServerState;
friend class ServerState;
};
} // namespace server