refactor: Replace json with IDataNode in DebugEngine
**Changes:** - DebugEngine.h: Replace `json` with `std::unique_ptr<IDataNode>` - engineConfig: json → std::unique_ptr<IDataNode> - getDetailedStatus(): json → std::unique_ptr<IDataNode> - 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 <noreply@anthropic.com>
This commit is contained in:
parent
6b295e9b17
commit
62e174f43d
@ -7,13 +7,11 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include "IEngine.h"
|
#include "IEngine.h"
|
||||||
#include "IModuleSystem.h"
|
#include "IModuleSystem.h"
|
||||||
#include "IIO.h"
|
#include "IIO.h"
|
||||||
|
#include "IDataNode.h"
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
namespace grove {
|
namespace grove {
|
||||||
|
|
||||||
@ -48,7 +46,7 @@ private:
|
|||||||
size_t frameCount = 0;
|
size_t frameCount = 0;
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
json engineConfig;
|
std::unique_ptr<IDataNode> engineConfig;
|
||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
void logEngineStart();
|
void logEngineStart();
|
||||||
@ -82,7 +80,7 @@ public:
|
|||||||
void resumeExecution();
|
void resumeExecution();
|
||||||
void stepSingleFrame();
|
void stepSingleFrame();
|
||||||
bool isPaused() const;
|
bool isPaused() const;
|
||||||
json getDetailedStatus() const;
|
std::unique_ptr<IDataNode> getDetailedStatus() const;
|
||||||
void setLogLevel(spdlog::level::level_enum level);
|
void setLogLevel(spdlog::level::level_enum level);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
#include <grove/DebugEngine.h>
|
#include <grove/DebugEngine.h>
|
||||||
|
#include <grove/JsonDataNode.h>
|
||||||
|
#include <grove/JsonDataValue.h>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
@ -6,6 +9,8 @@
|
|||||||
|
|
||||||
namespace grove {
|
namespace grove {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
DebugEngine::DebugEngine() {
|
DebugEngine::DebugEngine() {
|
||||||
// Create comprehensive logger with multiple sinks
|
// Create comprehensive logger with multiple sinks
|
||||||
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
||||||
@ -294,7 +299,7 @@ bool DebugEngine::isPaused() const {
|
|||||||
return paused;
|
return paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
json DebugEngine::getDetailedStatus() const {
|
std::unique_ptr<IDataNode> DebugEngine::getDetailedStatus() const {
|
||||||
logger->debug("📊 Detailed status requested");
|
logger->debug("📊 Detailed status requested");
|
||||||
|
|
||||||
json status = {
|
json status = {
|
||||||
@ -315,8 +320,8 @@ json DebugEngine::getDetailedStatus() const {
|
|||||||
status["average_fps"] = frameCount / totalTime;
|
status["average_fps"] = frameCount / totalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->trace("📄 Status JSON: {}", status.dump());
|
logger->trace("📄 Status: {}", status.dump());
|
||||||
return status;
|
return std::make_unique<JsonDataNode>("status", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugEngine::setLogLevel(spdlog::level::level_enum level) {
|
void DebugEngine::setLogLevel(spdlog::level::level_enum level) {
|
||||||
@ -425,8 +430,9 @@ void DebugEngine::processClientMessages() {
|
|||||||
for (int j = 0; j < messagesToProcess; ++j) {
|
for (int j = 0; j < messagesToProcess; ++j) {
|
||||||
try {
|
try {
|
||||||
auto message = socket->pullMessage();
|
auto message = socket->pullMessage();
|
||||||
logger->debug("📩 Client {} message: topic='{}', data size={}",
|
std::string dataPreview = message.data ? message.data->getData()->toString() : "null";
|
||||||
i, message.topic, message.data.dump().size());
|
logger->debug("📩 Client {} message: topic='{}', data present={}",
|
||||||
|
i, message.topic, message.data != nullptr);
|
||||||
|
|
||||||
// TODO: Route message to appropriate module or process it
|
// TODO: Route message to appropriate module or process it
|
||||||
logger->trace("🚧 TODO: Route client message to modules");
|
logger->trace("🚧 TODO: Route client message to modules");
|
||||||
@ -451,8 +457,8 @@ void DebugEngine::processCoordinatorMessages() {
|
|||||||
for (int i = 0; i < messagesToProcess; ++i) {
|
for (int i = 0; i < messagesToProcess; ++i) {
|
||||||
try {
|
try {
|
||||||
auto message = coordinatorSocket->pullMessage();
|
auto message = coordinatorSocket->pullMessage();
|
||||||
logger->debug("📩 Coordinator message: topic='{}', data size={}",
|
logger->debug("📩 Coordinator message: topic='{}', data present={}",
|
||||||
message.topic, message.data.dump().size());
|
message.topic, message.data != nullptr);
|
||||||
|
|
||||||
// TODO: Handle coordinator commands (shutdown, config reload, etc.)
|
// TODO: Handle coordinator commands (shutdown, config reload, etc.)
|
||||||
logger->trace("🚧 TODO: Handle coordinator commands");
|
logger->trace("🚧 TODO: Handle coordinator commands");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user