From aa4970f4f41eff96e49f7e27f767bcec399332d0 Mon Sep 17 00:00:00 2001 From: Mathias Paulin <mathias.paulin@irit.fr> Date: Mon, 21 Feb 2022 09:07:40 +0100 Subject: [PATCH] [librender] Add stduuid dependency as submodule --- .gitmodules | 3 +++ src/libRender/CMakeLists.txt | 9 +++++++++ src/libRender/Config.cmake.in | 1 + src/libRender/Dependencies/stduuid | 1 + src/libRender/RadiumNBR/NodeGraph/Node.cpp | 6 ++++-- src/libRender/RadiumNBR/NodeGraph/Node.hpp | 5 ++++- 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 src/libRender/Dependencies/stduuid diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..675f50e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "stduuid"] + path = src/libRender/Dependencies/stduuid + url = git@github.com:MathiasPaulin/stduuid.git diff --git a/src/libRender/CMakeLists.txt b/src/libRender/CMakeLists.txt index 8a4f697..130fbe7 100644 --- a/src/libRender/CMakeLists.txt +++ b/src/libRender/CMakeLists.txt @@ -178,6 +178,14 @@ set(resources Resources/RadiumNBR/RenderGraphs/fullfeaturerenderer.flow ) +# std::uuid dependency +# Note, follow the progress of integration of uuid generator in the C++ std lib. When supported by std, remove this dependency +set(UUID_BUILD_TESTS OFF) +set(UUID_SYSTEM_GENERATOR ON) +set(UUID_USING_CXX20_SPAN OFF) # change this when going to C++20 as language standard for Radium libs +add_subdirectory(Dependencies/stduuid) +# TODO verify correct installation and usage in Config.cmake.in + # Our library project uses these sources and headers. add_library( @@ -200,6 +208,7 @@ target_link_libraries( PUBLIC Radium::Core Radium::Engine + stduuid ) if(CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/src/libRender/Config.cmake.in b/src/libRender/Config.cmake.in index f645bde..4ed6ecf 100644 --- a/src/libRender/Config.cmake.in +++ b/src/libRender/Config.cmake.in @@ -28,6 +28,7 @@ if ( NOT Radium_FOUND) endif() if (NBR_FOUND) + # TODO : search for installed stduuid include("${CMAKE_CURRENT_LIST_DIR}/NBRTargets.cmake" ) radium_exported_resources( TARGET RadiumNBR::NBR diff --git a/src/libRender/Dependencies/stduuid b/src/libRender/Dependencies/stduuid new file mode 160000 index 0000000..5c538cc --- /dev/null +++ b/src/libRender/Dependencies/stduuid @@ -0,0 +1 @@ +Subproject commit 5c538cca02932aa0266659661d5b4726f3a317c7 diff --git a/src/libRender/RadiumNBR/NodeGraph/Node.cpp b/src/libRender/RadiumNBR/NodeGraph/Node.cpp index 59d3352..44b1c5a 100644 --- a/src/libRender/RadiumNBR/NodeGraph/Node.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/Node.cpp @@ -15,7 +15,8 @@ void Node::fromJson( const nlohmann::json& data ) { #endif // get the common content of the Node from the json data - m_uuid = data["id"]; + std::string struuid = data["id"]; + m_uuid = uuids::uuid::from_string(struuid).value(); std::string readTypeName = data["model"]["name"]; if ( readTypeName != m_typeName ) { @@ -37,7 +38,8 @@ void Node::fromJson( const nlohmann::json& data ) { void Node::toJson( nlohmann::json& data ) const { // write the common content of the Node to the json data - data["id"] = m_uuid; + std::string struuid = "{" + uuids::to_string(m_uuid) + "}"; + data["id"] = struuid; nlohmann::json model; model["instance"] = m_instanceName; diff --git a/src/libRender/RadiumNBR/NodeGraph/Node.hpp b/src/libRender/RadiumNBR/NodeGraph/Node.hpp index aaa3c21..cd9ecc4 100644 --- a/src/libRender/RadiumNBR/NodeGraph/Node.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/Node.hpp @@ -5,6 +5,8 @@ #include <RadiumNBR/externals/json.hpp> +#include <uuid.h> + #include <cstdint> #include <iostream> #include <memory> @@ -194,7 +196,8 @@ class NodeBasedRenderer_LIBRARY_API Node /// The uuid of the node (TODO, use https://github.com/mariusbancila/stduuid instead of a /// string) - std::string m_uuid; + //std::string m_uuid; + uuids::uuid m_uuid; /// The type name of the node std::string m_typeName; /// The instance name of the node -- GitLab