1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-06-23 00:44:07 +00:00

Move receiver_type from PVT/adapters to PVT/libs, make it buildable with pre C++17

This commit is contained in:
Carles Fernandez 2025-05-13 07:30:22 +02:00
parent e8af596bce
commit d2d9abf26a
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
5 changed files with 60 additions and 15 deletions

View File

@ -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

View File

@ -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 <iostream> // 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 <iostream> // for std::cout
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h>
#else

View File

@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

View File

@ -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))

View File

@ -41,6 +41,31 @@ class Signal_Enabled_Flags
public:
explicit Signal_Enabled_Flags(const ConfigurationInterface* configuration);
#if NO_FOLD_EXPRESSIONS
template <typename T>
uint32_t or_all(const T& value) const
{
return value;
}
template <typename T, typename... Args>
uint32_t or_all(const T& first, const Args&... rest) const
{
return first | or_all(rest...);
}
template <typename... Args>
bool check_only_enabled(const Args&... args) const
{
return (flags_ ^ or_all(args...)) == 0;
}
template <typename... Args>
bool check_any_enabled(const Args&... args) const
{
return (flags_ & or_all(args...)) > 0;
}
#else
template <typename... Args>
bool check_only_enabled(const Args&... args) const
{
@ -52,6 +77,7 @@ public:
{
return (flags_ & (args | ...)) > 0;
}
#endif
private:
uint32_t flags_;