GroveEngine/include/grove/DebugEngine.h
StillHammer e1cfa4513e Initial commit: Grove Engine core architecture
- Core interfaces for modular engine system
- Resource management and registry system
- Module system with sequential execution
- ImGui-based UI implementation
- Intra-process I/O communication
- Data tree structures for hierarchical data
- Serialization framework
- Task scheduler interface
- Debug engine implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 00:19:15 +08:00

89 lines
2.5 KiB
C++

#pragma once
#include <memory>
#include <string>
#include <vector>
#include <chrono>
#include <thread>
#include <atomic>
#include <spdlog/spdlog.h>
#include <nlohmann/json.hpp>
#include "IEngine.h"
#include "IModuleSystem.h"
#include "IIO.h"
using json = nlohmann::json;
namespace warfactory {
/**
* @brief Debug engine implementation with comprehensive logging
*
* DebugEngine provides maximum visibility into engine operations:
* - Verbose logging of all operations
* - Step-by-step execution capabilities
* - Module isolation and debugging
* - Performance metrics and timing
* - IIO health monitoring and reporting
* - Detailed socket management logging
*/
class DebugEngine : public IEngine {
private:
std::shared_ptr<spdlog::logger> logger;
std::atomic<bool> running{false};
std::atomic<bool> debugPaused{false};
// Module management
std::vector<std::unique_ptr<IModuleSystem>> moduleSystems;
std::vector<std::string> moduleNames;
// Socket management
std::unique_ptr<IIO> coordinatorSocket;
std::vector<std::unique_ptr<IIO>> clientSockets;
// Performance tracking
std::chrono::high_resolution_clock::time_point lastFrameTime;
std::chrono::high_resolution_clock::time_point engineStartTime;
size_t frameCount = 0;
// Configuration
json engineConfig;
// Helper methods
void logEngineStart();
void logEngineShutdown();
void logFrameStart(float deltaTime);
void logFrameEnd(float frameTime);
void logModuleHealth();
void logSocketHealth();
void processModuleSystems(float deltaTime);
void processClientMessages();
void processCoordinatorMessages();
float calculateDeltaTime();
void validateConfiguration();
public:
DebugEngine();
virtual ~DebugEngine();
// IEngine implementation
void initialize() override;
void run() override;
void step(float deltaTime) override;
void shutdown() override;
void loadModules(const std::string& configPath) override;
void registerMainSocket(std::unique_ptr<IIO> coordinatorSocket) override;
void registerNewClientSocket(std::unique_ptr<IIO> clientSocket) override;
EngineType getType() const override;
// Debug-specific methods
void pauseExecution();
void resumeExecution();
void stepSingleFrame();
bool isPaused() const;
json getDetailedStatus() const;
void setLogLevel(spdlog::level::level_enum level);
};
} // namespace warfactory