#pragma once #include #include #include using json = nlohmann::json; namespace warfactory { /** * @brief Input/Output interface - swappable transport * * IntraIO -> Same process (direct call) * LocalIO -> Same machine (named pipes/sockets) * NetworkIO -> Network/Internet (TCP/WebSocket) */ class IIO { public: virtual ~IIO() = default; /** * @brief Initialize IO with configuration * @param config Transport-specific configuration */ virtual void initialize(const json& config) = 0; /** * @brief Send JSON message * @param message JSON data to send * @param target Target identifier (module name, endpoint, etc.) */ virtual void send(const json& message, const std::string& target) = 0; /** * @brief Receive JSON message (blocking) * @return Received JSON message */ virtual json receive() = 0; /** * @brief Check if message available (non-blocking) * @return true if message ready to receive */ virtual bool hasMessage() const = 0; /** * @brief Set message handler for async operation * @param handler Function to call when message received */ virtual void setMessageHandler(std::function handler) = 0; /** * @brief Start async message processing */ virtual void startAsync() = 0; /** * @brief Stop async processing and cleanup */ virtual void shutdown() = 0; /** * @brief Get IO type identifier */ virtual std::string getType() const = 0; }; } // namespace warfactory