#pragma once #include #include #include #include "IModule.h" #include "IIO.h" using json = nlohmann::json; namespace warfactory { /** * @brief Execution strategy interface - swappable performance * * SequentialModuleSystem -> One module at a time (debug) * ThreadedModuleSystem -> Each module in own thread * PoolModuleSystem -> Module tasks across thread pool * ClusterModuleSystem -> Modules across multiple machines */ class IModuleSystem { public: virtual ~IModuleSystem() = default; /** * @brief Initialize module system * @param config System configuration (thread count, etc.) */ virtual void initialize(const json& config) = 0; /** * @brief Load module from shared library * @param modulePath Path to .so/.dll file * @param moduleConfig Configuration for the module */ virtual void loadModule(const std::string& modulePath, const json& moduleConfig) = 0; /** * @brief Unload module * @param moduleName Name of module to unload */ virtual void unloadModule(const std::string& moduleName) = 0; /** * @brief Send message to specific module * @param targetModule Module name to send to * @param message JSON message to send */ virtual void sendToModule(const std::string& targetModule, const json& message) = 0; /** * @brief Broadcast message to all modules * @param message JSON message to broadcast */ virtual void broadcast(const json& message) = 0; /** * @brief Start execution loop * Will run until shutdown() called */ virtual void startLoop() = 0; /** * @brief Process one iteration (for step debugging) */ virtual void tick() = 0; /** * @brief Stop execution and cleanup */ virtual void shutdown() = 0; /** * @brief Set communication IO * @param io IO implementation to use */ virtual void setIO(std::shared_ptr io) = 0; /** * @brief Get list of loaded modules * @return JSON array of module metadata */ virtual json getLoadedModules() const = 0; /** * @brief Get execution strategy name */ virtual std::string getStrategyName() const = 0; }; } // namespace warfactory