#include "hello_module.h"
#include <iostream>

namespace extra2d {

HelloModule::HelloModule(const HelloCfg& cfg) : cfg_(cfg) {}

HelloModule::HelloModule(std::function<void(HelloCfg&)> configFn) {
    configFn(cfg_);
}

HelloModule::~HelloModule() {
    if (initialized_) {
        shutdown();
    }
}

bool HelloModule::init() {
    if (initialized_) return true;
    
    std::cout << "HelloModule initialized" << std::endl;
    std::cout << "  Greeting: " << cfg_.greeting << std::endl;
    std::cout << "  Repeat count: " << cfg_.repeatCount << std::endl;
    
    initialized_ = true;
    return true;
}

void HelloModule::shutdown() {
    if (!initialized_) return;
    
    std::cout << "HelloModule shutdown" << std::endl;
    initialized_ = false;
}

void HelloModule::sayHello() const {
    for (int i = 0; i < cfg_.repeatCount; ++i) {
        std::cout << cfg_.greeting << std::endl;
    }
}

} // namespace extra2d
