Extra2D/include/context/context.h

100 lines
1.9 KiB
C
Raw Normal View History

#pragma once
#include <types/base/types.h>
#include <memory>
namespace extra2d {
// 前向声明
class ModuleRegistry;
class PluginLoader;
class TimerModule;
/**
* @brief
*
*
*
*/
class Context {
public:
Context();
~Context();
// 禁止拷贝
Context(const Context&) = delete;
Context& operator=(const Context&) = delete;
// 允许移动
Context(Context&&) noexcept;
Context& operator=(Context&&) noexcept;
/**
* @brief
*/
static std::unique_ptr<Context> create();
/**
* @brief
* @return
*/
bool init();
/**
* @brief
*/
void shutdown();
/**
* @brief
* @param dt
*/
void tick(float dt);
/**
* @brief
*/
ModuleRegistry& modules();
/**
* @brief
*/
PluginLoader& plugins();
/**
* @brief
*/
TimerModule& timer();
/**
* @brief
*/
float totalTime() const { return totalTime_; }
/**
* @brief
*/
uint64 frameCount() const { return frameCount_; }
/**
* @brief
*/
bool isRunning() const { return running_; }
/**
* @brief
*/
void stop() { running_ = false; }
private:
std::unique_ptr<PluginLoader> pluginLoader_;
std::unique_ptr<TimerModule> timerModule_;
float totalTime_ = 0.0f;
uint64 frameCount_ = 0;
bool running_ = false;
bool inited_ = false;
};
} // namespace extra2d