Viam C++ SDK current
Loading...
Searching...
No Matches
resource.hpp
1#pragma once
2
3#include <string>
4#include <unordered_map>
5
6#include <viam/sdk/common/proto_convert.hpp>
7#include <viam/sdk/common/proto_value.hpp>
8#include <viam/sdk/referenceframe/frame.hpp>
9#include <viam/sdk/resource/resource_api.hpp>
10
11namespace viam {
12namespace app {
13namespace v1 {
14
15class ComponentConfig;
16class ResourceLevelServiceConfig;
17
18} // namespace v1
19} // namespace app
20
21namespace service {
22namespace discovery {
23namespace v1 {
24
25class DiscoverResourcesResponse;
26}
27} // namespace discovery
28} // namespace service
29} // namespace viam
30
31namespace viam {
32namespace sdk {
33
35 std::string type;
36 ProtoStruct attributes;
37 ProtoValue converted_attributes;
38};
39
41 public:
42 ResourceConfig(std::string type,
43 std::string name,
44 std::string namespace_,
45 ProtoStruct attributes,
46 std::string api,
47 Model model,
48 LinkConfig frame);
49
50 ResourceConfig(std::string type);
51
52 Name resource_name();
53 const API& api() const;
54 const LinkConfig& frame() const;
55 const Model& model() const;
56 const std::string& name() const;
57 const std::string& namespace_() const;
58 const std::string& type() const;
59 const std::vector<std::string>& depends_on() const;
60 const std::vector<ResourceLevelServiceConfig>& service_config() const;
61 const ProtoStruct& attributes() const;
62
63 private:
64 API api_;
65 LinkConfig frame_;
66 Model model_;
67 std::string name_;
68 std::string namespace__;
69 std::string type_;
70 std::vector<std::string> depends_on_;
71 std::vector<ResourceLevelServiceConfig> service_config_;
72 ProtoStruct attributes_;
73 ProtoValue converted_attributes_;
74 std::vector<std::string> implicit_depends_on_;
75 void fix_api();
76};
77
78namespace proto_convert_details {
79
80template <>
82 void operator()(const ResourceLevelServiceConfig&, app::v1::ResourceLevelServiceConfig*) const;
83};
84
85template <>
87 void operator()(const ResourceConfig&, app::v1::ComponentConfig*) const;
88};
89
90template <>
91struct from_proto_impl<app::v1::ComponentConfig> {
92 ResourceConfig operator()(const app::v1::ComponentConfig*) const;
93};
94
95template <>
96struct from_proto_impl<service::discovery::v1::DiscoverResourcesResponse> {
97 std::vector<ResourceConfig> operator()(
98 const service::discovery::v1::DiscoverResourcesResponse*) const;
99};
100
101} // namespace proto_convert_details
102
103} // namespace sdk
104} // namespace viam
Definition resource_api.hpp:21
Definition frame.hpp:21
Defines the namespace_, family, and name for a particular resource model.
Definition resource_api.hpp:125
A name for specific instances of resources.
Definition resource_api.hpp:61
Type-erased value for storing google::protobuf::Value types. A ProtoValue can be nullptr,...
Definition proto_value.hpp:55
Definition resource.hpp:40
Definition resource.hpp:34