From 62e174f43d6b0a168b97d7a2d346c2f38b4ac6dc Mon Sep 17 00:00:00 2001 From: StillHammer Date: Tue, 28 Oct 2025 17:01:19 +0800 Subject: [PATCH] refactor: Replace json with IDataNode in DebugEngine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Changes:** - DebugEngine.h: Replace `json` with `std::unique_ptr` - engineConfig: json → std::unique_ptr - getDetailedStatus(): json → std::unique_ptr - DebugEngine.cpp: Update implementations - Include JsonDataNode/JsonDataValue headers - getDetailedStatus() returns JsonDataNode wrapper - Message logging adapted for IDataNode (check nullptr instead of dump()) - Keep json internally for convenience (converted to IDataNode when needed) **Architecture:** - Engine uses IDataNode abstraction for external interfaces - Internal JSON usage preserved for convenience - Compatible with new IDataTree system 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- include/grove/DebugEngine.h | 8 +++----- src/DebugEngine.cpp | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/grove/DebugEngine.h b/include/grove/DebugEngine.h index 1df257d..a11cb2d 100644 --- a/include/grove/DebugEngine.h +++ b/include/grove/DebugEngine.h @@ -7,13 +7,11 @@ #include #include #include -#include #include "IEngine.h" #include "IModuleSystem.h" #include "IIO.h" - -using json = nlohmann::json; +#include "IDataNode.h" namespace grove { @@ -48,7 +46,7 @@ private: size_t frameCount = 0; // Configuration - json engineConfig; + std::unique_ptr engineConfig; // Helper methods void logEngineStart(); @@ -82,7 +80,7 @@ public: void resumeExecution(); void stepSingleFrame(); bool isPaused() const; - json getDetailedStatus() const; + std::unique_ptr getDetailedStatus() const; void setLogLevel(spdlog::level::level_enum level); }; diff --git a/src/DebugEngine.cpp b/src/DebugEngine.cpp index b213b73..abf10d4 100644 --- a/src/DebugEngine.cpp +++ b/src/DebugEngine.cpp @@ -1,4 +1,7 @@ #include +#include +#include +#include #include #include #include @@ -6,6 +9,8 @@ namespace grove { +using json = nlohmann::json; + DebugEngine::DebugEngine() { // Create comprehensive logger with multiple sinks auto console_sink = std::make_shared(); @@ -294,7 +299,7 @@ bool DebugEngine::isPaused() const { return paused; } -json DebugEngine::getDetailedStatus() const { +std::unique_ptr DebugEngine::getDetailedStatus() const { logger->debug("📊 Detailed status requested"); json status = { @@ -315,8 +320,8 @@ json DebugEngine::getDetailedStatus() const { status["average_fps"] = frameCount / totalTime; } - logger->trace("📄 Status JSON: {}", status.dump()); - return status; + logger->trace("📄 Status: {}", status.dump()); + return std::make_unique("status", status); } void DebugEngine::setLogLevel(spdlog::level::level_enum level) { @@ -425,8 +430,9 @@ void DebugEngine::processClientMessages() { for (int j = 0; j < messagesToProcess; ++j) { try { auto message = socket->pullMessage(); - logger->debug("📩 Client {} message: topic='{}', data size={}", - i, message.topic, message.data.dump().size()); + std::string dataPreview = message.data ? message.data->getData()->toString() : "null"; + logger->debug("📩 Client {} message: topic='{}', data present={}", + i, message.topic, message.data != nullptr); // TODO: Route message to appropriate module or process it logger->trace("🚧 TODO: Route client message to modules"); @@ -451,8 +457,8 @@ void DebugEngine::processCoordinatorMessages() { for (int i = 0; i < messagesToProcess; ++i) { try { auto message = coordinatorSocket->pullMessage(); - logger->debug("📩 Coordinator message: topic='{}', data size={}", - message.topic, message.data.dump().size()); + logger->debug("📩 Coordinator message: topic='{}', data present={}", + message.topic, message.data != nullptr); // TODO: Handle coordinator commands (shutdown, config reload, etc.) logger->trace("🚧 TODO: Handle coordinator commands");