Viam C++ SDK current
Loading...
Searching...
No Matches
generic_client.hpp
1
4#pragma once
5
6#include <grpcpp/channel.h>
7
8#include <viam/api/service/generic/v1/generic.grpc.pb.h>
9
11#include <viam/sdk/services/generic.hpp>
12
13namespace viam {
14namespace sdk {
15namespace impl {
16
21 public:
23 GenericServiceClient(std::string name, std::shared_ptr<grpc::Channel> channel);
24 ProtoStruct do_command(const ProtoStruct& command) override;
25
26 protected:
27 // This constructor leaves the `channel_` as a nullptr. This is useful for testing
28 // purposes, but renders it unusable for production use. Care should be taken to
29 // avoid use of this constructor outside of tests.
31 std::string name,
32 std::unique_ptr<viam::service::generic::v1::GenericService::StubInterface> stub)
33 : GenericService(std::move(name)), stub_(std::move(stub)){};
34
35 private:
36 using StubType = viam::service::generic::v1::GenericService::StubInterface;
37 std::unique_ptr<StubType> stub_;
38 std::shared_ptr<grpc::Channel> channel_;
39};
40
41} // namespace impl
42} // namespace sdk
43} // namespace viam
A GenericService represents any service that can execute arbitrary commands.
Definition generic.hpp:21
virtual std::string name() const
Return the resource's name.
gRPC client implementation of a GenericService.
Definition generic_client.hpp:20
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
gRPC client implementation for a robot.