- Remove old 10-engine system (engines/ directory deleted) - Implement C++ triple interface architecture: * IEngine: Execution coordination (Debug → Production) * IModuleSystem: Strategy pattern (Sequential → Threaded → Cluster) * IModule: Pure game logic interface (200-300 lines per module) * IIO: Communication transport (Intra → Local → Network) - Add autonomous module structure: * modules/factory/: Production logic with autonomous build * modules/economy/: Market simulation with autonomous build * modules/logistic/: Supply chain with autonomous build * Each module: CLAUDE.md + CMakeLists.txt + shared/ + build/ - Benefits for Claude Code development: * Ultra-focused contexts (200 lines vs 50K+ lines) * Autonomous builds (cmake . from module directory) * Hot-swappable infrastructure without logic changes * Parallel development across multiple Claude instances 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
91 lines
2.4 KiB
C++
91 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
#include <nlohmann/json.hpp>
|
|
#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<IIO> 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
|