From d2d9abf26ad8a371afdb2bb23d5f5d0f825d3bc7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 13 May 2025 07:30:22 +0200 Subject: [PATCH] Move receiver_type from PVT/adapters to PVT/libs, make it buildable with pre C++17 --- src/algorithms/PVT/adapters/CMakeLists.txt | 6 ++--- src/algorithms/PVT/adapters/rtklib_pvt.cc | 23 ++++++++-------- src/algorithms/PVT/libs/CMakeLists.txt | 12 +++++++++ .../PVT/{adapters => libs}/receiver_type.cc | 8 ++++++ .../PVT/{adapters => libs}/receiver_type.h | 26 +++++++++++++++++++ 5 files changed, 60 insertions(+), 15 deletions(-) rename src/algorithms/PVT/{adapters => libs}/receiver_type.cc (98%) rename src/algorithms/PVT/{adapters => libs}/receiver_type.h (87%) diff --git a/src/algorithms/PVT/adapters/CMakeLists.txt b/src/algorithms/PVT/adapters/CMakeLists.txt index 673b09055..415fb13d4 100644 --- a/src/algorithms/PVT/adapters/CMakeLists.txt +++ b/src/algorithms/PVT/adapters/CMakeLists.txt @@ -10,14 +10,12 @@ if(USE_CMAKE_TARGET_SOURCES) target_sources(pvt_adapters PRIVATE rtklib_pvt.cc - receiver_type.cc PUBLIC rtklib_pvt.h - receiver_type.h ) else() - source_group(Headers FILES rtklib_pvt.h receiver_type.h) - add_library(pvt_adapters rtklib_pvt.cc rtklib_pvt.h receiver_type.h receiver_type.cc) + source_group(Headers FILES rtklib_pvt.h) + add_library(pvt_adapters rtklib_pvt.cc rtklib_pvt.h) endif() target_link_libraries(pvt_adapters diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 734e2c5f1..1d1eb6fa3 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -16,17 +16,18 @@ #include "rtklib_pvt.h" -#include "MATH_CONSTANTS.h" // for D2R -#include "configuration_interface.h" // for ConfigurationInterface -#include "galileo_almanac.h" // for Galileo_Almanac -#include "galileo_ephemeris.h" // for Galileo_Ephemeris -#include "gnss_sdr_flags.h" // for FLAGS_RINEX_version -#include "gps_almanac.h" // for Gps_Almanac -#include "gps_ephemeris.h" // for Gps_Ephemeris -#include "pvt_conf.h" // for Pvt_Conf -#include "receiver_type.h" // for get_type_of_receiver -#include "rtklib_rtkpos.h" // for rtkfree, rtkinit -#include // for std::cout +#include "MATH_CONSTANTS.h" // for D2R +#include "configuration_interface.h" // for ConfigurationInterface +#include "galileo_almanac.h" // for Galileo_Almanac +#include "galileo_ephemeris.h" // for Galileo_Ephemeris +#include "gnss_sdr_flags.h" // for FLAGS_RINEX_version +#include "gnss_sdr_string_literals.h" // for std::string_literals in C++11 +#include "gps_almanac.h" // for Gps_Almanac +#include "gps_ephemeris.h" // for Gps_Ephemeris +#include "pvt_conf.h" // for Pvt_Conf +#include "receiver_type.h" // for get_type_of_receiver +#include "rtklib_rtkpos.h" // for rtkfree, rtkinit +#include // for std::cout #if USE_GLOG_AND_GFLAGS #include #else diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index 8f89f7033..7a98f50ad 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -24,6 +24,7 @@ set(PVT_LIB_SOURCES has_simple_printer.cc geohash.cc pvt_kf.cc + receiver_type.cc ) set(PVT_LIB_HEADERS @@ -47,6 +48,7 @@ set(PVT_LIB_HEADERS has_simple_printer.h geohash.h pvt_kf.h + receiver_type.h ) list(SORT PVT_LIB_HEADERS) @@ -159,6 +161,16 @@ if(Boost_VERSION_STRING VERSION_LESS 1.71.0) ) endif() +if((CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD VERSION_LESS 17) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0") OR + (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.0") OR + (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")) + target_compile_definitions(pvt_libs + PUBLIC + -DNO_FOLD_EXPRESSIONS=1 + ) +endif() + set_property(TARGET pvt_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ ) diff --git a/src/algorithms/PVT/adapters/receiver_type.cc b/src/algorithms/PVT/libs/receiver_type.cc similarity index 98% rename from src/algorithms/PVT/adapters/receiver_type.cc rename to src/algorithms/PVT/libs/receiver_type.cc index 1e056d117..740188a23 100644 --- a/src/algorithms/PVT/adapters/receiver_type.cc +++ b/src/algorithms/PVT/libs/receiver_type.cc @@ -33,8 +33,15 @@ Signal_Enabled_Flags::Signal_Enabled_Flags(const ConfigurationInterface* configu {BDS_B1, "Channels_B1.count"}, {BDS_B3, "Channels_B3.count"}}; +#if NO_FOLD_EXPRESSIONS + for (const auto& pair_aux : signal_flag_to_prop) + { + auto flag = pair_aux.first; + auto prop = pair_aux.second; +#else for (const auto& [flag, prop] : signal_flag_to_prop) { +#endif const auto enabled = configuration->property(prop, 0) > 0; if (enabled) @@ -44,6 +51,7 @@ Signal_Enabled_Flags::Signal_Enabled_Flags(const ConfigurationInterface* configu } } + uint32_t get_type_of_receiver(const Signal_Enabled_Flags& signal_enabled_flags) { if (signal_enabled_flags.check_only_enabled(GPS_1C)) diff --git a/src/algorithms/PVT/adapters/receiver_type.h b/src/algorithms/PVT/libs/receiver_type.h similarity index 87% rename from src/algorithms/PVT/adapters/receiver_type.h rename to src/algorithms/PVT/libs/receiver_type.h index b6862614c..5008a988e 100644 --- a/src/algorithms/PVT/adapters/receiver_type.h +++ b/src/algorithms/PVT/libs/receiver_type.h @@ -41,6 +41,31 @@ class Signal_Enabled_Flags public: explicit Signal_Enabled_Flags(const ConfigurationInterface* configuration); +#if NO_FOLD_EXPRESSIONS + template + uint32_t or_all(const T& value) const + { + return value; + } + + template + uint32_t or_all(const T& first, const Args&... rest) const + { + return first | or_all(rest...); + } + + template + bool check_only_enabled(const Args&... args) const + { + return (flags_ ^ or_all(args...)) == 0; + } + + template + bool check_any_enabled(const Args&... args) const + { + return (flags_ & or_all(args...)) > 0; + } +#else template bool check_only_enabled(const Args&... args) const { @@ -52,6 +77,7 @@ public: { return (flags_ & (args | ...)) > 0; } +#endif private: uint32_t flags_;