GroveEngine/CMakeLists.txt
StillHammer fad105afb2 feat: Implement complete IDataNode/IDataTree system with JSON backend
Major feature: Unified config/data/runtime tree system

**New System Architecture:**
- Unified data tree for config, persistent data, and runtime state
- Three separate roots: config/ (read-only + hot-reload), data/ (read-write + save), runtime/ (temporary)
- Support for modding, saves, and hot-reload in single system

**Interfaces:**
- IDataValue: Abstract data value interface (type-safe access)
- IDataNode: Tree node with navigation, search, and modification
- IDataTree: Root container with config/data/runtime management

**Concrete Implementations:**
- JsonDataValue: nlohmann::json backed value
- JsonDataNode: Full tree navigation with pattern matching & queries
- JsonDataTree: File-based JSON storage with hot-reload

**Features:**
- Pattern matching search (wildcards support)
- Property-based queries with predicates
- SHA256 hashing for validation/sync
- Hot-reload for config/ directory
- Save operations for data/ persistence
- Read-only enforcement for config/

**API Changes:**
- All namespaces changed from 'warfactory' to 'grove'
- IDataTree: Added getConfigRoot(), getDataRoot(), getRuntimeRoot()
- IDataTree: Added saveData(), saveNode() for persistence
- IDataNode: Added setChild(), removeChild(), clearChildren()
- CMakeLists.txt: Added OpenSSL dependency for hashing

**Usage:**
```cpp
auto tree = DataTreeFactory::create("json", "./gamedata");
auto config = tree->getConfigRoot();     // Read-only game config
auto data = tree->getDataRoot();         // Player saves
auto runtime = tree->getRuntimeRoot();   // Temporary state

// Hot-reload config on file changes
if (tree->reloadIfChanged()) { /* refresh modules */ }

// Save player progress
data->setChild("progress", progressNode);
tree->saveData();
```

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

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

75 lines
1.8 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(GroveEngine VERSION 1.0.0 LANGUAGES CXX)
# C++ Standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Dependencies
include(FetchContent)
# nlohmann_json for JSON handling
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
FetchContent_MakeAvailable(nlohmann_json)
# Core library (INTERFACE - header-only pour les interfaces)
add_library(grove_core INTERFACE)
target_include_directories(grove_core INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(grove_core INTERFACE
nlohmann_json::nlohmann_json
)
# Alias for consistent naming
add_library(GroveEngine::core ALIAS grove_core)
# Optional: Build implementations
option(GROVE_BUILD_IMPLEMENTATIONS "Build GroveEngine implementations" ON)
if(GROVE_BUILD_IMPLEMENTATIONS)
add_library(grove_impl STATIC
src/ImGuiUI.cpp
src/ResourceRegistry.cpp
src/JsonDataValue.cpp
src/JsonDataNode.cpp
src/JsonDataTree.cpp
src/DataTreeFactory.cpp
)
target_link_libraries(grove_impl PUBLIC
GroveEngine::core
OpenSSL::Crypto
)
# Find OpenSSL for SHA256 hashing
find_package(OpenSSL REQUIRED)
# If imgui is available from parent project, link it
if(TARGET imgui_backends)
target_link_libraries(grove_impl PUBLIC imgui_backends)
endif()
add_library(GroveEngine::impl ALIAS grove_impl)
endif()
# Testing
option(GROVE_BUILD_TESTS "Build GroveEngine tests" OFF)
if(GROVE_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# Installation
install(DIRECTORY include/grove
DESTINATION include
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)