5#include <google/protobuf/descriptor.h>
7#include <viam/api/common/v1/common.pb.h>
16 APIType(std::string namespace_, std::string resource_type);
18 virtual std::string to_string()
const;
20 const std::string& type_namespace()
const;
21 const std::string& resource_type()
const;
23 void set_namespace(
const std::string& type_namespace);
24 void set_resource_type(
const std::string& resource_type);
27 std::string namespace_;
28 std::string resource_type_;
35 virtual std::string to_string()
const override;
37 API(std::string namespace_, std::string resource_type, std::string resource_subtype);
38 API(
APIType type, std::string resource_subtype);
39 static API from_string(std::string api);
41 const std::string& resource_subtype()
const;
42 void set_resource_subtype(
const std::string& subtype);
43 bool is_component_type();
44 bool is_service_type();
45 friend bool operator==(
API const& lhs,
API const& rhs);
46 friend bool operator<(
const API& lhs,
const API& rhs);
47 friend std::ostream& operator<<(std::ostream& os,
const API& v);
58 std::string resource_subtype_;
65 std::string short_name()
const;
66 std::string to_string()
const;
67 viam::common::v1::ResourceName to_proto()
const;
68 static Name from_proto(
const viam::common::v1::ResourceName& proto);
69 static Name from_string(std::string name);
70 Name(
API api, std::string remote_name, std::string name);
72 const API& api()
const;
73 const std::string& name()
const;
74 const std::string& remote_name()
const;
75 friend bool operator==(
const Name& lhs,
const Name& rhs);
76 friend std::ostream& operator<<(std::ostream& os,
const Name& v);
80 std::string remote_name_;
87 return (api_.to_string() + proto_service_name_ + descriptor_.DebugString()) <
88 (rhs.api_.to_string() + rhs.proto_service_name_ + rhs.descriptor_.DebugString());
90 const std::string& proto_service_name()
const;
91 const API& api()
const;
93 RPCSubtype(
API api,
const google::protobuf::ServiceDescriptor& descriptor);
95 std::string proto_service_name,
96 const google::protobuf::ServiceDescriptor& descriptor);
100 const google::protobuf::ServiceDescriptor& descriptor_;
101 std::string proto_service_name_;
107 ModelFamily(std::string namespace_, std::string family);
108 std::string to_string()
const;
111 std::string namespace_;
119 std::string to_string()
const;
121 Model(std::string namespace_, std::string family, std::string model_name);
130 friend bool operator==(
const Model& lhs,
const Model& rhs);
134 std::string model_name_;
143 return std::hash<std::string>()(key.to_string());
150 const ::viam::sdk::API& api = key.api();
151 std::string hash = api.to_string() + key.proto_service_name();
152 return std::hash<std::string>()(hash);
158 size_t operator()(const ::viam::sdk::API& key)
const noexcept {
159 return std::hash<std::string>()(key.to_string());
Defines a resource's namespace (e.g., RDK) and type (e.g., component or service).
Definition resource_api.hpp:14
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
Definition resource_api.hpp:105
Defines the namespace_, family, and name for a particular resource model.
Definition resource_api.hpp:117
static Model from_str(std::string model)
Parses a single model string into a Model, using default values for namespace and family if not provi...
A name for specific instances of resources.
Definition resource_api.hpp:63
Definition resource_api.hpp:84
Definition resource_api.hpp:50