From 8d4d4f67b10244421d210d02430956f70e31664d Mon Sep 17 00:00:00 2001 From: KerstinKeller Date: Tue, 16 Apr 2024 17:59:17 +0200 Subject: [PATCH 1/3] [build] make eCAL::proto part of ecal subfolder (ecal_core project) (#1528) - changed include folder from "ecal/protobuf/..." to "ecal/msg/protobuf/..." to be in line with the includes from core (e.g. subscriber.h / publisher.h) --- CMakeLists.txt | 5 - app/mon/mon_cli/CMakeLists.txt | 3 +- .../protobuf_reflection/CMakeLists.txt | 3 +- .../protobuf_reflection/src/plugin_widget.h | 2 +- .../src/protobuf_tree_builder.h | 2 +- .../signals_plotting/CMakeLists.txt | 2 +- .../signals_plotting/src/plugin_widget.h | 2 +- .../src/protobuf_tree_builder.h | 2 +- app/mon/mon_tui/CMakeLists.txt | 3 +- .../view/message_visualization/proto_tree.hpp | 4 +- .../viewmodel/message_visualization/proto.hpp | 2 +- app/play/play_core/CMakeLists.txt | 2 +- app/rec/rec_client_core/CMakeLists.txt | 2 +- app/rec/rec_server_core/CMakeLists.txt | 2 +- app/sys/sys_client_cli/CMakeLists.txt | 2 +- app/sys/sys_core/CMakeLists.txt | 2 +- contrib/ecaltime/simtime/CMakeLists.txt | 2 +- .../message/include/ecal/msg/proto/message.h | 2 +- contrib/mma/CMakeLists.txt | 4 +- ecal/CMakeLists.txt | 1 + ecal/core/CMakeLists.txt | 21 +- .../ecal/msg/protobuf/ecal_proto_dyn.h | 441 ------------------ .../ecal/msg/protobuf/ecal_proto_hlp.h | 172 ------- .../msg/protobuf}/CMakeLists.txt | 49 +- .../ecal/msg}/protobuf/ecal_proto_decoder.h | 0 .../ecal/msg}/protobuf/ecal_proto_dyn.h | 5 +- .../ecal/msg}/protobuf/ecal_proto_hlp.h | 2 +- .../ecal_proto_maximum_array_dimensions.h | 2 +- .../msg}/protobuf/ecal_proto_message_filter.h | 0 .../ecal/msg}/protobuf/ecal_proto_visitor.h | 0 .../msg/protobuf}/src/ecal_proto_decoder.cpp | 8 +- .../msg/protobuf}/src/ecal_proto_dyn.cpp | 44 +- .../ecal_proto_maximum_array_dimensions.cpp | 4 +- .../src/ecal_proto_message_filter.cpp | 2 +- .../msg/protobuf}/src/ecal_proto_visitor.cpp | 0 .../orchestration/component1/CMakeLists.txt | 4 +- .../orchestration/component2/CMakeLists.txt | 4 +- .../orchestration/orchestrator/CMakeLists.txt | 4 +- .../protobuf/person_events_rec/CMakeLists.txt | 4 +- .../protobuf/person_events_snd/CMakeLists.txt | 4 +- .../protobuf/person_loopback/CMakeLists.txt | 4 +- .../pubsub/protobuf/person_rec/CMakeLists.txt | 4 +- .../pubsub/protobuf/person_snd/CMakeLists.txt | 4 +- .../proto_dyn_json_rec/CMakeLists.txt | 8 +- .../protobuf/proto_dyn_rec/CMakeLists.txt | 7 +- .../protobuf/proto_dyn_snd/CMakeLists.txt | 4 +- .../cpp/services/math_client/CMakeLists.txt | 4 +- .../cpp/services/math_server/CMakeLists.txt | 4 +- .../cpp/services/ping_client/CMakeLists.txt | 4 +- .../services/ping_client_dyn/CMakeLists.txt | 4 +- .../cpp/services/ping_server/CMakeLists.txt | 4 +- .../clientserver_proto_test/CMakeLists.txt | 6 +- .../cpp/pubsub_proto_test/CMakeLists.txt | 7 +- .../services/ecalplayer_client/CMakeLists.txt | 3 +- .../ecalplayer_gui_client/CMakeLists.txt | 3 +- .../services/ecalsys_client/CMakeLists.txt | 6 +- .../services/player_stepper/CMakeLists.txt | 8 +- .../rec_client_service_cli/CMakeLists.txt | 6 +- .../rec_client_service_gui/CMakeLists.txt | 3 +- .../rec_server_service_gui/CMakeLists.txt | 3 +- .../dynproto_test/src/dynproto_test.cpp | 2 +- .../ecal_proto_test/src/test_filters.cpp | 2 +- 62 files changed, 175 insertions(+), 744 deletions(-) delete mode 100644 ecal/core/include/ecal/msg/protobuf/ecal_proto_dyn.h delete mode 100644 ecal/core/include/ecal/msg/protobuf/ecal_proto_hlp.h rename {contrib/ecalproto => ecal/msg/protobuf}/CMakeLists.txt (51%) rename {contrib/ecalproto/include/ecal => ecal/msg/protobuf/include/ecal/msg}/protobuf/ecal_proto_decoder.h (100%) rename {contrib/ecalproto/include/ecal => ecal/msg/protobuf/include/ecal/msg}/protobuf/ecal_proto_dyn.h (96%) rename {contrib/ecalproto/include/ecal => ecal/msg/protobuf/include/ecal/msg}/protobuf/ecal_proto_hlp.h (99%) rename {contrib/ecalproto/include/ecal => ecal/msg/protobuf/include/ecal/msg}/protobuf/ecal_proto_maximum_array_dimensions.h (96%) rename {contrib/ecalproto/include/ecal => ecal/msg/protobuf/include/ecal/msg}/protobuf/ecal_proto_message_filter.h (100%) rename {contrib/ecalproto/include/ecal => ecal/msg/protobuf/include/ecal/msg}/protobuf/ecal_proto_visitor.h (100%) rename {contrib/ecalproto => ecal/msg/protobuf}/src/ecal_proto_decoder.cpp (98%) rename {contrib/ecalproto => ecal/msg/protobuf}/src/ecal_proto_dyn.cpp (88%) rename {contrib/ecalproto => ecal/msg/protobuf}/src/ecal_proto_maximum_array_dimensions.cpp (93%) rename {contrib/ecalproto => ecal/msg/protobuf}/src/ecal_proto_message_filter.cpp (99%) rename {contrib/ecalproto => ecal/msg/protobuf}/src/ecal_proto_visitor.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2a9720c99..9d5ee871cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,11 +233,6 @@ if(WIN32) set(CMAKE_RELWITHDEBINFO_POSTFIX reldbg) endif() -# -------------------------------------------------------- -# protobuf utilities -# -------------------------------------------------------- -add_subdirectory(contrib/ecalproto) - # -------------------------------------------------------- # ecal app protobuf interface # -------------------------------------------------------- diff --git a/app/mon/mon_cli/CMakeLists.txt b/app/mon/mon_cli/CMakeLists.txt index aad13afc55..3b99c47dae 100644 --- a/app/mon/mon_cli/CMakeLists.txt +++ b/app/mon/mon_cli/CMakeLists.txt @@ -42,9 +42,8 @@ target_compile_definitions(${PROJECT_NAME} create_targets_protobuf() target_link_libraries(${PROJECT_NAME} - protobuf::libprotobuf tclap::tclap - eCAL::core + eCAL::core_protobuf eCAL::core_pb) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/app/mon/mon_plugins/protobuf_reflection/CMakeLists.txt b/app/mon/mon_plugins/protobuf_reflection/CMakeLists.txt index 4060345ab9..e76cb873e5 100644 --- a/app/mon/mon_plugins/protobuf_reflection/CMakeLists.txt +++ b/app/mon/mon_plugins/protobuf_reflection/CMakeLists.txt @@ -63,8 +63,7 @@ create_targets_protobuf() target_link_libraries (${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets - eCAL::core - eCAL::proto + eCAL::core_protobuf eCAL::app_pb protobuf::libprotobuf MonitorTreeView diff --git a/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.h b/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.h index dead5b5ec1..992c148e14 100644 --- a/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.h +++ b/app/mon/mon_plugins/protobuf_reflection/src/plugin_widget.h @@ -32,7 +32,7 @@ #include "ui_plugin_widget.h" -#include +#include #include class PluginWidget : public QWidget, public eCAL::mon::PluginWidgetInterface diff --git a/app/mon/mon_plugins/protobuf_reflection/src/protobuf_tree_builder.h b/app/mon/mon_plugins/protobuf_reflection/src/protobuf_tree_builder.h index 15055fae46..c3e9fc96b6 100644 --- a/app/mon/mon_plugins/protobuf_reflection/src/protobuf_tree_builder.h +++ b/app/mon/mon_plugins/protobuf_reflection/src/protobuf_tree_builder.h @@ -22,7 +22,7 @@ #include #include "monitor_tree_model.h" -#include +#include #include class ProtobufTreeBuilder : public eCAL::protobuf::MessageVisitor diff --git a/app/mon/mon_plugins/signals_plotting/CMakeLists.txt b/app/mon/mon_plugins/signals_plotting/CMakeLists.txt index caad4008cb..e668f0bcef 100644 --- a/app/mon/mon_plugins/signals_plotting/CMakeLists.txt +++ b/app/mon/mon_plugins/signals_plotting/CMakeLists.txt @@ -76,7 +76,7 @@ target_link_libraries (${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets eCAL::core - eCAL::proto + eCAL::core_protobuf eCAL::app_pb protobuf::libprotobuf eCAL::mon_plugin_lib diff --git a/app/mon/mon_plugins/signals_plotting/src/plugin_widget.h b/app/mon/mon_plugins/signals_plotting/src/plugin_widget.h index 6b3b92df4a..e10787c4ee 100644 --- a/app/mon/mon_plugins/signals_plotting/src/plugin_widget.h +++ b/app/mon/mon_plugins/signals_plotting/src/plugin_widget.h @@ -46,7 +46,7 @@ #include "ui_plugin_widget.h" -#include +#include #include class PluginWidget : public QWidget, public eCAL::mon::PluginWidgetInterface diff --git a/app/mon/mon_plugins/signals_plotting/src/protobuf_tree_builder.h b/app/mon/mon_plugins/signals_plotting/src/protobuf_tree_builder.h index 60d4ed9a89..eaba487264 100644 --- a/app/mon/mon_plugins/signals_plotting/src/protobuf_tree_builder.h +++ b/app/mon/mon_plugins/signals_plotting/src/protobuf_tree_builder.h @@ -22,7 +22,7 @@ #include #include "signal_tree_model.h" -#include +#include #include class ProtobufTreeBuilder : public eCAL::protobuf::MessageVisitor diff --git a/app/mon/mon_tui/CMakeLists.txt b/app/mon/mon_tui/CMakeLists.txt index 3dfa2a7852..4d36b72694 100644 --- a/app/mon/mon_tui/CMakeLists.txt +++ b/app/mon/mon_tui/CMakeLists.txt @@ -118,9 +118,8 @@ create_targets_protobuf() target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf tclap::tclap - eCAL::core + eCAL::core_protobuf eCAL::core_pb - eCAL::proto ftxui::screen ftxui::dom ftxui::component) diff --git a/app/mon/mon_tui/src/tui/view/message_visualization/proto_tree.hpp b/app/mon/mon_tui/src/tui/view/message_visualization/proto_tree.hpp index a3274c8008..9864bafff7 100644 --- a/app/mon/mon_tui/src/tui/view/message_visualization/proto_tree.hpp +++ b/app/mon/mon_tui/src/tui/view/message_visualization/proto_tree.hpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp b/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp index 0db3abd09a..1a170baf1d 100644 --- a/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp +++ b/app/mon/mon_tui/src/tui/viewmodel/message_visualization/proto.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include "tui/viewmodel/message_visualization/message_visualization.hpp" diff --git a/app/play/play_core/CMakeLists.txt b/app/play/play_core/CMakeLists.txt index 466e6ee9e1..29de1b037d 100644 --- a/app/play/play_core/CMakeLists.txt +++ b/app/play/play_core/CMakeLists.txt @@ -55,7 +55,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads spdlog::spdlog protobuf::libprotobuf - eCAL::core + eCAL::core_protobuf eCAL::app_pb eCAL::ecaltime_pb eCAL::measurement_hdf5 diff --git a/app/rec/rec_client_core/CMakeLists.txt b/app/rec/rec_client_core/CMakeLists.txt index ec7312dd5e..f0eda371be 100644 --- a/app/rec/rec_client_core/CMakeLists.txt +++ b/app/rec/rec_client_core/CMakeLists.txt @@ -94,7 +94,7 @@ target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf - eCAL::core + eCAL::core_protobuf eCAL::core_pb eCAL::app_pb PRIVATE diff --git a/app/rec/rec_server_core/CMakeLists.txt b/app/rec/rec_server_core/CMakeLists.txt index 6f5225d9e3..49a6587564 100644 --- a/app/rec/rec_server_core/CMakeLists.txt +++ b/app/rec/rec_server_core/CMakeLists.txt @@ -68,7 +68,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE tinyxml2::tinyxml2 protobuf::libprotobuf - eCAL::core + eCAL::core_protobuf eCAL::app_pb ThreadingUtils Threads::Threads diff --git a/app/sys/sys_client_cli/CMakeLists.txt b/app/sys/sys_client_cli/CMakeLists.txt index c18eeaa3ee..5a6faf76b0 100644 --- a/app/sys/sys_client_cli/CMakeLists.txt +++ b/app/sys/sys_client_cli/CMakeLists.txt @@ -43,7 +43,7 @@ target_link_libraries(${PROJECT_NAME} spdlog::spdlog tclap::tclap protobuf::libprotobuf - eCAL::core + eCAL::core_protobuf eCAL::core_pb eCAL::app_pb eCAL::sys_client_core diff --git a/app/sys/sys_core/CMakeLists.txt b/app/sys/sys_core/CMakeLists.txt index 707178a715..795d2ba55e 100644 --- a/app/sys/sys_core/CMakeLists.txt +++ b/app/sys/sys_core/CMakeLists.txt @@ -91,7 +91,7 @@ target_link_libraries(${PROJECT_NAME} tinyxml2::tinyxml2 spdlog::spdlog protobuf::libprotobuf - eCAL::core + eCAL::core_protobuf eCAL::core_pb eCAL::app_pb EcalParser diff --git a/contrib/ecaltime/simtime/CMakeLists.txt b/contrib/ecaltime/simtime/CMakeLists.txt index 6b4951c710..018ff2b89c 100644 --- a/contrib/ecaltime/simtime/CMakeLists.txt +++ b/contrib/ecaltime/simtime/CMakeLists.txt @@ -45,7 +45,7 @@ ecal_add_time_plugin(${PROJECT_NAME} SHARED ${ecal_time_simtime_src} ${ecal_time target_compile_definitions(${PROJECT_NAME} PRIVATE ECAL_TIME_PLUGIN_API_EXPORT) -target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::core) +target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::core_protobuf) target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::ecaltime_pb) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/contrib/message/include/ecal/msg/proto/message.h b/contrib/message/include/ecal/msg/proto/message.h index 53b965f740..e4289bd466 100644 --- a/contrib/message/include/ecal/msg/proto/message.h +++ b/contrib/message/include/ecal/msg/proto/message.h @@ -28,7 +28,7 @@ #pragma warning(pop) #endif -#include +#include #include namespace eCAL diff --git a/contrib/mma/CMakeLists.txt b/contrib/mma/CMakeLists.txt index 5d1c072098..f6381e987e 100644 --- a/contrib/mma/CMakeLists.txt +++ b/contrib/mma/CMakeLists.txt @@ -81,9 +81,9 @@ target_include_directories(${PROJECT_NAME} create_targets_protobuf() target_link_libraries(${PROJECT_NAME} - protobuf::libprotobuf Threads::Threads - eCAL::core eCAL::app_pb + eCAL::core_protobuf + eCAL::app_pb $<$:Pdh> $<$:wbemuuid.lib>) diff --git a/ecal/CMakeLists.txt b/ecal/CMakeLists.txt index 4726aeebb8..dc36fe1ea6 100644 --- a/ecal/CMakeLists.txt +++ b/ecal/CMakeLists.txt @@ -24,6 +24,7 @@ cmake_minimum_required(VERSION 3.13) add_subdirectory(core) if(ECAL_CORE_HAS_PROTOBUF) + add_subdirectory(msg/protobuf) add_subdirectory(core_pb) endif() diff --git a/ecal/core/CMakeLists.txt b/ecal/core/CMakeLists.txt index 4c36e95cb3..d2f17ca25b 100644 --- a/ecal/core/CMakeLists.txt +++ b/ecal/core/CMakeLists.txt @@ -520,8 +520,6 @@ set(ecal_header_msg include/ecal/msg/protobuf/client.h include/ecal/msg/protobuf/dynamic_publisher.h include/ecal/msg/protobuf/dynamic_subscriber.h - include/ecal/msg/protobuf/ecal_proto_dyn.h - include/ecal/msg/protobuf/ecal_proto_hlp.h include/ecal/msg/protobuf/publisher.h include/ecal/msg/protobuf/server.h include/ecal/msg/protobuf/subscriber.h @@ -732,3 +730,22 @@ if(UNIX) set_property(TARGET ${PROJECT_NAME_PROCESS_STUB} PROPERTY FOLDER core) endif(UNIX) + +if(ECAL_CORE_HAS_PROTOBUF) +find_package(Protobuf REQUIRED) + +add_library(core_protobuf INTERFACE) +add_library(eCAL::core_protobuf ALIAS core_protobuf) + +target_link_libraries(core_protobuf + INTERFACE + eCAL::core + eCAL::proto +) + +install( + TARGETS core_protobuf + EXPORT eCALCoreTargets +) + +endif() \ No newline at end of file diff --git a/ecal/core/include/ecal/msg/protobuf/ecal_proto_dyn.h b/ecal/core/include/ecal/msg/protobuf/ecal_proto_dyn.h deleted file mode 100644 index 36a09e8353..0000000000 --- a/ecal/core/include/ecal/msg/protobuf/ecal_proto_dyn.h +++ /dev/null @@ -1,441 +0,0 @@ -/* ========================= eCAL LICENSE ================================= - * - * Copyright (C) 2016 - 2019 Continental Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ========================= eCAL LICENSE ================================= -*/ - -/** - * @file ecal_proto_dyn.h - * @brief dynamic protobuf message decoder -**/ - -#pragma once - -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning(push, 0) // disable proto warnings -#endif -#if defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif -#include -#include -#include -#include -#include -#include -#ifdef _MSC_VER -#pragma warning(pop) -#endif -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -#include - -namespace eCAL -{ - namespace protobuf - { - /** - * @brief eCAL dynamic protobuf decoder. - * - * The CProtoDynDecoder class is used to decode a protobuf message using protobuf reflection interface. The returned - * google message objects are owned by CProtoDynDecoder and freed on destruction. - * - * @code - * // create dynamic decoder - * std::string error_s; - * eCAL::CProtoDynDecoder decoder; - * std::shared_ptr msg_obj(decoder.GetProtoMessageFromFile("foo.proto", "FooMessage", error_s)); - * - * // receive a message - * std::string msg_s = ReceiveMessageFromAnyWhere("foo"); - * - * // decode message - * msg_obj->ParseFromString(msg_s); - * - * // print message - * std::cout << msg_obj->DebugString() << std::endl; - * @endcode - **/ - class CProtoDynDecoder - { - public: - /** - * @brief Create message from proto file. - * - * Note: Ownership of the google::protobuf::Message pointer is passed to the caller. - * - * @param proto_filename_ Proto file name. - * @param msg_type_ Type name. - * @param [out] error_s_ Error string. - * - * @return google message object or nullptr if generation failed (details see error_s_) - **/ - google::protobuf::Message* GetProtoMessageFromFile(const std::string& proto_filename_, const std::string& msg_type_, std::string& error_s_); - - /** - * @brief Create message from proto string. - * - * Note: Ownership of the google::protobuf::Message pointer is passed to the caller. - * - * @param proto_string_ Proto string. - * @param msg_type_ Type name. - * @param [out] error_s_ Error string. - * - * @return google message object or nullptr if generation failed (details see error_s_) - **/ - google::protobuf::Message* GetProtoMessageFromString(const std::string& proto_string_, const std::string& msg_type_, std::string& error_s_); - - /** - * @brief Create message from proto descriptor. - * - * Note: Ownership of the google::protobuf::Message pointer is passed to the caller. - * - * @param proto_desc_ Proto descriptor. - * @param msg_type_ Type name. - * @param [out] error_s_ Error string. - * - * @return google message object or nullptr if generation failed (details see error_s_) - **/ - google::protobuf::Message* GetProtoMessageFromDescriptor(const google::protobuf::FileDescriptorProto& proto_desc_, const std::string& msg_type_, std::string& error_s_); - - /** - * @brief Create message from serialized proto descriptor string. - * - * Note: Ownership of the google::protobuf::Message pointer is passed to the caller. - * - * @param msg_desc_ Serialized message descriptor. - * @param msg_type_ Type name. - * @param [out] error_s_ Error string. - * - * @return google message object or nullptr if generation failed (details see error_s_) - **/ - google::protobuf::Message* GetProtoMessageFromDescriptor(const std::string& msg_desc_, const std::string& msg_type_, std::string& error_s_); - - /** - * @brief Create message from proto descriptor set. - * - * Note: Ownership of the google::protobuf::Message pointer is passed to the caller. - * - * @param proto_desc_set_ Proto descriptor set. - * @param msg_type_ Type name. - * @param [out] error_s_ Error string. - * - * @return google message object or nullptr if generation failed (details see error_s_) - **/ - google::protobuf::Message* GetProtoMessageFromDescriptorSet(const google::protobuf::FileDescriptorSet& proto_desc_set_, const std::string& msg_type_, std::string& error_s_); - - /** - * @brief Returns the DescriptorPool member variable - **/ - google::protobuf::DescriptorPool* GetDescriptorPool(); - - /** - * @brief Create proto descriptor from proto file. - * - * @param proto_filename_ Proto file name. - * @param [out] file_desc_proto_ Type name. - * @param [out] error_s_ Error string. - * - * @return true if succeeded otherwise false (details see error_s_) - **/ - bool GetFileDescriptorFromFile(const std::string& proto_filename_, google::protobuf::FileDescriptorProto* file_desc_proto_, std::string& error_s_); - - /** - * @brief Create proto descriptor from proto string. - * - * @param proto_string_ Proto string. - * @param [out] file_desc_proto_ Type name. - * @param [out] error_s_ Error string. - * - * @return true if succeeded otherwise false (details see error_s_) - **/ - bool GetFileDescriptorFromString(const std::string& proto_string_, google::protobuf::FileDescriptorProto* file_desc_proto_, std::string& error_s_); - - bool GetServiceMessageDescFromType(const google::protobuf::ServiceDescriptor* service_desc_, const std::string& type_name_, std::string& type_desc_, std::string& error_s_); - - protected: - google::protobuf::DescriptorPool m_descriptor_pool; - google::protobuf::DynamicMessageFactory m_message_factory; - }; - - class ParserErrorCollector : public google::protobuf::io::ErrorCollector - { - public: - ParserErrorCollector() = default; - ~ParserErrorCollector() override = default; - - std::string Get() { return (m_ss.str()); } - - // Indicates that there was an error in the input at the given line and - // column numbers. The numbers are zero-based, so you may want to add - // 1 to each before printing them. - void AddError(int line_, int column_, const std::string& msg_) override - { - Add(line_, column_, "ERROR: " + msg_); - } - - // Indicates that there was a warning in the input at the given line and - // column numbers. The numbers are zero-based, so you may want to add - // 1 to each before printing them. - void AddWarning(int line_, int column_, const std::string& msg_) override - { - Add(line_, column_, "WARNING: " + msg_); - } - - private: - void Add(int line_, int column_, const std::string& msg_) - { - m_ss << line_ << ":" << column_ << " " << msg_ << std::endl; - } - - std::stringstream m_ss; - }; - - class DescriptorErrorCollector : public google::protobuf::DescriptorPool::ErrorCollector - { - public: - DescriptorErrorCollector() = default; - ~DescriptorErrorCollector() override {} - - std::string Get() { return (m_ss.str()); } - - void AddError( - const std::string& filename, // File name in which the error occurred. - const std::string& element_name, // Full name of the erroneous element. - const google::protobuf::Message* descriptor, // Descriptor of the erroneous element. - ErrorLocation location, // One of the location constants, above. - const std::string& message // Human-readable error message. - ) override - { - Add(filename, element_name, descriptor, location, "ERROR: " + message); - } - - void AddWarning( - const std::string& filename, // File name in which the error occurred. - const std::string& element_name, // Full name of the erroneous element. - const google::protobuf::Message* descriptor, // Descriptor of the erroneous element. - ErrorLocation location, // One of the location constants, above. - const std::string& message // Human-readable error message. - ) override - { - Add(filename, element_name, descriptor, location, "WARNING: " + message); - } - - private: - void Add( - const std::string& filename, - const std::string& element_name, - const google::protobuf::Message* /*descriptor*/, - ErrorLocation location, - const std::string& message) - { - m_ss << filename << " " << element_name << " " << location << " " << message << std::endl; - } - - std::stringstream m_ss; - }; - - inline google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromFile(const std::string& proto_filename_, const std::string& msg_type_, std::string& error_s_) - { - google::protobuf::FileDescriptorProto proto; - if (!GetFileDescriptorFromFile(proto_filename_, &proto, error_s_)) return (nullptr); - google::protobuf::FileDescriptorSet pset; - google::protobuf::FileDescriptorProto* pdesc = pset.add_file(); - pdesc->CopyFrom(proto); - return (GetProtoMessageFromDescriptorSet(pset, msg_type_, error_s_)); - } - - inline google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromString(const std::string& proto_string_, const std::string& msg_type_, std::string& error_s_) - { - google::protobuf::FileDescriptorProto proto; - if (!GetFileDescriptorFromString(proto_string_, &proto, error_s_)) return (nullptr); - google::protobuf::FileDescriptorSet pset; - google::protobuf::FileDescriptorProto* pdesc = pset.add_file(); - pdesc->CopyFrom(proto); - return (GetProtoMessageFromDescriptorSet(pset, msg_type_, error_s_)); - } - - inline google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromDescriptor(const google::protobuf::FileDescriptorProto& proto_desc_, const std::string& msg_type_, std::string& error_s_) - { - google::protobuf::FileDescriptorSet pset; - google::protobuf::FileDescriptorProto* pdesc = pset.add_file(); - pdesc->CopyFrom(proto_desc_); - return (GetProtoMessageFromDescriptorSet(pset, msg_type_, error_s_)); - } - - inline google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromDescriptor(const std::string& msg_desc_, const std::string& msg_type_, std::string& error_s_) - { - // create file descriptor set - google::protobuf::FileDescriptorSet pset; - if (!pset.ParseFromString(msg_desc_)) - { - error_s_ = "Cannot get file descriptor of message: " + msg_type_; - return (nullptr); - } - - // create message object - google::protobuf::Message* proto_msg = GetProtoMessageFromDescriptorSet(pset, msg_type_, error_s_); - if (proto_msg == nullptr) - { - return (nullptr); - } - - return (proto_msg); - } - - inline google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromDescriptorSet(const google::protobuf::FileDescriptorSet& proto_desc_set_, const std::string& msg_type_, std::string& error_s_) - { - // check if msg_type_ is available in descriptor pool - const google::protobuf::Descriptor* desc = m_descriptor_pool.FindMessageTypeByName(msg_type_); - if (desc != nullptr) - { - const google::protobuf::Message* prototype_msg = m_message_factory.GetPrototype(desc); - if (prototype_msg != nullptr) - { - // ownership passed to caller here ! - google::protobuf::Message* proto_msg = prototype_msg->New(); - if (proto_msg == nullptr) - { - error_s_ = "Failed in prototype_msg->New(); to create mutable message"; - return (nullptr); - } - return (proto_msg); - } - } - - // suppose you want to parse a message type with a specific type name. - DescriptorErrorCollector error_collector; - const google::protobuf::FileDescriptor* file_desc = nullptr; - for (auto it = 0; it < proto_desc_set_.file_size(); ++it) - { - file_desc = m_descriptor_pool.BuildFileCollectingErrors(proto_desc_set_.file(it), &error_collector); - if (file_desc == nullptr) - { - error_s_ = error_collector.Get(); - return (nullptr); - } - if ((file_desc->message_type_count() > 0) && - (file_desc->message_type(0)->name() == msg_type_)) - { - break; - } - } - if (file_desc == nullptr) - { - error_s_ = "Cannot get file descriptor of message: " + msg_type_; - return (nullptr); - } - const google::protobuf::Descriptor* message_desc = file_desc->FindMessageTypeByName(msg_type_); - if (message_desc == nullptr) - { - error_s_ = "Cannot get message descriptor of message: " + msg_type_; - return (nullptr); - } - - const google::protobuf::Message* prototype_msg = m_message_factory.GetPrototype(message_desc); - if (prototype_msg == nullptr) - { - error_s_ = "Cannot create prototype message from message descriptor"; - return (nullptr); - } - - // ownership passed to caller here ! - google::protobuf::Message* proto_msg = prototype_msg->New(); - if (proto_msg == nullptr) - { - error_s_ = "Failed in prototype_msg->New(); to create mutable message"; - return (nullptr); - } - return (proto_msg); - } - - inline google::protobuf::DescriptorPool* CProtoDynDecoder::GetDescriptorPool() - { - return &m_descriptor_pool; - } - - inline bool CProtoDynDecoder::GetFileDescriptorFromFile(const std::string& proto_filename_, google::protobuf::FileDescriptorProto* file_desc_proto_, std::string& error_s_) - { - std::ifstream fs(proto_filename_); - if (!fs.is_open()) - { - std::cout << "Cannot open .proto file: " << proto_filename_; - return (false); - } - std::stringstream ss; - ss << fs.rdbuf(); - - std::string proto_str = ss.str(); - - return (GetFileDescriptorFromString(proto_str, file_desc_proto_, error_s_)); - } - - inline bool CProtoDynDecoder::GetFileDescriptorFromString(const std::string& proto_string_, google::protobuf::FileDescriptorProto* file_desc_proto_, std::string& error_s_) - { - std::stringstream ss; - ss << proto_string_; - google::protobuf::io::IstreamInputStream proto_string_input_stream(&ss); - - google::protobuf::io::Tokenizer tokenizer(&proto_string_input_stream, nullptr); - google::protobuf::compiler::Parser parser; - ParserErrorCollector error_collector; - parser.RecordErrorsTo(&error_collector); - if (!parser.Parse(&tokenizer, file_desc_proto_)) - { - error_s_ = error_collector.Get(); - return (false); - } - - // here we walk around a bug in protocol buffers that - // |Parser::Parse| does not set name (.proto filename) in - // file_desc_proto. - if (!file_desc_proto_->has_name()) - { - file_desc_proto_->set_name("foo.proto"); - } - - return (true); - } - - inline bool CProtoDynDecoder::GetServiceMessageDescFromType(const google::protobuf::ServiceDescriptor* service_desc_, const std::string& type_name_, std::string& type_desc_, std::string& error_s_) - { - const google::protobuf::FileDescriptor* file_desc = service_desc_->file(); - if (file_desc == nullptr) return false; - - const std::string file_desc_s = file_desc->DebugString(); - google::protobuf::FileDescriptorProto file_desc_proto; - if (!GetFileDescriptorFromString(file_desc_s, &file_desc_proto, error_s_)) return false; - - google::protobuf::FileDescriptorSet pset; - google::protobuf::FileDescriptorProto* pdesc = pset.add_file(); - pdesc->CopyFrom(file_desc_proto); - - const std::shared_ptr req_msg(GetProtoMessageFromDescriptorSet(pset, type_name_, error_s_)); - if (!req_msg) return false; - - type_desc_ = pset.SerializeAsString(); - return true; - } - } -} diff --git a/ecal/core/include/ecal/msg/protobuf/ecal_proto_hlp.h b/ecal/core/include/ecal/msg/protobuf/ecal_proto_hlp.h deleted file mode 100644 index 8a5459ef18..0000000000 --- a/ecal/core/include/ecal/msg/protobuf/ecal_proto_hlp.h +++ /dev/null @@ -1,172 +0,0 @@ -/* ========================= eCAL LICENSE ================================= - * - * Copyright (C) 2016 - 2019 Continental Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ========================= eCAL LICENSE ================================= -*/ - -/** - * @file ecal_proto_hlp.h - * @brief protobuf message description handling -**/ - -#pragma once - -#include -#include -#include -#include - -// protobuf includes -#ifdef _MSC_VER -#pragma warning(push, 0) // disable proto warnings -#endif -#include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - -namespace eCAL -{ -namespace protobuf -{ - inline std::string CreateCompleteMessageName(const std::string& name_, const std::string& prefix_) - { - std::string message_name; - if (!prefix_.empty()) - { - message_name += prefix_; - message_name += '.'; - } - message_name += name_; - return message_name; - } - - inline std::string ExtractTopicName(const std::string& element_) - { - return element_.substr(0, element_.find('.')); - } - - inline bool HasFile(const google::protobuf::FileDescriptorSet& fset_, const std::string& fname_) - { - for (auto findex = 0; findex < fset_.file_size(); ++findex) - { - if (fset_.file(findex).name() == fname_) - { - return(true); - } - } - return(false); - } - - inline bool GetFileDescriptor(const google::protobuf::Descriptor* desc_, google::protobuf::FileDescriptorSet& fset_) - { - if (desc_ == nullptr) return(false); - const google::protobuf::FileDescriptor* fdesc = desc_->file(); - - for (auto dep = 0; dep < fdesc->dependency_count(); ++dep) - { - // iterate containing messages - const google::protobuf::FileDescriptor* sfdesc = fdesc->dependency(dep); - for (auto mtype = 0; mtype < sfdesc->message_type_count(); ++mtype) - { - const google::protobuf::Descriptor* desc = sfdesc->message_type(mtype); - GetFileDescriptor(desc, fset_); - } - - // containing enums ? - if (sfdesc->enum_type_count() > 0) - { - const google::protobuf::EnumDescriptor* edesc = sfdesc->enum_type(0); - const google::protobuf::FileDescriptor* efdesc = edesc->file(); - - if (!HasFile(fset_, efdesc->name())) - { - google::protobuf::FileDescriptorProto* epdesc = fset_.add_file(); - efdesc->CopyTo(epdesc); - } - } - - // containing services ? - if (sfdesc->service_count() > 0) - { - const google::protobuf::ServiceDescriptor* svdesc = sfdesc->service(0); - const google::protobuf::FileDescriptor* svfdesc = svdesc->file(); - - if (!HasFile(fset_, svfdesc->name())) - { - google::protobuf::FileDescriptorProto* svpdesc = fset_.add_file(); - svfdesc->CopyTo(svpdesc); - } - } - } - - if (HasFile(fset_, fdesc->name())) return(true); - - google::protobuf::FileDescriptorProto* pdesc = fset_.add_file(); - fdesc->CopyTo(pdesc); - for (auto field = 0; field < desc_->field_count(); ++field) - { - const google::protobuf::FieldDescriptor* fddesc = desc_->field(field); - const google::protobuf::Descriptor* desc = fddesc->message_type(); - GetFileDescriptor(desc, fset_); - } - - return(true); - } - - inline std::string GetProtoMessageDescription(const google::protobuf::Message& msg_) - { - const google::protobuf::Descriptor* desc = msg_.GetDescriptor(); - google::protobuf::FileDescriptorSet pset; - if (GetFileDescriptor(desc, pset)) - { - std::string desc_s = pset.SerializeAsString(); - return(desc_s); - } - return(""); - } - - inline std::string GetProtoMessageTypeName(const google::protobuf::Message& msg_) - { - return(std::string("proto:") + msg_.GetTypeName()); - } - - inline std::vector GetProtoMessageFieldNames(const std::vector& fields_) - { - std::vector names_vec; - std::transform(fields_.begin(), fields_.end(), std::back_inserter(names_vec), - [](const google::protobuf::FieldDescriptor* field) - { - return field->name(); - } - ); - return names_vec; - } - - inline std::vector GetProtoMessageFieldNames(const google::protobuf::Descriptor* descriptor) - { - std::vector names_vec; - auto count = descriptor->field_count(); - for (int i = 0; i < count; ++i) - { - const auto *field = descriptor->field(i); - names_vec.push_back(field->name()); - } - return names_vec; - } -} -} diff --git a/contrib/ecalproto/CMakeLists.txt b/ecal/msg/protobuf/CMakeLists.txt similarity index 51% rename from contrib/ecalproto/CMakeLists.txt rename to ecal/msg/protobuf/CMakeLists.txt index 04f1a1b9a6..63a400b160 100644 --- a/contrib/ecalproto/CMakeLists.txt +++ b/ecal/msg/protobuf/CMakeLists.txt @@ -20,7 +20,22 @@ find_package(Protobuf REQUIRED) project(proto) -set(ecal_protobuf_src +ecal_add_library(proto) +add_library(eCAL::proto ALIAS proto) + +target_sources(proto + PUBLIC + FILE_SET proto_headers + TYPE HEADERS + BASE_DIRS include + FILES + include/ecal/msg/protobuf/ecal_proto_decoder.h + include/ecal/msg/protobuf/ecal_proto_dyn.h + include/ecal/msg/protobuf/ecal_proto_hlp.h + include/ecal/msg/protobuf/ecal_proto_maximum_array_dimensions.h + include/ecal/msg/protobuf/ecal_proto_message_filter.h + include/ecal/msg/protobuf/ecal_proto_visitor.h + PRIVATE src/ecal_proto_decoder.cpp src/ecal_proto_dyn.cpp src/ecal_proto_maximum_array_dimensions.cpp @@ -28,32 +43,16 @@ set(ecal_protobuf_src src/ecal_proto_visitor.cpp ) -set(ecal_protobuf_header - include/ecal/protobuf/ecal_proto_decoder.h - include/ecal/protobuf/ecal_proto_dyn.h - include/ecal/protobuf/ecal_proto_hlp.h - include/ecal/protobuf/ecal_proto_maximum_array_dimensions.h - include/ecal/protobuf/ecal_proto_message_filter.h - include/ecal/protobuf/ecal_proto_visitor.h -) - -ecal_add_library(${PROJECT_NAME} ${ecal_protobuf_src} ${ecal_protobuf_header}) -add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $ -) - -target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf) - -target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) +target_link_libraries(proto PUBLIC protobuf::libprotobuf) -ecal_install_library(${PROJECT_NAME}) +target_compile_features(proto PUBLIC cxx_std_14) install( - FILES ${ecal_protobuf_header} - DESTINATION "${INSTALL_INCLUDE_DIR}/ecal/protobuf" - COMPONENT sdk + TARGETS proto + EXPORT eCALCoreTargets + ARCHIVE DESTINATION "${eCAL_install_archive_dir}" COMPONENT sdk + LIBRARY DESTINATION "${eCAL_install_lib_dir}" COMPONENT sdk + FILE_SET proto_headers COMPONENT sdk ) -set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER contrib) +set_property(TARGET proto PROPERTY FOLDER core) diff --git a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_decoder.h b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_decoder.h similarity index 100% rename from contrib/ecalproto/include/ecal/protobuf/ecal_proto_decoder.h rename to ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_decoder.h diff --git a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_dyn.h b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_dyn.h similarity index 96% rename from contrib/ecalproto/include/ecal/protobuf/ecal_proto_dyn.h rename to ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_dyn.h index 3d80ae9a0c..4fd32f3193 100644 --- a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_dyn.h +++ b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_dyn.h @@ -45,7 +45,7 @@ #pragma GCC diagnostic pop #endif -#include +#include namespace eCAL { @@ -168,9 +168,10 @@ namespace protobuf **/ static bool GetFileDescriptorFromString(const std::string& proto_string_, google::protobuf::FileDescriptorProto* file_desc_proto_, std::string& error_s_); + bool GetServiceMessageDescFromType(const google::protobuf::ServiceDescriptor* service_desc_, const std::string& type_name_, std::string& type_desc_, std::string& error_s_); protected: google::protobuf::DescriptorPool m_descriptor_pool; google::protobuf::DynamicMessageFactory m_message_factory; }; } -} +} \ No newline at end of file diff --git a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_hlp.h b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_hlp.h similarity index 99% rename from contrib/ecalproto/include/ecal/protobuf/ecal_proto_hlp.h rename to ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_hlp.h index f361950221..cda6fa6658 100644 --- a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_hlp.h +++ b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_hlp.h @@ -167,4 +167,4 @@ namespace protobuf return names_vec; } } -} +} \ No newline at end of file diff --git a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_maximum_array_dimensions.h b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_maximum_array_dimensions.h similarity index 96% rename from contrib/ecalproto/include/ecal/protobuf/ecal_proto_maximum_array_dimensions.h rename to ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_maximum_array_dimensions.h index bfc7d08990..83aac4dc33 100644 --- a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_maximum_array_dimensions.h +++ b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_maximum_array_dimensions.h @@ -17,7 +17,7 @@ * ========================= eCAL LICENSE ================================= */ -#include +#include #include #include diff --git a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_message_filter.h b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_message_filter.h similarity index 100% rename from contrib/ecalproto/include/ecal/protobuf/ecal_proto_message_filter.h rename to ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_message_filter.h diff --git a/contrib/ecalproto/include/ecal/protobuf/ecal_proto_visitor.h b/ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_visitor.h similarity index 100% rename from contrib/ecalproto/include/ecal/protobuf/ecal_proto_visitor.h rename to ecal/msg/protobuf/include/ecal/msg/protobuf/ecal_proto_visitor.h diff --git a/contrib/ecalproto/src/ecal_proto_decoder.cpp b/ecal/msg/protobuf/src/ecal_proto_decoder.cpp similarity index 98% rename from contrib/ecalproto/src/ecal_proto_decoder.cpp rename to ecal/msg/protobuf/src/ecal_proto_decoder.cpp index d5012e8c8e..2cc663d592 100644 --- a/contrib/ecalproto/src/ecal_proto_decoder.cpp +++ b/ecal/msg/protobuf/src/ecal_proto_decoder.cpp @@ -21,11 +21,11 @@ * @brief eCALMonitor proto message decoding class **/ -#include +#include -#include -#include -#include +#include +#include +#include #include diff --git a/contrib/ecalproto/src/ecal_proto_dyn.cpp b/ecal/msg/protobuf/src/ecal_proto_dyn.cpp similarity index 88% rename from contrib/ecalproto/src/ecal_proto_dyn.cpp rename to ecal/msg/protobuf/src/ecal_proto_dyn.cpp index 0e53dec6fe..66c8ac4c3e 100644 --- a/contrib/ecalproto/src/ecal_proto_dyn.cpp +++ b/ecal/msg/protobuf/src/ecal_proto_dyn.cpp @@ -21,7 +21,7 @@ * dynamic protobuf message decoder **/ -#include +#include #include #include @@ -36,15 +36,15 @@ namespace protobuf class ParserErrorCollector : public google::protobuf::io::ErrorCollector { public: - ParserErrorCollector() {} - ~ParserErrorCollector() {} + ParserErrorCollector() = default; + ~ParserErrorCollector() override = default; std::string Get() { return(m_ss.str()); } // Indicates that there was an error in the input at the given line and // column numbers. The numbers are zero-based, so you may want to add // 1 to each before printing them. - void AddError(int line_, int column_, const std::string& msg_) + void AddError(int line_, int column_, const std::string& msg_) override { Add(line_, column_, "ERROR: " + msg_); } @@ -52,7 +52,7 @@ namespace protobuf // Indicates that there was a warning in the input at the given line and // column numbers. The numbers are zero-based, so you may want to add // 1 to each before printing them. - void AddWarning(int line_, int column_, const std::string& msg_) + void AddWarning(int line_, int column_, const std::string& msg_) override { Add(line_, column_, "WARNING: " + msg_); } @@ -69,8 +69,8 @@ namespace protobuf class DescriptorErrorCollector : public google::protobuf::DescriptorPool::ErrorCollector { public: - DescriptorErrorCollector() {} - ~DescriptorErrorCollector() {} + DescriptorErrorCollector() = default; + ~DescriptorErrorCollector() override {} std::string Get() { return(m_ss.str()); } @@ -80,7 +80,7 @@ namespace protobuf const google::protobuf::Message* descriptor, // Descriptor of the erroneous element. ErrorLocation location, // One of the location constants, above. const std::string& message // Human-readable error message. - ) + ) override { Add(filename, element_name, descriptor, location, "ERROR: " + message); } @@ -91,7 +91,7 @@ namespace protobuf const google::protobuf::Message* descriptor, // Descriptor of the erroneous element. ErrorLocation location, // One of the location constants, above. const std::string& message // Human-readable error message. - ) + ) override { Add(filename, element_name, descriptor, location, "WARNING: " + message); } @@ -151,7 +151,7 @@ namespace protobuf // create message object google::protobuf::Message* proto_msg = GetProtoMessageFromDescriptorSet(pset, msg_type_, error_s_); - if (!proto_msg) + if (proto_msg == nullptr) { return(nullptr); } @@ -232,10 +232,6 @@ namespace protobuf bool CProtoDynDecoder::GetFileDescriptorFromFile(const std::string& proto_filename_, google::protobuf::FileDescriptorProto* file_desc_proto_, std::string& error_s_) { - using namespace google::protobuf; - using namespace google::protobuf::io; - using namespace google::protobuf::compiler; - std::ifstream fs(proto_filename_); if (!fs.is_open()) { @@ -280,5 +276,25 @@ namespace protobuf return(true); } + + bool CProtoDynDecoder::GetServiceMessageDescFromType(const google::protobuf::ServiceDescriptor* service_desc_, const std::string& type_name_, std::string& type_desc_, std::string& error_s_) + { + const google::protobuf::FileDescriptor* file_desc = service_desc_->file(); + if (file_desc == nullptr) return false; + + const std::string file_desc_s = file_desc->DebugString(); + google::protobuf::FileDescriptorProto file_desc_proto; + if (!GetFileDescriptorFromString(file_desc_s, &file_desc_proto, error_s_)) return false; + + google::protobuf::FileDescriptorSet pset; + google::protobuf::FileDescriptorProto* pdesc = pset.add_file(); + pdesc->CopyFrom(file_desc_proto); + + const std::shared_ptr req_msg(GetProtoMessageFromDescriptorSet(pset, type_name_, error_s_)); + if (!req_msg) return false; + + type_desc_ = pset.SerializeAsString(); + return true; + } } } diff --git a/contrib/ecalproto/src/ecal_proto_maximum_array_dimensions.cpp b/ecal/msg/protobuf/src/ecal_proto_maximum_array_dimensions.cpp similarity index 93% rename from contrib/ecalproto/src/ecal_proto_maximum_array_dimensions.cpp rename to ecal/msg/protobuf/src/ecal_proto_maximum_array_dimensions.cpp index 37b81a22f8..5a1069c68e 100644 --- a/contrib/ecalproto/src/ecal_proto_maximum_array_dimensions.cpp +++ b/ecal/msg/protobuf/src/ecal_proto_maximum_array_dimensions.cpp @@ -17,9 +17,9 @@ * ========================= eCAL LICENSE ================================= */ -#include +#include -#include +#include namespace eCAL { diff --git a/contrib/ecalproto/src/ecal_proto_message_filter.cpp b/ecal/msg/protobuf/src/ecal_proto_message_filter.cpp similarity index 99% rename from contrib/ecalproto/src/ecal_proto_message_filter.cpp rename to ecal/msg/protobuf/src/ecal_proto_message_filter.cpp index ff46e91cb1..0ae9286c3d 100644 --- a/contrib/ecalproto/src/ecal_proto_message_filter.cpp +++ b/ecal/msg/protobuf/src/ecal_proto_message_filter.cpp @@ -17,7 +17,7 @@ * ========================= eCAL LICENSE ================================= */ -#include +#include #include #include diff --git a/contrib/ecalproto/src/ecal_proto_visitor.cpp b/ecal/msg/protobuf/src/ecal_proto_visitor.cpp similarity index 100% rename from contrib/ecalproto/src/ecal_proto_visitor.cpp rename to ecal/msg/protobuf/src/ecal_proto_visitor.cpp diff --git a/ecal/samples/cpp/orchestration/component1/CMakeLists.txt b/ecal/samples/cpp/orchestration/component1/CMakeLists.txt index 9591857a78..bb9b05b80b 100644 --- a/ecal/samples/cpp/orchestration/component1/CMakeLists.txt +++ b/ecal/samples/cpp/orchestration/component1/CMakeLists.txt @@ -37,8 +37,8 @@ ecal_add_sample(${PROJECT_NAME} ${component1_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${component1_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/orchestration/component2/CMakeLists.txt b/ecal/samples/cpp/orchestration/component2/CMakeLists.txt index a6e63e2e33..9f10eb899e 100644 --- a/ecal/samples/cpp/orchestration/component2/CMakeLists.txt +++ b/ecal/samples/cpp/orchestration/component2/CMakeLists.txt @@ -37,8 +37,8 @@ ecal_add_sample(${PROJECT_NAME} ${component2_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${component2_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/orchestration/orchestrator/CMakeLists.txt b/ecal/samples/cpp/orchestration/orchestrator/CMakeLists.txt index 8780f2d45b..0a6868e12f 100644 --- a/ecal/samples/cpp/orchestration/orchestrator/CMakeLists.txt +++ b/ecal/samples/cpp/orchestration/orchestrator/CMakeLists.txt @@ -36,8 +36,8 @@ ecal_add_sample(${PROJECT_NAME} ${orchestrator_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${orchestrator_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/person_events_rec/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/person_events_rec/CMakeLists.txt index 226946d9a3..e5088a2ea6 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_events_rec/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/person_events_rec/CMakeLists.txt @@ -38,8 +38,8 @@ ecal_add_sample(${PROJECT_NAME} ${person_events_rec_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${person_events_rec_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/person_events_snd/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/person_events_snd/CMakeLists.txt index 58099575cc..f1b138d6fe 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_events_snd/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/person_events_snd/CMakeLists.txt @@ -38,8 +38,8 @@ ecal_add_sample(${PROJECT_NAME} ${person_events_snd_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${person_events_snd_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/person_loopback/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/person_loopback/CMakeLists.txt index e56cb98dd0..0dafa50874 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_loopback/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/person_loopback/CMakeLists.txt @@ -38,8 +38,8 @@ ecal_add_sample(${PROJECT_NAME} ${person_loopback_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${person_loopback_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/person_rec/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/person_rec/CMakeLists.txt index f933a3336f..8925dd042b 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_rec/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/person_rec/CMakeLists.txt @@ -38,8 +38,8 @@ ecal_add_sample(${PROJECT_NAME} ${person_rec_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${person_rec_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/person_snd/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/person_snd/CMakeLists.txt index 48ca976d5a..8cbef0c8c5 100644 --- a/ecal/samples/cpp/pubsub/protobuf/person_snd/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/person_snd/CMakeLists.txt @@ -38,8 +38,8 @@ ecal_add_sample(${PROJECT_NAME} ${person_snd_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${person_snd_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/CMakeLists.txt index 82b0592326..ee46944b85 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_json_rec/CMakeLists.txt @@ -23,6 +23,7 @@ set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) project(proto_dyn_json_rec) find_package(eCAL REQUIRED) +find_package(Protobuf REQUIRED) set(proto_dyn_json_rec_src src/proto_dyn_json_rec.cpp @@ -30,10 +31,11 @@ set(proto_dyn_json_rec_src ecal_add_sample(${PROJECT_NAME} ${proto_dyn_json_rec_src}) -target_link_libraries(${PROJECT_NAME} eCAL::core) +target_link_libraries(${PROJECT_NAME} + PRIVATE + eCAL::core_protobuf +) -find_package(Protobuf REQUIRED) -target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) ecal_install_sample(${PROJECT_NAME}) diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/CMakeLists.txt index a92a380ff1..0bff96455d 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_rec/CMakeLists.txt @@ -33,9 +33,10 @@ ecal_add_sample(${PROJECT_NAME} ${proto_dyn_rec_src}) target_include_directories(${PROJECT_NAME} PRIVATE .) -target_link_libraries(${PROJECT_NAME} eCAL::core) - -target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf) +target_link_libraries(${PROJECT_NAME} + PRIVATE + eCAL::core_protobuf +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/CMakeLists.txt b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/CMakeLists.txt index b40e685040..366f4fb149 100644 --- a/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/CMakeLists.txt +++ b/ecal/samples/cpp/pubsub/protobuf/proto_dyn_snd/CMakeLists.txt @@ -38,8 +38,8 @@ ecal_add_sample(${PROJECT_NAME} ${proto_dyn_snd_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${proto_dyn_snd_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/services/math_client/CMakeLists.txt b/ecal/samples/cpp/services/math_client/CMakeLists.txt index 2f261e16dc..701521d23f 100644 --- a/ecal/samples/cpp/services/math_client/CMakeLists.txt +++ b/ecal/samples/cpp/services/math_client/CMakeLists.txt @@ -37,8 +37,8 @@ ecal_add_sample(${PROJECT_NAME} ${math_client_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${math_client_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/services/math_server/CMakeLists.txt b/ecal/samples/cpp/services/math_server/CMakeLists.txt index c0d0b97dbb..27ba5601de 100644 --- a/ecal/samples/cpp/services/math_server/CMakeLists.txt +++ b/ecal/samples/cpp/services/math_server/CMakeLists.txt @@ -37,8 +37,8 @@ ecal_add_sample(${PROJECT_NAME} ${math_server_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${math_server_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/services/ping_client/CMakeLists.txt b/ecal/samples/cpp/services/ping_client/CMakeLists.txt index e9453973ef..4ba240425e 100644 --- a/ecal/samples/cpp/services/ping_client/CMakeLists.txt +++ b/ecal/samples/cpp/services/ping_client/CMakeLists.txt @@ -37,8 +37,8 @@ ecal_add_sample(${PROJECT_NAME} ${ping_client_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${ping_client_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/services/ping_client_dyn/CMakeLists.txt b/ecal/samples/cpp/services/ping_client_dyn/CMakeLists.txt index 4482f70b4b..274ef5233e 100644 --- a/ecal/samples/cpp/services/ping_client_dyn/CMakeLists.txt +++ b/ecal/samples/cpp/services/ping_client_dyn/CMakeLists.txt @@ -33,8 +33,8 @@ set(ping_client_dyn_src ecal_add_sample(${PROJECT_NAME} ${ping_client_dyn_src}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/samples/cpp/services/ping_server/CMakeLists.txt b/ecal/samples/cpp/services/ping_server/CMakeLists.txt index 591c13563b..4f58c1eb28 100644 --- a/ecal/samples/cpp/services/ping_server/CMakeLists.txt +++ b/ecal/samples/cpp/services/ping_server/CMakeLists.txt @@ -37,8 +37,8 @@ ecal_add_sample(${PROJECT_NAME} ${ping_server_src}) PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${ping_server_proto}) target_link_libraries(${PROJECT_NAME} - eCAL::core - protobuf::libprotobuf + PRIVATE + eCAL::core_protobuf ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/tests/cpp/clientserver_proto_test/CMakeLists.txt b/ecal/tests/cpp/clientserver_proto_test/CMakeLists.txt index 3e9c398386..96e06b3801 100644 --- a/ecal/tests/cpp/clientserver_proto_test/CMakeLists.txt +++ b/ecal/tests/cpp/clientserver_proto_test/CMakeLists.txt @@ -39,9 +39,9 @@ PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${c target_link_libraries(${PROJECT_NAME} PRIVATE - eCAL::core - protobuf::libprotobuf - Threads::Threads) + eCAL::core_protobuf + Threads::Threads +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/ecal/tests/cpp/pubsub_proto_test/CMakeLists.txt b/ecal/tests/cpp/pubsub_proto_test/CMakeLists.txt index 93afdae789..cc0c9af257 100644 --- a/ecal/tests/cpp/pubsub_proto_test/CMakeLists.txt +++ b/ecal/tests/cpp/pubsub_proto_test/CMakeLists.txt @@ -42,9 +42,10 @@ PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${p target_link_libraries(${PROJECT_NAME} PRIVATE - eCAL::core - protobuf::libprotobuf - Threads::Threads) + eCAL::core_protobuf + Threads::Threads +) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/samples/cpp/services/ecalplayer_client/CMakeLists.txt b/samples/cpp/services/ecalplayer_client/CMakeLists.txt index df6e14d0e9..c025dbe04b 100644 --- a/samples/cpp/services/ecalplayer_client/CMakeLists.txt +++ b/samples/cpp/services/ecalplayer_client/CMakeLists.txt @@ -31,7 +31,8 @@ set(ecalplayer_client_src ecal_add_sample(${PROJECT_NAME} ${ecalplayer_client_src}) target_link_libraries(${PROJECT_NAME} - eCAL::core + PRIVATE + eCAL::core_protobuf eCAL::app_pb ) diff --git a/samples/cpp/services/ecalplayer_gui_client/CMakeLists.txt b/samples/cpp/services/ecalplayer_gui_client/CMakeLists.txt index b5bf9141af..6c459c49e9 100644 --- a/samples/cpp/services/ecalplayer_gui_client/CMakeLists.txt +++ b/samples/cpp/services/ecalplayer_gui_client/CMakeLists.txt @@ -79,7 +79,8 @@ endif() target_include_directories(${PROJECT_NAME} PRIVATE src) target_link_libraries(${PROJECT_NAME} - eCAL::core + PRIVATE + eCAL::core_protobuf eCAL::app_pb Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets diff --git a/samples/cpp/services/ecalsys_client/CMakeLists.txt b/samples/cpp/services/ecalsys_client/CMakeLists.txt index 4b2ffd5733..83d653e71a 100644 --- a/samples/cpp/services/ecalsys_client/CMakeLists.txt +++ b/samples/cpp/services/ecalsys_client/CMakeLists.txt @@ -33,8 +33,10 @@ ecal_add_sample(${PROJECT_NAME} ${ecalsys_client_src}) target_include_directories(${PROJECT_NAME} PRIVATE .) target_link_libraries(${PROJECT_NAME} - eCAL::core - eCAL::app_pb) + PRIVATE + eCAL::core_protobuf + eCAL::app_pb +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/samples/cpp/services/player_stepper/CMakeLists.txt b/samples/cpp/services/player_stepper/CMakeLists.txt index 5fae1cbb46..ac8e6ea463 100644 --- a/samples/cpp/services/player_stepper/CMakeLists.txt +++ b/samples/cpp/services/player_stepper/CMakeLists.txt @@ -32,7 +32,13 @@ target_include_directories(${PROJECT_NAME} target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:PCRE_STATIC;_UNICODE>) -target_link_libraries(${PROJECT_NAME} eCAL::core eCAL::app_pb tclap::tclap) +target_link_libraries(${PROJECT_NAME} + PRIVATE + eCAL::core_protobuf + eCAL::app_pb + tclap::tclap +) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) ecal_install_sample(${PROJECT_NAME}) diff --git a/samples/cpp/services/rec_client_service_cli/CMakeLists.txt b/samples/cpp/services/rec_client_service_cli/CMakeLists.txt index f2bda24448..ac8d8f832d 100644 --- a/samples/cpp/services/rec_client_service_cli/CMakeLists.txt +++ b/samples/cpp/services/rec_client_service_cli/CMakeLists.txt @@ -33,8 +33,10 @@ ecal_add_sample(${PROJECT_NAME} ${ecalrecorder_client_src}) target_include_directories(${PROJECT_NAME} PRIVATE .) target_link_libraries(${PROJECT_NAME} - eCAL::core - eCAL::app_pb) + PRIVATE + eCAL::core_protobuf + eCAL::app_pb +) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/samples/cpp/services/rec_client_service_gui/CMakeLists.txt b/samples/cpp/services/rec_client_service_gui/CMakeLists.txt index c68c8d43d9..bdeb9ae1a5 100644 --- a/samples/cpp/services/rec_client_service_gui/CMakeLists.txt +++ b/samples/cpp/services/rec_client_service_gui/CMakeLists.txt @@ -78,7 +78,8 @@ endif(WIN32) target_include_directories(${PROJECT_NAME} PRIVATE src) target_link_libraries(${PROJECT_NAME} - eCAL::core + PRIVATE + eCAL::core_protobuf eCAL::app_pb Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets diff --git a/samples/cpp/services/rec_server_service_gui/CMakeLists.txt b/samples/cpp/services/rec_server_service_gui/CMakeLists.txt index 47b5604ca4..014fffbd1e 100644 --- a/samples/cpp/services/rec_server_service_gui/CMakeLists.txt +++ b/samples/cpp/services/rec_server_service_gui/CMakeLists.txt @@ -81,7 +81,8 @@ ENDIF(MSVC) target_include_directories(${PROJECT_NAME} PRIVATE src) target_link_libraries(${PROJECT_NAME} - eCAL::core + PRIVATE + eCAL::core_protobuf eCAL::core_pb eCAL::app_pb Qt${QT_VERSION_MAJOR}::Core diff --git a/tests/contrib/ecalproto/dynproto_test/src/dynproto_test.cpp b/tests/contrib/ecalproto/dynproto_test/src/dynproto_test.cpp index f9aa60e160..3db577c437 100644 --- a/tests/contrib/ecalproto/dynproto_test/src/dynproto_test.cpp +++ b/tests/contrib/ecalproto/dynproto_test/src/dynproto_test.cpp @@ -17,7 +17,7 @@ * ========================= eCAL LICENSE ================================= */ -#include +#include #include diff --git a/tests/contrib/ecalproto/ecal_proto_test/src/test_filters.cpp b/tests/contrib/ecalproto/ecal_proto_test/src/test_filters.cpp index f430588e39..2d4aaef555 100644 --- a/tests/contrib/ecalproto/ecal_proto_test/src/test_filters.cpp +++ b/tests/contrib/ecalproto/ecal_proto_test/src/test_filters.cpp @@ -23,7 +23,7 @@ #include -#include "ecal/protobuf/ecal_proto_message_filter.h" +#include "ecal/msg/protobuf/ecal_proto_message_filter.h" #include "gtest/gtest.h" From f1988303e58c5e2e77497614d616b44e5703817f Mon Sep 17 00:00:00 2001 From: KerstinKeller Date: Wed, 17 Apr 2024 09:52:49 +0200 Subject: [PATCH 2/3] [dependencies] ensure Protobuf 3.26 compatibility. (#1537) --- .github/workflows/build-macos.yml | 4 +- .../msg/protobuf/dynamic_json_subscriber.h | 5 ++ ecal/msg/protobuf/src/ecal_proto_dyn.cpp | 86 ++++++++++++++++++- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 2c3fd68b07..15c62caaa4 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -25,7 +25,7 @@ jobs: target: 'desktop' - name: Install Dependencies - run: brew install ninja doxygen graphviz protobuf@21 hdf5@1.10 pkg-config + run: brew install ninja doxygen graphviz protobuf hdf5@1.10 pkg-config - name: Install Cap’n Proto run: | @@ -86,7 +86,7 @@ jobs: -DECAL_THIRDPARTY_BUILD_QWT=ON \ -DECAL_THIRDPARTY_BUILD_YAML-CPP=ON \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="/usr/local/opt/hdf5@1.10:/usr/local/opt/protobuf@21" \ + -DCMAKE_PREFIX_PATH=/usr/local/opt/hdf5@1.10 \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON \ -DPython_FIND_STRATEGY=LOCATION \ diff --git a/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h b/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h index 38783cfeff..bf6a5305a1 100644 --- a/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h +++ b/ecal/core/include/ecal/msg/protobuf/dynamic_json_subscriber.h @@ -41,6 +41,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #endif +#include #include #include #include @@ -244,7 +245,11 @@ namespace eCAL { google::protobuf::util::JsonOptions options; +#if GOOGLE_PROTOBUF_VERSION >= 5026000 + options.always_print_fields_with_no_presence = true; +#else options.always_print_primitive_fields = true; +#endif std::string binary_input; binary_input.assign(static_cast(data_->buf), static_cast(data_->size)); diff --git a/ecal/msg/protobuf/src/ecal_proto_dyn.cpp b/ecal/msg/protobuf/src/ecal_proto_dyn.cpp index 66c8ac4c3e..6e29395fce 100644 --- a/ecal/msg/protobuf/src/ecal_proto_dyn.cpp +++ b/ecal/msg/protobuf/src/ecal_proto_dyn.cpp @@ -28,11 +28,94 @@ #include #include +#include + namespace eCAL { namespace protobuf { +#if GOOGLE_PROTOBUF_VERSION >= 5026000 + class ParserErrorCollector : public google::protobuf::io::ErrorCollector + { + public: + ParserErrorCollector() = default; + ~ParserErrorCollector() override = default; + + std::string Get() { return(m_ss.str()); } + + // Indicates that there was an error in the input at the given line and + // column numbers. The numbers are zero-based, so you may want to add + // 1 to each before printing them. + void RecordError(int line_, + google::protobuf::io::ColumnNumber column_, + absl::string_view message_) override + { + Add(line_, column_, "ERROR", message_); + } + + // Indicates that there was a warning in the input at the given line and + // column numbers. The numbers are zero-based, so you may want to add + // 1 to each before printing them. + void RecordWarning(int line_, + google::protobuf::io::ColumnNumber column_, + absl::string_view message_) override + { + Add(line_, column_, "WARNING: ", message_); + } + + private: + void Add(int line_, google::protobuf::io::ColumnNumber column_, const std::string& type_, absl::string_view message_) + { + m_ss << line_ << ":" << column_ << " " << type_ << ": " << message_ << std::endl; + } + + std::stringstream m_ss; +}; + + class DescriptorErrorCollector : public google::protobuf::DescriptorPool::ErrorCollector + { + public: + DescriptorErrorCollector() = default; + ~DescriptorErrorCollector() override {} + + std::string Get() { return(m_ss.str()); } + + void RecordError(absl::string_view filename, + absl::string_view element_name, + const google::protobuf::Message* descriptor, + ErrorLocation location, + absl::string_view message) override + { + Add(filename, element_name, descriptor, location, "ERROR", message); + } + + void RecordWarning(absl::string_view filename, + absl::string_view element_name, + const google::protobuf::Message* descriptor, + ErrorLocation location, + absl::string_view message) override + { + Add(filename, element_name, descriptor, location, "WARNING", message); + } + + private: + void Add( + absl::string_view filename, + absl::string_view element_name, + const google::protobuf::Message* /*descriptor*/, + ErrorLocation location, + const std::string& type, + absl::string_view message + ) + { + m_ss << filename << " " << element_name << " " << location << " " << type << ": " << message << std::endl; + } + + std::stringstream m_ss; + }; + +#else class ParserErrorCollector : public google::protobuf::io::ErrorCollector { public: @@ -70,7 +153,7 @@ namespace protobuf { public: DescriptorErrorCollector() = default; - ~DescriptorErrorCollector() override {} + ~DescriptorErrorCollector() override = default; std::string Get() { return(m_ss.str()); } @@ -110,6 +193,7 @@ namespace protobuf std::stringstream m_ss; }; +#endif google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromFile(const std::string& proto_filename_, const std::string& msg_type_, std::string& error_s_) { From 09f56b32b32370c2809b7c6921a85fa8b7c7a400 Mon Sep 17 00:00:00 2001 From: KerstinKeller Date: Wed, 17 Apr 2024 16:35:39 +0200 Subject: [PATCH 3/3] [doc] downgrade Sphinx to < 7.3 (#1541) --- doc/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/requirements.txt b/doc/requirements.txt index de78d538e4..424039e7fa 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,5 @@ wheel +sphinx<7.3 sphinx-book-theme==1.1.2 sphinx-tabs==3.4.5 PyGithub