Viam C++ SDK current
Loading...
Searching...
No Matches
generic_client.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <grpcpp/channel.h>
7
8#include <viam/api/component/generic/v1/generic.grpc.pb.h>
9
12
13namespace viam {
14namespace sdk {
15namespace impl {
16
21 public:
23 GenericComponentClient(std::string name, std::shared_ptr<grpc::Channel> channel);
24 ProtoStruct do_command(const ProtoStruct& command) override;
25 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
26
27 protected:
28 // This constructor leaves the `channel_` as a nullptr. This is useful for testing
29 // purposes, but renders it unusable for production use. Care should be taken to
30 // avoid use of this constructor outside of tests.
32 std::string name,
33 std::unique_ptr<viam::component::generic::v1::GenericService::StubInterface> stub)
34 : GenericComponent(std::move(name)), stub_(std::move(stub)){};
35
36 private:
37 using StubType = viam::component::generic::v1::GenericService::StubInterface;
38 std::unique_ptr<StubType> stub_;
39 std::shared_ptr<grpc::Channel> channel_;
40};
41
42} // namespace impl
43} // namespace sdk
44} // namespace viam
A GenericComponent represents any component that can execute arbitrary commands.
Definition generic.hpp:20
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling camera.
Definition generic.hpp:29
virtual std::string name() const
Return the resource's name.
gRPC client implementation of a GenericComponent.
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.
Defines GenericComponent subtype and component class capable of executing arbitrary commands.