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 ProtoStruct get_status() override;
29 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
30
31 protected:
32 // This constructor leaves the `channel_` as a nullptr. This is useful for testing
33 // purposes, but renders it unusable for production use. Care should be taken to
34 // avoid use of this constructor outside of tests.
36 std::string name,
37 std::unique_ptr<viam::component::generic::v1::GenericService::StubInterface> stub)
38 : GenericComponent(std::move(name)), stub_(std::move(stub)) {}
39
40 private:
41 using StubType = viam::component::generic::v1::GenericService::StubInterface;
42 std::unique_ptr<StubType> stub_;
43 const ViamChannel* channel_;
44};
45
46} // namespace impl
47} // namespace sdk
48} // 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:33
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 get_status() override
Get the status of the generic component.
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.