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>
9#include <viam/sdk/referenceframe/frame.hpp>
10#include <viam/sdk/resource/resource_api.hpp>
11
12namespace viam {
13namespace app {
14namespace v1 {
15
16class ComponentConfig;
17class ResourceLevelServiceConfig;
18
19} // namespace v1
20} // namespace app
21
22namespace service {
23namespace discovery {
24namespace v1 {
25
26class DiscoverResourcesResponse;
27}
28} // namespace discovery
29} // namespace service
30} // namespace viam
31
32namespace viam {
33namespace sdk {
34
36 std::string type;
37 ProtoStruct attributes;
38 ProtoValue converted_attributes;
39};
40
42 public:
43 ResourceConfig(std::string type,
44 std::string name,
45 std::string namespace_,
46 ProtoStruct attributes,
47 std::string api,
48 Model model,
49 LinkConfig frame,
50 log_level lvl = sdk::log_level::info);
51
52 ResourceConfig(std::string type);
53
54 Name resource_name();
55
56 const API& api() const;
57
58 const LinkConfig& frame() const;
59
60 const Model& model() const;
61
62 const std::string& name() const;
63 const std::string& namespace_() const;
64 const std::string& type() const;
65
66 log_level get_log_level() const;
67
68 const std::vector<std::string>& depends_on() const;
69
70 const std::vector<ResourceLevelServiceConfig>& service_config() const;
71
72 const ProtoStruct& attributes() const;
73
74 private:
75 void fix_api();
76
77 API api_;
78
79 LinkConfig frame_;
80
81 Model model_;
82
83 std::string name_;
84 std::string namespace__;
85 std::string type_;
86
87 std::vector<std::string> depends_on_;
88
89 std::vector<ResourceLevelServiceConfig> service_config_;
90
91 ProtoStruct attributes_;
92 ProtoValue converted_attributes_;
93
94 std::vector<std::string> implicit_depends_on_;
95
96 log_level log_level_;
97};
98
99namespace proto_convert_details {
100
101template <>
103 void operator()(const ResourceLevelServiceConfig&, app::v1::ResourceLevelServiceConfig*) const;
104};
105
106template <>
108 void operator()(const ResourceConfig&, app::v1::ComponentConfig*) const;
109};
110
111template <>
112struct from_proto_impl<app::v1::ComponentConfig> {
113 ResourceConfig operator()(const app::v1::ComponentConfig*) const;
114};
115
116template <>
117struct from_proto_impl<service::discovery::v1::DiscoverResourcesResponse> {
118 std::vector<ResourceConfig> operator()(
119 const service::discovery::v1::DiscoverResourcesResponse*) const;
120};
121
122} // namespace proto_convert_details
123
124} // namespace sdk
125} // 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:41
log_level
Severity levels for the logger.
Definition logging.hpp:30
Defines logging infrastructure.
Definition resource.hpp:35