Use lambdas if possible.

Fine tuning in CMake scripts
This commit is contained in:
Carles Fernandez 2020-06-15 19:23:59 +02:00
parent 8cc799235b
commit 3beb1e98af
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 42 additions and 11 deletions

View File

@ -62,8 +62,9 @@ endif()
target_link_libraries(core_libs
PUBLIC
Boost::headers
Gnuradio::blocks
Gnuradio::runtime
Gnuradio::pmt
core_libs_supl
core_system_parameters
pvt_libs
@ -74,6 +75,12 @@ target_link_libraries(core_libs
Pugixml::pugixml
)
if(USE_GENERIC_LAMBDAS AND NOT GNURADIO_USES_STD_POINTERS)
target_link_libraries(core_libs PUBLIC Boost::headers)
else()
target_link_libraries(core_libs PRIVATE Boost::headers)
endif()
if(GNURADIO_USES_STD_POINTERS)
target_compile_definitions(core_libs
PUBLIC -DGNURADIO_USES_STD_POINTERS=1

View File

@ -136,7 +136,6 @@ endif()
target_link_libraries(core_receiver
PUBLIC
core_libs
Gnuradio::runtime
PRIVATE
core_monitor
signal_source_adapters
@ -162,6 +161,21 @@ if(ENABLE_ARMA_NO_DEBUG)
)
endif()
if(USE_GENERIC_LAMBDAS)
set(has_generic_lambdas HAS_GENERIC_LAMBDA=1)
set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0)
target_compile_definitions(core_receiver
PRIVATE
"$<$<COMPILE_FEATURES:cxx_generic_lambdas>:${has_generic_lambdas}>"
"$<$<NOT:$<COMPILE_FEATURES:cxx_generic_lambdas>>:${no_has_generic_lambdas}>"
)
else()
target_compile_definitions(core_receiver
PRIVATE
-DHAS_GENERIC_LAMBDA=0
)
endif()
# Fix for Boost Asio < 1.70
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (Boost_VERSION_STRING VERSION_LESS 1.70.0))

View File

@ -48,13 +48,23 @@ TcpCmdInterface::TcpCmdInterface()
void TcpCmdInterface::register_functions()
{
functions["status"] = std::bind(&TcpCmdInterface::status, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
functions["standby"] = std::bind(&TcpCmdInterface::standby, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
functions["reset"] = std::bind(&TcpCmdInterface::reset, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
functions["hotstart"] = std::bind(&TcpCmdInterface::hotstart, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
functions["warmstart"] = std::bind(&TcpCmdInterface::warmstart, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
functions["coldstart"] = std::bind(&TcpCmdInterface::coldstart, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
functions["set_ch_satellite"] = std::bind(&TcpCmdInterface::set_ch_satellite, this, std::placeholders::_1); // NOLINT(modernize-avoid-bind)
#if HAS_GENERIC_LAMBDA
functions["status"] = [&](auto &s) { return TcpCmdInterface::status(s); };
functions["standby"] = [&](auto &s) { return TcpCmdInterface::standby(s); };
functions["reset"] = [&](auto &s) { return TcpCmdInterface::reset(s); };
functions["hotstart"] = [&](auto &s) { return TcpCmdInterface::hotstart(s); };
functions["warmstart"] = [&](auto &s) { return TcpCmdInterface::warmstart(s); };
functions["coldstart"] = [&](auto &s) { return TcpCmdInterface::coldstart(s); };
functions["set_ch_satellite"] = [&](auto &s) { return TcpCmdInterface::set_ch_satellite(s); };
#else
functions["status"] = std::bind(&TcpCmdInterface::status, this, std::placeholders::_1);
functions["standby"] = std::bind(&TcpCmdInterface::standby, this, std::placeholders::_1);
functions["reset"] = std::bind(&TcpCmdInterface::reset, this, std::placeholders::_1);
functions["hotstart"] = std::bind(&TcpCmdInterface::hotstart, this, std::placeholders::_1);
functions["warmstart"] = std::bind(&TcpCmdInterface::warmstart, this, std::placeholders::_1);
functions["coldstart"] = std::bind(&TcpCmdInterface::coldstart, this, std::placeholders::_1);
functions["set_ch_satellite"] = std::bind(&TcpCmdInterface::set_ch_satellite, this, std::placeholders::_1);
#endif
}
@ -64,7 +74,7 @@ void TcpCmdInterface::set_pvt(std::shared_ptr<PvtInterface> PVT_sptr)
}
time_t TcpCmdInterface::get_utc_time()
time_t TcpCmdInterface::get_utc_time() const
{
return receiver_utc_time_;
}

View File

@ -45,7 +45,7 @@ public:
/*!
* \brief gets the UTC time parsed from the last TC command issued
*/
time_t get_utc_time();
time_t get_utc_time() const;
/*!
* \brief gets the Latitude, Longitude and Altitude vector from the last TC command issued