[core] protobuf service client to v6#1981
Conversation
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
| { | ||
| public: | ||
| // Constructors | ||
| CClientInstance(eCAL::CClientInstance&& base_instance_) noexcept |
There was a problem hiding this comment.
warning: rvalue reference parameter 'base_instance_' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
CClientInstance(eCAL::CClientInstance&& base_instance_) noexcept
^
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/typed_response.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/typed_response.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/samples/services/math_client/src/math_client.cpp
Outdated
Show resolved
Hide resolved
… means all host in legacy logic)
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_typed_response.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_typed_response.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/samples/services/ping_client/src/ping_client.cpp
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_response_parser.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_typed_response.h
Outdated
Show resolved
Hide resolved
… separate unit msg/protobuf/client_protobuf_utils.h
|
|
||
| #pragma once | ||
|
|
||
| #include <ecal/service/client.h> |
There was a problem hiding this comment.
warning: 'ecal/service/client.h' file not found [clang-diagnostic-error]
#include <ecal/service/client.h>
^|
|
||
| ServiceMethodInformationSetT method_information_set; | ||
| CProtoDynDecoder dyn_decoder; | ||
| std::string error_s; |
There was a problem hiding this comment.
warning: variable 'error_s' is not initialized [cppcoreguidelines-init-variables]
| std::string error_s; | |
| std::string error_s = 0; |
| const std::string& request_type_name = method_descriptor->input_type()->name(); | ||
| const std::string& response_type_name = method_descriptor->output_type()->name(); | ||
|
|
||
| std::string request_type_descriptor; |
There was a problem hiding this comment.
warning: variable 'request_type_descriptor' is not initialized [cppcoreguidelines-init-variables]
| std::string request_type_descriptor; | |
| std::string request_type_descriptor = 0; |
| const std::string& response_type_name = method_descriptor->output_type()->name(); | ||
|
|
||
| std::string request_type_descriptor; | ||
| std::string response_type_descriptor; |
There was a problem hiding this comment.
warning: variable 'response_type_descriptor' is not initialized [cppcoreguidelines-init-variables]
| std::string response_type_descriptor; | |
| std::string response_type_descriptor = 0; |
| static eCAL::rec::Error GetRemoteConfig(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerConfig& config_output); | ||
|
|
||
| static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service | ||
| static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service |
There was a problem hiding this comment.
warning: function 'eCAL::rec_cli::command::Command::CallRemoteEcalrecService' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service
^Additional context
app/rec/rec_server_cli/src/commands/command.cpp:75: the definition seen here
eCAL::rec::Error Command::CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalrec_service
^app/rec/rec_server_cli/src/commands/command.h:63: differing parameters are named here: ('remote_ecalsys_service'), in definition: ('remote_ecalrec_service')
static eCAL::rec::Error CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service
^| // Rec Sever instance and rec_server_service. We will only use one of those, depending on the remote-control setting | ||
| std::shared_ptr<eCAL::rec_server::RecServer> rec_server_instance; | ||
| std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>> remote_rec_server_service; | ||
| std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>> remote_rec_server_service; |
There was a problem hiding this comment.
warning: variable 'remote_rec_server_service' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>> remote_rec_server_service;
^|
|
||
| eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component1("component1"); | ||
| eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component2("component2"); | ||
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component1("component1"); |
There was a problem hiding this comment.
warning: variable 'component1' of type 'eCAL::protobuf::CServiceClientTypedResponseorchestrator::ComponentService' can be declared 'const' [misc-const-correctness]
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component1("component1"); | |
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> const component1("component1"); |
| eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component1("component1"); | ||
| eCAL::protobuf::CServiceClient<orchestrator::ComponentService> component2("component2"); | ||
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component1("component1"); | ||
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component2("component2"); |
There was a problem hiding this comment.
warning: variable 'component2' of type 'eCAL::protobuf::CServiceClientTypedResponseorchestrator::ComponentService' can be declared 'const' [misc-const-correctness]
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> component2("component2"); | |
| eCAL::protobuf::CServiceClientTypedResponse<orchestrator::ComponentService> const component2("component2"); |
| // create player service client | ||
| eCAL::protobuf::CServiceClient<eCAL::pb::play::EcalPlayService> player_service; | ||
| player_service.AddResponseCallback(OnPlayerResponse); | ||
| eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::play::EcalPlayService> player_service; |
There was a problem hiding this comment.
warning: variable 'player_service' of type 'eCAL::protobuf::CServiceClientUntypedCallbackeCAL::pb::play::EcalPlayService' can be declared 'const' [misc-const-correctness]
| eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::play::EcalPlayService> player_service; | |
| eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::play::EcalPlayService> const player_service; |
| { | ||
| public: | ||
| using CServiceClientBase<T>::CServiceClientBase; | ||
| virtual ~CServiceClientCallbackBase() override = default; |
There was a problem hiding this comment.
warning: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
| virtual ~CServiceClientCallbackBase() override = default; | |
| ; |
|
|
||
| #pragma once | ||
|
|
||
| #include <ecal/service/types.h> |
There was a problem hiding this comment.
warning: 'ecal/service/types.h' file not found [clang-diagnostic-error]
#include <ecal/service/types.h>
^| * @tparam ResponseT The expected protobuf response type. | ||
| */ | ||
| template <typename ResponseT> | ||
| struct TMsgServiceResponse |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: server_id, service_method_information, error_msg [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:50:
- SServiceId server_id; //!< Identifier of the server that executed the call
- SServiceMethodInformation service_method_information; //!< Information about the called method
+ SServiceId server_id{}; //!< Identifier of the server that executed the call
+ SServiceMethodInformation service_method_information{}; //!< Information about the called methodserialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:54:
- std::string error_msg; //!< Error message if the call failed
+ std::string error_msg{}; //!< Error message if the call failed| * This class will serve as the parent for the typed and untyped variants. | ||
| */ | ||
| template <typename T> | ||
| class CServiceClientResponseBase : public CServiceClientBase<T> |
There was a problem hiding this comment.
warning: class 'CServiceClientResponseBase' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
>
^| { | ||
| public: | ||
| using CServiceClientBase<T>::CServiceClientBase; // Inherit constructors | ||
| virtual ~CServiceClientResponseBase() override = default; |
There was a problem hiding this comment.
warning: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
| virtual ~CServiceClientResponseBase() override = default; | |
| s |
ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp
Outdated
Show resolved
Hide resolved
ecal/samples/cpp/orchestration/orchestrator/src/orchestrator.cpp
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Show resolved
Hide resolved
| { | ||
| public: | ||
| // Constructors | ||
| CClientInstanceTyped(eCAL::CClientInstance&& base_instance_) noexcept |
There was a problem hiding this comment.
warning: rvalue reference parameter 'base_instance_' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
CClientInstanceTyped(eCAL::CClientInstance&& base_instance_) noexcept
^| { | ||
| } | ||
|
|
||
| CClientInstanceTyped(const SEntityId& entity_id_, const std::shared_ptr<eCAL::CServiceClientImpl>& service_client_impl_) |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
CClientInstanceTyped(const SEntityId& entity_id_, const std::shared_ptr<eCAL::CServiceClientImpl>& service_client_impl_)
^| * @tparam ResponseT The expected protobuf response type. | ||
| */ | ||
| template <typename ResponseT> | ||
| struct TMsgServiceResponse |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: server_id, service_method_information, error_msg [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:50:
- SServiceId server_id; //!< Identifier of the server that executed the call
- SServiceMethodInformation service_method_information; //!< Information about the called method
+ SServiceId server_id{}; //!< Identifier of the server that executed the call
+ SServiceMethodInformation service_method_information{}; //!< Information about the called methodserialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:54:
- std::string error_msg; //!< Error message if the call failed
+ std::string error_msg{}; //!< Error message if the call failed|
Apps and service samples tested in vm environment on windows and several ubuntu machines - working as expected. |
|
Danke 🫶 |
| } | ||
|
|
||
| bool CPublisherImpl::SetAttribute(const std::string& /* attr_name_ */_, const std::string& /* attr_value_ */) | ||
| bool CPublisherImpl::SetAttribute(const std::string& /* attr_name_ */, const std::string& /* attr_value_ */) |
There was a problem hiding this comment.
warning: method 'SetAttribute' can be made const [readability-make-member-function-const]
ecal/core/src/pubsub/ecal_publisher_impl.h:91:
- bool SetAttribute(const std::string& attr_name_, const std::string& attr_value_);
+ bool SetAttribute(const std::string& attr_name_, const std::string& attr_value_) const;| bool CPublisherImpl::SetAttribute(const std::string& /* attr_name_ */, const std::string& /* attr_value_ */) | |
| bool CPublisherImpl::SetAttribute(const std::string& /* attr_name_ */, const std::string& /* attr_value_ */) const |
| * ========================= eCAL LICENSE ================================= | ||
| */ | ||
|
|
||
| #include <ecal/ecal.h> |
There was a problem hiding this comment.
warning: 'ecal/ecal.h' file not found [clang-diagnostic-error]
#include <ecal/ecal.h>
^|
|
||
| #include "math_service_impl.h" | ||
|
|
||
| enum { |
There was a problem hiding this comment.
warning: enum '(unnamed enum at /github/workspace/serialization/protobuf/tests/clientserver_proto_test/src/clientserver_instances_typed_test.cpp:36:1)' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint16_t' (2 bytes) as the base type to reduce its size [performance-enum-size]
enum {
^| // | ||
| // Iterative Client Instance Tests (Typed Math - Blocking) | ||
| // | ||
| TEST(core_cpp_clientserver_proto, IterativeClientInstances_Typed_Math) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| TEST(core_cpp_clientserver_proto, IterativeClientInstances_Typed_Math) | |
| TEST(core_cpp_clientserver_proto /*unused*/, IterativeClientInstances_Typed_Math /*unused*/) |
| // | ||
| // Iterative Client Instance Tests (Typed Math - Callback) | ||
| // | ||
| TEST(core_cpp_clientserver_proto, IterativeClientInstances_Typed_Math_Callback) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| TEST(core_cpp_clientserver_proto, IterativeClientInstances_Typed_Math_Callback) | |
| TEST(core_cpp_clientserver_proto /*unused*/, IterativeClientInstances_Typed_Math_Callback /*unused*/) |
| eCAL::Finalize(); | ||
| } | ||
|
|
||
| TEST(core_cpp_clientserver_proto, TypedCallbackAsync_Math) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| TEST(core_cpp_clientserver_proto, TypedCallbackAsync_Math) | |
| TEST(core_cpp_clientserver_proto /*unused*/, TypedCallbackAsync_Math /*unused*/) |
|
|
||
| auto start = std::chrono::steady_clock::now(); | ||
|
|
||
| bool initiated = math_client.CallWithCallbackAsync<SFloat>("Divide", request, callback); |
There was a problem hiding this comment.
warning: variable 'initiated' is not initialized [cppcoreguidelines-init-variables]
| bool initiated = math_client.CallWithCallbackAsync<SFloat>("Divide", request, callback); | |
| bool initiated = false = math_client.CallWithCallbackAsync<SFloat>("Divide", request, callback); |
| // | ||
| // Typed Ping Service Tests | ||
| // | ||
| TEST(core_cpp_clientserver_proto, TypedBlocking_Ping) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| TEST(core_cpp_clientserver_proto, TypedBlocking_Ping) | |
| TEST(core_cpp_clientserver_proto /*unused*/, TypedBlocking_Ping /*unused*/) |
| eCAL::Finalize(); | ||
| } | ||
|
|
||
| TEST(core_cpp_clientserver_proto, TypedCallback_Ping) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| TEST(core_cpp_clientserver_proto, TypedCallback_Ping) | |
| TEST(core_cpp_clientserver_proto /*unused*/, TypedCallback_Ping /*unused*/) |
| prom.set_value(resp.response->answer()); | ||
| }; | ||
|
|
||
| bool initiated = ping_client.CallWithCallback<PingResponse>("Ping", request, callback); |
There was a problem hiding this comment.
warning: variable 'initiated' is not initialized [cppcoreguidelines-init-variables]
| bool initiated = ping_client.CallWithCallback<PingResponse>("Ping", request, callback); | |
| bool initiated = false = ping_client.CallWithCallback<PingResponse>("Ping", request, callback); |
| return newValue; | ||
| } | ||
|
|
||
| T operator++(T) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| T operator++(T) | |
| T operator++(T /*unused*/) |
| return newValue; | ||
| } | ||
|
|
||
| T operator--(T) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| T operator--(T) | |
| T operator--(T /*unused*/) |
| * ========================= eCAL LICENSE ================================= | ||
| */ | ||
|
|
||
| #include <ecal/ecal.h> |
There was a problem hiding this comment.
warning: 'ecal/ecal.h' file not found [clang-diagnostic-error]
#include <ecal/ecal.h>
^| #include "math_service_impl.h" | ||
| #include "ping_service_impl.h" | ||
|
|
||
| enum { CMN_REGISTRATION_REFRESH_MS = 1000 }; |
There was a problem hiding this comment.
warning: enum '(unnamed enum at /github/workspace/serialization/protobuf/tests/clientserver_proto_test/src/clientserver_event_test.cpp:37:1)' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint16_t' (2 bytes) as the base type to reduce its size [performance-enum-size]
enum { CMN_REGISTRATION_REFRESH_MS = 1000 };
^|
|
||
| enum { CMN_REGISTRATION_REFRESH_MS = 1000 }; | ||
|
|
||
| TEST(core_cpp_clientserver_proto, ClientConnectEvent) |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| TEST(core_cpp_clientserver_proto, ClientConnectEvent) | |
| TEST(core_cpp_clientserver_proto /*unused*/, ClientConnectEvent /*unused*/) |
| } | ||
|
|
||
| // Implements the "Multiply" RPC. | ||
| void Multiply(::google::protobuf::RpcController* /*controller*/, |
There was a problem hiding this comment.
warning: method 'Multiply' can be made static [readability-convert-member-functions-to-static]
| void Multiply(::google::protobuf::RpcController* /*controller*/, | |
| static void Multiply(::google::protobuf::RpcController* /*controller*/, |
| // Implements the "Multiply" RPC. | ||
| void Multiply(::google::protobuf::RpcController* /*controller*/, | ||
| const SFloatTuple* request, | ||
| SFloat* response, |
There was a problem hiding this comment.
warning: pointer parameter 'response' can be pointer to const [readability-non-const-parameter]
| SFloat* response, | |
| const SFloat* response, |
| void Multiply(::google::protobuf::RpcController* /*controller*/, | ||
| const SFloatTuple* request, | ||
| SFloat* response, | ||
| ::google::protobuf::Closure* done) override |
There was a problem hiding this comment.
warning: pointer parameter 'done' can be pointer to const [readability-non-const-parameter]
| ::google::protobuf::Closure* done) override | |
| const ::google::protobuf::Closure* done) override |
| } | ||
|
|
||
| // Implements the "Divide" RPC. | ||
| void Divide(::google::protobuf::RpcController* /*controller*/, |
There was a problem hiding this comment.
warning: method 'Divide' can be made static [readability-convert-member-functions-to-static]
| void Divide(::google::protobuf::RpcController* /*controller*/, | |
| static void Divide(::google::protobuf::RpcController* /*controller*/, |
| // Implements the "Divide" RPC. | ||
| void Divide(::google::protobuf::RpcController* /*controller*/, | ||
| const SFloatTuple* request, | ||
| SFloat* response, |
There was a problem hiding this comment.
warning: pointer parameter 'response' can be pointer to const [readability-non-const-parameter]
| SFloat* response, | |
| const SFloat* response, |
KerstinKeller
left a comment
There was a problem hiding this comment.
I think that this is a very, very, very good first step in the right direction.
I am unsure about the typed vs. untyped client versions. I'd vote to keep only the typed ones, since in my opinion you are using protobuf in order to get the typing support in the first place!
The client instances should not use the dynamic messages to decode the responses.
And we need to take a look at the response Type, if the message should be stored in a shared_ptr or not.
I am a bit unsure. If we do it, we should also change it in the Message subscribers. It is maybe a bit connected to error handling in message subscribers. #1988
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h
Outdated
Show resolved
Hide resolved
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h
Outdated
Show resolved
Hide resolved
sligthly improved error handling in case ParseFromString fails
| { | ||
| public: | ||
| // Constructors | ||
| CClientInstance(eCAL::CClientInstance&& base_instance_) noexcept |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h:197:
- eCAL::CClientInstance m_instance;
+ eCAL::CClientInstance m_instance{};| { | ||
| } | ||
|
|
||
| CClientInstance(const SEntityId& entity_id_, |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
CClientInstance(const SEntityId& entity_id_,
^| { | ||
| public: | ||
| // Constructors | ||
| CClientInstanceTyped(eCAL::CClientInstance&& base_instance_) noexcept |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h:320:
- eCAL::CClientInstance m_instance;
+ eCAL::CClientInstance m_instance{};| { | ||
| } | ||
|
|
||
| CClientInstanceTyped(const SEntityId& entity_id_, |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
CClientInstanceTyped(const SEntityId& entity_id_,
^| auto ret = m_instance.CallWithResponse(method_name_, serialized_request, timeout_ms_); | ||
| TMsgServiceResponse<ResponseT> msg_response = ConvertResponse<ResponseT>(ret.second); | ||
|
|
||
| bool success = ret.first && (msg_response.call_state == eCallState::executed); |
There was a problem hiding this comment.
warning: variable 'success' is not initialized [cppcoreguidelines-init-variables]
| bool success = ret.first && (msg_response.call_state == eCallState::executed); | |
| bool success = false = ret.first && (msg_response.call_state == eCallState::executed); |
| void Divide(::google::protobuf::RpcController* /*controller*/, | ||
| const SFloatTuple* request, | ||
| SFloat* response, | ||
| ::google::protobuf::Closure* done) override |
There was a problem hiding this comment.
warning: pointer parameter 'done' can be pointer to const [readability-non-const-parameter]
| ::google::protobuf::Closure* done) override | |
| const ::google::protobuf::Closure* done) override |
|
|
||
| #pragma once | ||
|
|
||
| #include "ping.pb.h" |
There was a problem hiding this comment.
warning: 'ping.pb.h' file not found [clang-diagnostic-error]
#include "ping.pb.h"
^| { | ||
| public: | ||
| // Implements the "Ping" RPC. | ||
| void Ping(::google::protobuf::RpcController* /*controller*/, |
There was a problem hiding this comment.
warning: method 'Ping' can be made static [readability-convert-member-functions-to-static]
| void Ping(::google::protobuf::RpcController* /*controller*/, | |
| static void Ping(::google::protobuf::RpcController* /*controller*/, |
| // Implements the "Ping" RPC. | ||
| void Ping(::google::protobuf::RpcController* /*controller*/, | ||
| const PingRequest* /*request*/, | ||
| PingResponse* response, |
There was a problem hiding this comment.
warning: pointer parameter 'response' can be pointer to const [readability-non-const-parameter]
| PingResponse* response, | |
| const PingResponse* response, |
| void Ping(::google::protobuf::RpcController* /*controller*/, | ||
| const PingRequest* /*request*/, | ||
| PingResponse* response, | ||
| ::google::protobuf::Closure* done) override |
There was a problem hiding this comment.
warning: pointer parameter 'done' can be pointer to const [readability-non-const-parameter]
| ::google::protobuf::Closure* done) override | |
| const ::google::protobuf::Closure* done) override |
| * @tparam ResponseT The expected protobuf response type. | ||
| */ | ||
| template <typename ResponseT> | ||
| struct SMsgServiceResponse |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: server_id, service_method_information, error_msg [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:46:
- SServiceId server_id; //!< Identifier of the server that executed the call
- SServiceMethodInformation service_method_information; //!< Information about the called method
+ SServiceId server_id{}; //!< Identifier of the server that executed the call
+ SServiceMethodInformation service_method_information{}; //!< Information about the called methodserialization/protobuf/protobuf/include/ecal/msg/protobuf/client_protobuf_types.h:50:
- std::string error_msg; //!< Error message if the call failed
+ std::string error_msg{}; //!< Error message if the call failed| { | ||
| public: | ||
| // Constructors | ||
| CClientInstance(eCAL::CClientInstance&& base_instance_) noexcept |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h:188:
- eCAL::CClientInstance m_instance;
+ eCAL::CClientInstance m_instance{};| { | ||
| public: | ||
| // Constructors | ||
| CClientInstanceTyped(eCAL::CClientInstance&& base_instance_) noexcept |
There was a problem hiding this comment.
warning: constructor does not initialize these fields: m_instance [cppcoreguidelines-pro-type-member-init]
serialization/protobuf/protobuf/include/ecal/msg/protobuf/client_instance.h:312:
- eCAL::CClientInstance m_instance;
+ eCAL::CClientInstance m_instance{};| request.set_inp1(100.0); | ||
| request.set_inp2(50.0); | ||
|
|
||
| auto result = math_client.CallWithResponse<SFloatTuple, SFloat>("Multiply", request); |
There was a problem hiding this comment.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
| auto result = math_client.CallWithResponse<SFloatTuple, SFloat>("Multiply", request); | |
| auto result = math_client.CallWithResponse<SFloatTuple; | |
| auto SFloat>("Multiply";("Multiply", request); |
| request.set_inp1(20.0); | ||
| request.set_inp2(22.0); | ||
|
|
||
| auto result = math_client.CallWithResponse<SFloatTuple, SFloat>("Add", request); |
There was a problem hiding this comment.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
| auto result = math_client.CallWithResponse<SFloatTuple, SFloat>("Add", request); | |
| auto result = math_client.CallWithResponse<SFloatTuple; | |
| auto SFloat>("Add";("Add", request); |
| prom.set_value(resp.response.out()); | ||
| }; | ||
|
|
||
| bool initiated = math_client.CallWithCallback<SFloatTuple, SFloat>("Divide", request, callback); |
There was a problem hiding this comment.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
| bool initiated = math_client.CallWithCallback<SFloatTuple, SFloat>("Divide", request, callback); | |
| bool initiated = math_client.CallWithCallback<SFloatTuple; | |
| bool SFloat>("Divide";("Divide", request, callback); |
|
|
||
| auto start = std::chrono::steady_clock::now(); | ||
|
|
||
| bool initiated = math_client.CallWithCallbackAsync<SFloatTuple, SFloat>("Divide", request, callback); |
There was a problem hiding this comment.
warning: variable 'initiated' is not initialized [cppcoreguidelines-init-variables]
bool initiated = math_client.CallWithCallbackAsync<SFloatTuple, SFloat>("Divide", request, callback);
^this fix will not be applied because it overlaps with another fix
| PingRequest request; | ||
| request.set_message("PING"); | ||
|
|
||
| auto result = ping_client.CallWithResponse<PingRequest, PingResponse>("Ping", request); |
There was a problem hiding this comment.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
| auto result = ping_client.CallWithResponse<PingRequest, PingResponse>("Ping", request); | |
| auto result = ping_client.CallWithResponse<PingRequest; | |
| auto PingResponse>("Ping";("Ping", request); |
| prom.set_value(resp.response.answer()); | ||
| }; | ||
|
|
||
| bool initiated = ping_client.CallWithCallback<PingRequest, PingResponse>("Ping", request, callback); |
There was a problem hiding this comment.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
| bool initiated = ping_client.CallWithCallback<PingRequest, PingResponse>("Ping", request, callback); | |
| bool initiated = ping_client.CallWithCallback<PingRequest; | |
| bool PingResponse>("Ping";("Ping", request, callback); |
| prom.set_value(resp.response.answer()); | ||
| }; | ||
|
|
||
| bool initiated = ping_client.CallWithCallback<PingRequest, PingResponse>("Ping", request, callback); |
There was a problem hiding this comment.
warning: variable 'PingResponse' is not initialized [cppcoreguidelines-init-variables]
bool initiated = ping_client.CallWithCallback<PingRequest, PingResponse>("Ping", request, callback);
^this fix will not be applied because it overlaps with another fix
| prom.set_value(resp.response.answer()); | ||
| }; | ||
|
|
||
| bool initiated = ping_client.CallWithCallback<PingRequest, PingResponse>("Ping", request, callback); |
There was a problem hiding this comment.
warning: variable 'initiated' is not initialized [cppcoreguidelines-init-variables]
bool initiated = ping_client.CallWithCallback<PingRequest, PingResponse>("Ping", request, callback);
^this fix will not be applied because it overlaps with another fix
KerstinKeller
left a comment
There was a problem hiding this comment.
Let's merge and continue from there.
Refactor Protobuf Client API
This pull request introduces a major update and refactoring of the Protobuf-based service client API. The old API for
CServiceClienthas been replaced with a more robust, flexible, and type-safe design that separates untyped and typed interfaces.Key Changes
New API Structure:
CServiceClient):SServiceResponse).CallWithResponse<RequestT>()CallWithCallback<RequestT>()CallWithCallbackAsync<RequestT>()CServiceClientTyped):CallWithResponse<RequestT, ResponseT>()CallWithCallback<RequestT, ResponseT>()CallWithCallbackAsync<RequestT, ResponseT>()New Client Instance Wrappers:
CClientInstance: Handles untyped service calls.CClientInstanceTyped: Handles typed service calls and includes conversion of raw responses into the specified protobuf type.Common Base Class (
CServiceClientBase):Improved Code Organization:
Impact & Migration
Enhanced Maintainability & Flexibility:
Breaking Changes:
CServiceClientinterface is replaced. Users should migrate to:eCAL::protobuf::CServiceClientfor untyped calls.eCAL::protobuf::CServiceClientTypedfor calls that require typed responses.CallWithResponse,CallWithCallback, andCallWithCallbackAsync).Migration Steps:
CServiceClientwith the new interfaces.Code Snippet Old and New API
1. Client Construction & Callback Registration
Old API:
New API:
2. Service Call Invocation
Old API (Untyped calls):
New API (Typed calls):
3. Iterating Over Client Instances
Old API:
New API:
4. Callback Function Signatures
Old API (Untyped Response):
New API (Typed Response):
5. Client State Callback Signature
Old API:
New API:
These snippets illustrate the key changes:
CServiceClientTypedwith templated methods for request/response types, eliminating manual parsing.CallWithCallbackandCallWithResponseenforce type safety.GetClientInstances().