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 <viam/api/component/generic/v1/generic.grpc.pb.h>
7
10#include <viam/sdk/rpc/dial.hpp>
11
12namespace viam {
13namespace sdk {
14namespace impl {
15
20 public:
22 GenericComponentClient(std::string name, const ViamChannel& channel);
23
24 const ViamChannel& channel() const {
25 return *channel_;
26 }
27 ProtoStruct do_command(const ProtoStruct& command) override;
28 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
29
30 protected:
31 // This constructor leaves the `channel_` as a nullptr. This is useful for testing
32 // purposes, but renders it unusable for production use. Care should be taken to
33 // avoid use of this constructor outside of tests.
35 std::string name,
36 std::unique_ptr<viam::component::generic::v1::GenericService::StubInterface> stub)
37 : GenericComponent(std::move(name)), stub_(std::move(stub)) {}
38
39 private:
40 using StubType = viam::component::generic::v1::GenericService::StubInterface;
41 std::unique_ptr<StubType> stub_;
42 const ViamChannel* channel_;
43};
44
45} // namespace impl
46} // namespace sdk
47} // 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.
Definition dial.hpp:25
gRPC client implementation of a GenericComponent.
Definition generic_client.hpp:19
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.