Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] protobuf service client to v6 #1981

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/command_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace eCAL
// Constructor & Destructor
/////////////////////////////////

CommandExecutor::CommandExecutor(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::string& remote_hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service)
CommandExecutor::CommandExecutor(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::string& remote_hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service)
: rec_server_instance_ (rec_server_instance)
, remote_hostname_ (remote_hostname)
, remote_rec_server_service_(remote_rec_server_service)
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/command_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace eCAL
// Constructor & Destructor
/////////////////////////////////
public:
CommandExecutor(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::string& remote_hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service);
CommandExecutor(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::string& remote_hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service);
~CommandExecutor();

/////////////////////////////////
Expand All @@ -70,7 +70,7 @@ namespace eCAL
private:
std::shared_ptr<eCAL::rec_server::RecServer> rec_server_instance_;
std::string remote_hostname_;
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_;

std::vector<std::pair<std::string, std::unique_ptr<eCAL::rec_cli::command::Command>>> command_map_;

Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/activate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace eCAL
return eCAL::rec::Error::OK;
}

eCAL::rec::Error Activate::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
eCAL::rec::Error Activate::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
{
// Arg check
if (argv.size() > 0)
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/activate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
};
}
}
Expand Down
26 changes: 15 additions & 11 deletions app/rec/rec_server_cli/src/commands/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace eCAL
{
namespace command
{
eCAL::rec::Error Command::GetRemoteStatus(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerStatus& status_output)
eCAL::rec::Error Command::GetRemoteStatus(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerStatus& status_output)
{
eCAL::pb::rec_server::Status status_pb;

Expand All @@ -53,7 +53,7 @@ namespace eCAL
}
}

eCAL::rec::Error Command::GetRemoteConfig(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerConfig& config_output)
eCAL::rec::Error Command::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)
{
// Service call
eCAL::pb::rec_server::GenericRequest request_pb;
Expand All @@ -73,23 +73,27 @@ namespace eCAL
}
}

eCAL::rec::Error Command::CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalsys_service
eCAL::rec::Error Command::CallRemoteEcalrecService(const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_ecalrec_service
, const std::string& hostname
, const std::string& method_name
, const google::protobuf::Message& request
, google::protobuf::Message& response)
{
remote_ecalsys_service->SetHostName(hostname);
constexpr int timeout_ms(1000);

eCAL::v5::ServiceResponseVecT service_response_vec;
constexpr int timeout_ms = 1000;

if (remote_ecalsys_service->Call(method_name, request.SerializeAsString(), timeout_ms, &service_response_vec))
auto client_instances = remote_ecalrec_service->GetClientInstances();
for (auto& client_instance : client_instances)
{
if (service_response_vec.size() > 0)
// TODO: We need to filter for pid as well in the future?
// Currently empty hostname means "all hosts"
if (client_instance.GetClientID().host_name == hostname || hostname.empty())
{
response.ParseFromString(service_response_vec[0].response);
return eCAL::rec::Error::ErrorCode::OK;
auto client_instance_response = client_instance.CallWithResponse(method_name, request, timeout_ms);
if (client_instance_response.first)
{
response.ParseFromString(client_instance_response.second.response);
return eCAL::rec::Error::ErrorCode::OK;
}
}
}
return eCAL::rec::Error(eCAL::rec::Error::ErrorCode::REMOTE_HOST_UNAVAILABLE, hostname);
Expand Down
8 changes: 4 additions & 4 deletions app/rec/rec_server_cli/src/commands/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ namespace eCAL
virtual std::string Example() const = 0;

virtual eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const = 0;
virtual eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const = 0;
virtual eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const = 0;

virtual void Interrupt() const {};

static eCAL::rec::Error GetRemoteStatus(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerStatus& status_output);
static eCAL::rec::Error GetRemoteConfig(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerConfig& config_output);
static eCAL::rec::Error GetRemoteStatus(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, eCAL::rec_server::RecServerStatus& status_output);
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
                                ^

, const std::string& hostname
, const std::string& method_name
, const google::protobuf::Message& request
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace eCAL
}
}

eCAL::rec::Error Comment::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
eCAL::rec::Error Comment::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
{
// Arg check
if (argv.size() < 1)
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/deactivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace eCAL
return eCAL::rec::Error::OK;
}

eCAL::rec::Error DeActivate::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
eCAL::rec::Error DeActivate::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
{
// Arg check
if (argv.size() > 0)
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/deactivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace eCAL
return rec_server_instance->DeleteMeasurement(meas_id);
}

eCAL::rec::Error Delete::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
eCAL::rec::Error Delete::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
{
// Arg check
if (argv.size() == 0)
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/delete.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace eCAL
return eCAL::rec::Error::ErrorCode::OK;
}

eCAL::rec::Error Exit::Execute(const std::string& /*hostname*/, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& /*remote_rec_server_service*/, const std::vector<std::string>& /*argv*/) const
eCAL::rec::Error Exit::Execute(const std::string& /*hostname*/, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& /*remote_rec_server_service*/, const std::vector<std::string>& /*argv*/) const
{
return eCAL::rec::Error::ErrorCode::OK;
}
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/exit.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/get_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace eCAL
return PrintConfig(rec_server_instance->GetConfig());
}

eCAL::rec::Error GetConfig::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& /*argv*/) const
eCAL::rec::Error GetConfig::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& /*argv*/) const
{
eCAL::rec_server::RecServerConfig config;
eCAL::rec::Error error = GetRemoteConfig(hostname, remote_rec_server_service, config);
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/get_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;

eCAL::rec::Error PrintConfig(const eCAL::rec_server::RecServerConfig& config) const;
};
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/load_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace eCAL
}
}

eCAL::rec::Error LoadConfig::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
eCAL::rec::Error LoadConfig::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
{
// Arg check
if (argv.empty())
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_cli/src/commands/load_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace eCAL
std::string Example() const override;

eCAL::rec::Error Execute(const std::shared_ptr<eCAL::rec_server::RecServer>& rec_server_instance, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
eCAL::rec::Error Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const override;
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_server_cli/src/commands/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace eCAL
return Execute(rec_server_instance, time_to_rec);
}

eCAL::rec::Error Record::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
eCAL::rec::Error Record::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, const std::vector<std::string>& argv) const
{
std::chrono::duration<double> time_to_rec(0);

Expand Down Expand Up @@ -111,7 +111,7 @@ namespace eCAL
return eCAL::rec::Error::ErrorCode::OK;
}

eCAL::rec::Error Record::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClient<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, std::chrono::duration<double> time_to_rec) const
eCAL::rec::Error Record::Execute(const std::string& hostname, const std::shared_ptr<eCAL::protobuf::CServiceClientUntypedCallback<eCAL::pb::rec_server::EcalRecServerService>>& remote_rec_server_service, std::chrono::duration<double> time_to_rec) const
{
// Retrieve Status
eCAL::rec_server::RecServerStatus status;
Expand Down
Loading
Loading