Viam C++ SDK current
Loading...
Searching...
No Matches
resource.hpp
1#pragma once
2
3#include <unordered_map>
4
5#include <viam/sdk/common/proto_value.hpp>
6#include <viam/sdk/config/resource.hpp>
7#include <viam/sdk/resource/resource_api.hpp>
8
9namespace viam {
10namespace sdk {
11
12class Resource;
13using Dependencies = std::unordered_map<Name, std::shared_ptr<Resource>>;
14class Resource {
15 public:
16 virtual ~Resource();
17 explicit Resource(std::string name);
18
20 virtual API api() const = 0;
21
23 virtual Name get_resource_name() const;
24
26 virtual std::string name() const;
27
28 private:
29 std::string name_;
30
31 protected:
32 Name get_resource_name(const std::string& type) const;
33};
34
35template <>
37 static API api() {
38 return {"rdk", "resource", "Resource"};
39 }
40};
41
42} // namespace sdk
43} // namespace viam
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
A name for specific instances of resources.
Definition resource_api.hpp:63
Definition resource.hpp:14
virtual std::string name() const
Return the resource's name.
virtual Name get_resource_name() const
Returns the Name for a particular resource.
virtual API api() const =0
Returns the API associated with a particular resource.
Definition resource_api.hpp:50