mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
feat: Add Template Module
This commit is contained in:
1 parent
50eb73d4e8
commit
d87972242a
1 file changed
+58
@@ -0,0 +1,58 @@
|
||||
#include <modules/ModuleRegistry.hpp>
|
||||
#include <JuiceAgent/Logger.hpp>
|
||||
|
||||
namespace JuiceAgent::Core::Modules {
|
||||
|
||||
class TemplateModule : public IModule {
|
||||
public:
|
||||
std::string name() const override {
|
||||
return "Template";
|
||||
}
|
||||
|
||||
bool init() override {
|
||||
if (_initialized) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// load config / prepare resource
|
||||
|
||||
_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool start() override {
|
||||
if (!_initialized) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_running) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// start logic
|
||||
|
||||
_running = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
if (!_running) {
|
||||
return;
|
||||
}
|
||||
|
||||
// cleanup logic
|
||||
|
||||
_running = false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _initialized = false;
|
||||
bool _running = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
JUICEAGENT_REGISTER_MODULE(
|
||||
JuiceAgent::Core::Modules::TemplateModule,
|
||||
Template
|
||||
)
|
||||
Reference in new issue
Block a user