1
0
Files
BasaltMeter/BasaltPresenter/Shared/basalt/engine.cpp

35 lines
976 B
C++
Raw Normal View History

2026-01-08 19:23:19 +08:00
#include "engine.hpp"
#include <stdexcept>
namespace basalt::shared::engine {
IEngine::IEngine() : config(), status(EngineStatus::Ready) {}
IEngine::~IEngine() {
if (this->status != EngineStatus::Stop) {
2026-01-08 19:37:25 +08:00
this->shutdown();
2026-01-08 19:23:19 +08:00
}
}
2026-01-08 19:37:25 +08:00
guid::Guid IEngine::get_guid() const {
2026-01-08 19:23:19 +08:00
throw std::logic_error("unimplemented function");
}
2026-01-08 19:37:25 +08:00
void IEngine::startup(EngineConfig &&config) {
2026-01-08 19:23:19 +08:00
if (this->status != EngineStatus::Ready) throw std::runtime_error("unexpected engine status");
this->config = std::move(config);
this->status = EngineStatus::Running;
}
2026-01-08 19:37:25 +08:00
bool IEngine::tick() {
2026-01-08 19:23:19 +08:00
if (this->status != EngineStatus::Running) throw std::runtime_error("unexpected engine status");
return false;
}
2026-01-08 19:37:25 +08:00
void IEngine::shutdown() {
2026-01-08 19:23:19 +08:00
if (this->status != EngineStatus::Running) throw std::runtime_error("unexpected engine status");
this->status = EngineStatus::Stop;
}
}