Skip to content

Commit

Permalink
Replace reflectpp with reflect-cpp (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicer86 committed Jan 5, 2024
1 parent 997646e commit 3c4a28d
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 104 deletions.
4 changes: 1 addition & 3 deletions .github/aur/photobroom-git/.SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pkgbase = photobroom-git
makedepends = libwebp
makedepends = cs-libguarded
makedepends = boost
makedepends = clang
makedepends = llvm
depends = exiv2
depends = qt6-base
depends = qt6-multimedia
Expand All @@ -30,7 +28,7 @@ pkgbase = photobroom-git
source = qml-colorpicker::git+https://github.com/rshest/qml-colorpicker.git#commit=5967b3e38033794f54d66c57a03f9a356df0dc03
source = face_recognition_models::git+https://github.com/ageitgey/face_recognition_models.git#commit=e67de717267507d1e9246de95692eb8be736ab61
source = animated_webp::git+https://github.com/Kicer86/AnimatedWebP.git#commit=996e92a0c45b2ea20034c9e97ec75d2098faf2f8
source = reflectpp::git+https://github.com/Kicer86/reflectpp.git#commit=5dc631cb129dd6a5dbdcab8836ba7e0772c2b02c
source = reflect-cpp::git+https://github.com/getml/reflect-cpp.git#commit=0a524a9893fc1220fe38734dac311b032edd4b79
md5sums = SKIP
md5sums = SKIP
md5sums = SKIP
Expand Down
8 changes: 4 additions & 4 deletions .github/aur/photobroom-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ url="https://github.com/Kicer86/photobroom"
license=('GPL3')
groups=()
depends=('exiv2' 'qt6-base' 'qt6-multimedia' 'qt6-declarative' 'qt6-svg' 'dlib' 'opencv' 'jsoncpp')
makedepends=('cmake' 'magic_enum' 'qt6-tools' 'imagemagick' 'libwebp' 'cs-libguarded' 'boost' 'clang' 'llvm')
makedepends=('cmake' 'magic_enum' 'qt6-tools' 'imagemagick' 'libwebp' 'cs-libguarded' 'boost')
optdepends=()
provides=('photobroom')
conflicts=('photobroom')
Expand All @@ -22,7 +22,7 @@ source=(photobroom-git::git+https://github.com/Kicer86/photobroom.git#branch=mas
qml-colorpicker::git+https://github.com/rshest/qml-colorpicker.git#commit=5967b3e38033794f54d66c57a03f9a356df0dc03
face_recognition_models::git+https://github.com/ageitgey/face_recognition_models.git#commit=e67de717267507d1e9246de95692eb8be736ab61
animated_webp::git+https://github.com/Kicer86/AnimatedWebP.git#commit=996e92a0c45b2ea20034c9e97ec75d2098faf2f8
reflectpp::git+https://github.com/Kicer86/reflectpp.git#commit=5dc631cb129dd6a5dbdcab8836ba7e0772c2b02c
reflect-cpp::git+https://github.com/getml/reflect-cpp.git#commit=0a524a9893fc1220fe38734dac311b032edd4b79
)
noextract=()
md5sums=('SKIP'
Expand All @@ -44,12 +44,12 @@ prepare()
rm -d $pkgname/src/gui/desktop/quick_items/external/qml-colorpicker
rm -d $pkgname/src/gui/desktop/utils/animated_webp
rm -d $pkgname/src/face_recognition/dlib_wrapper/face_recognition_models
rm -d $pkgname/tools/reflect++
rm -d $pkgname/src/third_party/reflect-cpp
ln -s ../cmake_modules $pkgname/cmake_modules
ln -s ../../../../../../qml-colorpicker $pkgname/src/gui/desktop/quick_items/external/qml-colorpicker
ln -s ../../../../../animated_webp $pkgname/src/gui/desktop/utils/animated_webp
ln -s ../../../../face_recognition_models $pkgname/src/face_recognition/dlib_wrapper/face_recognition_models
ln -s ../../reflectpp $pkgname/tools/reflect++
ln -s ../../../reflect-cpp $pkgname/src/third_party/reflect-cpp
}

build()
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ jobs:
submodules: true

- name: Load llvm keys
if: matrix.compiler.compiler == 'LLVM'
run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

- name: Update clang
if: matrix.compiler.compiler == 'LLVM'
uses: myci-actions/add-deb-repo@10
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main
repo-name: llvm-toolchain-focal-16
update: false
install: clang-16

- name: Install system dependencies
run: |
Expand All @@ -44,9 +47,7 @@ jobs:
qt6-multimedia-dev \
libqt6svg6-dev \
qt6-l10n-tools \
clang-16 \
libboost-dev \
libclang-16-dev \
libopencv-dev \
libdlib-dev \
libexiv2-dev \
Expand Down Expand Up @@ -81,4 +82,4 @@ jobs:
build-type: Release
cc: ${{ matrix.compiler.CC }}
cxx: ${{ matrix.compiler.CXX }}
configure-options: -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DLUPDATE=/usr/lib/qt6/bin/lupdate -DLRELEASE:FILEPATH=/usr/lib/qt6/bin/lrelease -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DClang_DIR=/usr/lib/llvm-16/lib/cmake/clang
configure-options: -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DLUPDATE=/usr/lib/qt6/bin/lupdate -DLRELEASE:FILEPATH=/usr/lib/qt6/bin/lrelease -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
[submodule "src/gui/desktop/utils/animated_webp"]
path = src/gui/desktop/utils/animated_webp
url = https://github.com/Kicer86/AnimatedWebP.git
[submodule "tools/reflex++"]
path = tools/reflect++
url = https://github.com/Kicer86/reflexpp.git
[submodule "src/third_party/reflect-cpp"]
path = src/third_party/reflect-cpp
url = https://github.com/getml/reflect-cpp.git
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ endif(UNIX OR CYGWIN)

#subdirs
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(tr)

#documentation
Expand Down
2 changes: 1 addition & 1 deletion cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro(addTestTarget target)
get_source_file_property(is_generated ${source_name} GENERATED)

if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name} AND
NOT ${is_generated})
NOT ${is_generated} AND NOT EXISTS ${source_name})
message(FATAL_ERROR "File ${source_name} for '${target}' does not exist")
endif()
endforeach()
Expand Down
32 changes: 17 additions & 15 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,25 @@ qt6_add_resources(CORE_RESOURCES ${CORE_RESOURCE_FILES})

add_library(core ${CORE_SOURCES} ${CORE_RESOURCES})
target_link_libraries(core
PUBLIC
Qt::Core
Qt::Gui
Qt::Multimedia
PRIVATE
system
${CMAKE_THREAD_LIBS_INIT}
CsLibGuarded::CsLibGuarded
${EXIV2_LIB}
opencv_videoio
PUBLIC
Qt::Core
Qt::Gui
Qt::Multimedia
PRIVATE
system
${CMAKE_THREAD_LIBS_INIT}
CsLibGuarded::CsLibGuarded
${EXIV2_LIB}
opencv_videoio
)

target_include_directories(core PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
target_include_directories(core
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/third_party/reflect-cpp/include
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

set_target_properties(core PROPERTIES AUTOMOC TRUE)
Expand Down
15 changes: 2 additions & 13 deletions src/core/core_test.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@

include(${CMAKE_SOURCE_DIR}/cmake/functions.cmake)

find_package(GTest REQUIRED CONFIG)
find_package(GTest REQUIRED CONFIG)
find_package(Qt6 REQUIRED COMPONENTS Core Gui)
find_package(Qt6Test REQUIRED)

include(${PROJECT_SOURCE_DIR}/tools/reflect++/Reflect++.cmake)

ReflectFiles(
ReflectionFiles
TARGET
core
SOURCES
unit_tests/json_serializer_tests.hpp
)

addTestTarget(core
SOURCES
implementation/base_tags.cpp
Expand All @@ -41,8 +31,6 @@ addTestTarget(core
unit_tests/status_tests.cpp
unit_tests/tag_value_tests.cpp

${ReflectionFiles}

LIBRARIES
GTest::gtest
GTest::gmock
Expand All @@ -55,6 +43,7 @@ addTestTarget(core
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/third_party/reflect-cpp/include

DEFINITIONS
CORE_STATIC_DEFINE # disable visibility mechanisms to prevent inconsistent dll linkage warnings
Expand Down
29 changes: 15 additions & 14 deletions src/core/json_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#include <QJsonDocument>
#include <QJsonObject>

#include "rfl.hpp"
#include "rfl/to_view.hpp"
#include "generic_concepts.hpp"


namespace JSon
{
template<typename T>
Expand Down Expand Up @@ -90,11 +91,13 @@ namespace JSon
{
QJsonObject jsonObj;

reflectpp::get_object_members(obj, [&jsonObj](auto member_info, const auto& member)
{
const QString name = QString::fromStdString(std::string(member_info.name));
jsonObj[name] = getSerialized(member);
});
const auto objView = rfl::to_view(obj);

const auto process = [&jsonObj]<class... F>(F... _field) {
(( jsonObj[QString::fromStdString(typename F::Name().str())] = getSerialized(*_field.value()) ), ...);
};

std::apply(process, objView.fields());

return jsonObj;
}
Expand Down Expand Up @@ -137,16 +140,14 @@ namespace JSon
}
else
{
const QJsonObject object = convertTo<QJsonObject>(json);
const QJsonObject jsonObj = convertTo<QJsonObject>(json);
auto objView = rfl::to_view(r);

reflectpp::set_object_members(r, [&object](const auto member_info)
{
using VT = decltype(member_info)::type;
const QString name = QString::fromStdString(std::string(member_info.name));
const auto value = object[name];
const auto process = [&jsonObj]<class... F>(F... _field) {
(( *_field.value() = getDeserialized<std::remove_pointer_t<typename F::Type>>(jsonObj[QString::fromStdString(typename F::Name().str())]) ), ...);
};

return getDeserialized<VT>(value);
});
std::apply(process, objView.fields());
}

return r;
Expand Down
5 changes: 3 additions & 2 deletions src/core/unit_tests/json_serializer_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

#include <gtest/gtest.h>

#include "json_serializer_tests_r++.hpp"
#include "rfl.hpp"
#include "json_serializer.hpp"
#include "json_serializer_tests.hpp"



namespace
Expand Down Expand Up @@ -93,7 +95,6 @@ TEST(JsonSerializerTest, SerializationDeserialization)

TEST(JsonSerializerTest, CustomSerializationDeserialization)
{

XYZ xyz;
xyz.a = 77;
xyz.b = -156;
Expand Down
43 changes: 20 additions & 23 deletions src/core/unit_tests/json_serializer_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,28 @@
#include <QRect>


namespace
struct ABC
{
struct ABC
int a = 5;
float b = 45.f;
double c = 123.;
std::string d = "Hello";
QRect e = QRect(1, 2, 3, 4);
std::vector<QSize> f = {};

bool operator==(const ABC& other) const
{
int a = 5;
float b = 45.f;
double c = 123.;
std::string d = "Hello";
QRect e = QRect(1, 2, 3, 4);
std::vector<QSize> f = {};
return std::tie(a, b, c, d, e, f) == std::tie(other.a, other.b, other.c, other.d, other.e, other.f);
}
};

bool operator==(const ABC& other) const
{
return std::tie(a, b, c, d, e, f) == std::tie(other.a, other.b, other.c, other.d, other.e, other.f);
}
};
struct DEF
{
std::vector<ABC> abc_vec;
std::deque<ABC> abc_deque;

struct DEF
bool operator==(const DEF& other) const
{
std::vector<ABC> abc_vec;
std::deque<ABC> abc_deque;

bool operator==(const DEF& other) const
{
return std::tie(abc_vec, abc_deque) == std::tie(other.abc_vec, other.abc_deque);
}
};
}
return std::tie(abc_vec, abc_deque) == std::tie(other.abc_vec, other.abc_deque);
}
};
11 changes: 0 additions & 11 deletions src/database/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ find_package(Threads REQUIRED)
find_package(MagicEnum REQUIRED)
find_package(OpenCV REQUIRED)

include(${PROJECT_SOURCE_DIR}/tools/reflect++/Reflect++.cmake)

set(DATABASE_SOURCES
actions.hpp
apeople_information_accessor.hpp
Expand Down Expand Up @@ -93,15 +91,6 @@ target_include_directories(database

set_target_properties(database PROPERTIES AUTOMOC TRUE)

ReflectFiles(ReflectionFiles
TARGET
database
SOURCES
person_data.hpp
)

target_sources(database PRIVATE ${ReflectionFiles})

generate_export_header(database)
hideSymbols(database)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <QStringList>
#include <QVariant>

#include "person_data_r++.hpp"

#include <core/containers_utils.hpp>
#include <core/json_serializer.hpp>
#include "../json_to_backend.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/database/database_tools/json_to_backend.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#ifndef JSONTOBACKEND_HPP
#define JSONTOBACKEND_HPP


#include <QJsonArray>
#include <QJsonObject>
#include <QString>
Expand Down
1 change: 1 addition & 0 deletions src/gui/desktop/models/faces_model.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include <cassert>
#include <ranges>

#include <core/icore_factory_accessor.hpp>
#include <core/iexif_reader.hpp>
Expand Down
6 changes: 1 addition & 5 deletions src/gui/desktop/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ add_subdirectory(animated_webp)
find_package(Qt6 REQUIRED COMPONENTS Svg Quick QuickWidgets)
find_package(OpenCV REQUIRED)

include(${PROJECT_SOURCE_DIR}/tools/reflect++/Reflect++.cmake)

set(UTILS_SOURCES
grouppers/animation_generator.cpp
grouppers/animation_generator.hpp
Expand Down Expand Up @@ -57,7 +55,7 @@ set(UTILS_SOURCES
variant_display.hpp
)

add_library(gui_utils OBJECT ${UTILS_SOURCES} ${ReflectionFiles})
add_library(gui_utils OBJECT ${UTILS_SOURCES})
set_target_properties(gui_utils PROPERTIES AUTOMOC TRUE)
target_link_libraries(gui_utils
PRIVATE
Expand All @@ -81,5 +79,3 @@ target_include_directories(gui_utils
${CMAKE_SOURCE_DIR}/src/gui/desktop
${CMAKE_CURRENT_BINARY_DIR}
)

target_sources(gui_utils PRIVATE ${ReflectionFiles})
1 change: 1 addition & 0 deletions src/third_party/reflect-cpp
Submodule reflect-cpp added at 0a524a
2 changes: 0 additions & 2 deletions tools/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion tools/reflect++
Submodule reflect++ deleted from 5dc631

0 comments on commit 3c4a28d

Please sign in to comment.