Skip to content

Commit

Permalink
added basic version of v2 which will be a templated wrapper around fl…
Browse files Browse the repository at this point in the history
…exbuffer
  • Loading branch information
drexlerd committed Aug 25, 2024
1 parent 368f92b commit 9e90ba4
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ project(dependencies)

add_subdirectory(benchmark)
add_subdirectory(googletest)
add_subdirectory(flatbuffers)
21 changes: 21 additions & 0 deletions dependencies/flatbuffers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 [email protected]:google/flatbuffers.git
GIT_TAG master
PREFIX ${CMAKE_BINARY_DIR}/flatbuffers
CMAKE_ARGS ${CMAKE_ARGS}
)
60 changes: 60 additions & 0 deletions include/flatmemory/details/types/vector2.hpp
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#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 <algorithm>
#include <cassert>
#include <flatbuffers/flexbuffers.h>
#include <iostream>
#include <ranges>
#include <vector>

namespace flatmemory
{
/**
* ID class for non-trivial Vector type.
*/
template<IsTriviallyCopyableOrNonTrivialType T>
struct Vector2 : public NonTrivialType
{
/// @brief Non-trivial copy-constructor
/// @param other
Vector(const Vector& other) {}
};

template<IsTriviallyCopyableOrNonTrivialType T>
class Builder<Vector2<T>> : public IBuilder<Builder<Vector2<T>>>
{
public:
private:
flexbuffers::Builder m_fbb;
};

}

#endif
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 9e90ba4

Please sign in to comment.