From 9e90ba4abb7c9ba843fb0c9a6f1fd5e5eaf5c8bb Mon Sep 17 00:00:00 2001 From: Dominik Drexler Date: Sun, 25 Aug 2024 12:03:20 +0200 Subject: [PATCH] added basic version of v2 which will be a templated wrapper around flexbuffer --- dependencies/CMakeLists.txt | 1 + dependencies/flatbuffers/CMakeLists.txt | 21 +++++++ include/flatmemory/details/types/vector2.hpp | 60 ++++++++++++++++++++ src/CMakeLists.txt | 7 +++ 4 files changed, 89 insertions(+) create mode 100644 dependencies/flatbuffers/CMakeLists.txt create mode 100644 include/flatmemory/details/types/vector2.hpp diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 2694af9..10e0d8c 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -4,3 +4,4 @@ project(dependencies) add_subdirectory(benchmark) add_subdirectory(googletest) +add_subdirectory(flatbuffers) \ No newline at end of file diff --git a/dependencies/flatbuffers/CMakeLists.txt b/dependencies/flatbuffers/CMakeLists.txt new file mode 100644 index 0000000..d541298 --- /dev/null +++ b/dependencies/flatbuffers/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.21) +project(InstallFlatbuffers) + +include(ExternalProject) + +list(APPEND CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} +) + +message(STATUS "Preparing external project \"flatbuffers\" with args:") +foreach(CMAKE_ARG ${CMAKE_ARGS}) + message(STATUS "-- ${CMAKE_ARG}") +endforeach() + +ExternalProject_Add( + flatbuffers + GIT_REPOSITORY git@github.com:google/flatbuffers.git + GIT_TAG master + PREFIX ${CMAKE_BINARY_DIR}/flatbuffers + CMAKE_ARGS ${CMAKE_ARGS} +) diff --git a/include/flatmemory/details/types/vector2.hpp b/include/flatmemory/details/types/vector2.hpp new file mode 100644 index 0000000..d0c7c1d --- /dev/null +++ b/include/flatmemory/details/types/vector2.hpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2024 Dominik Drexler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef FLATMEMORY_TYPES_VECTOR2_HPP_ +#define FLATMEMORY_TYPES_VECTOR2_HPP_ + +#include "flatmemory/details/algorithms/hash.hpp" +#include "flatmemory/details/algorithms/murmurhash3.hpp" +#include "flatmemory/details/byte_buffer.hpp" +#include "flatmemory/details/byte_buffer_utils.hpp" +#include "flatmemory/details/layout.hpp" +#include "flatmemory/details/layout_utils.hpp" +#include "flatmemory/details/types/declarations.hpp" +#include "flatmemory/details/types/formatter.hpp" + +#include +#include +#include +#include +#include +#include + +namespace flatmemory +{ +/** + * ID class for non-trivial Vector type. + */ +template +struct Vector2 : public NonTrivialType +{ + /// @brief Non-trivial copy-constructor + /// @param other + Vector(const Vector& other) {} +}; + +template +class Builder> : public IBuilder>> +{ +public: +private: + flexbuffers::Builder m_fbb; +}; + +} + +#endif \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c3540c5..e68aaae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,13 @@ file(GLOB_RECURSE FLATMEMORY_PUBLIC_HEADER_FILES add_library(flatmemory STATIC ${FLATMEMORY_SRC_FILES} ${FLATMEMORY_PRIVATE_HEADER_FILES} ${FLATMEMORY_PUBLIC_HEADER_FILES}) +find_package(flatbuffers REQUIRED COMPONENTS flatbuffers PATHS ${CMAKE_PREFIX_PATH} NO_DEFAULT_PATH) +if(flatbuffers_FOUND) + include_directories(${flatbuffers_INCLUDE_DIRS}) + message(STATUS "Found flatbuffers: ${flatbuffers_DIR} (found version ${flatbuffers_VERSION})") +endif() +target_link_libraries(flatmemory flatbuffers::flatbuffers) + # Create an alias for simpler reference add_library(flatmemory::flatmemory ALIAS flatmemory)