#pragma once #include #include #include namespace extra2d { /** * @brief Hello模块配置结构 */ struct HelloCfg { std::string greeting; int repeatCount; int priority; HelloCfg() : greeting("Hello, Extra2D!") , repeatCount(1) , priority(100) {} }; /** * @brief Hello模块示例 * 展示如何创建自定义模块 */ class HelloModule : public Module { public: /** * @brief 配置类型别名(向后兼容) */ using Cfg = HelloCfg; /** * @brief 构造函数 * @param cfg 配置 */ explicit HelloModule(const HelloCfg& cfg = HelloCfg{}); /** * @brief 构造函数(Lambda 配置) * @param configFn 配置函数 */ explicit HelloModule(std::function configFn); /** * @brief 析构函数 */ ~HelloModule() override; bool init() override; void shutdown() override; bool ok() const override { return initialized_; } const char* name() const override { return "hello"; } int priority() const override { return cfg_.priority; } /** * @brief 执行问候操作 */ void sayHello() const; private: HelloCfg cfg_; bool initialized_ = false; }; } // namespace extra2d