-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathresource.hpp
46 lines (34 loc) · 1021 Bytes
/
resource.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <unordered_map>
#include <viam/sdk/common/proto_value.hpp>
#include <viam/sdk/config/resource.hpp>
#include <viam/sdk/resource/resource_api.hpp>
namespace viam {
namespace sdk {
class Resource;
using Dependencies = std::unordered_map<Name, std::shared_ptr<Resource>>;
class Resource {
public:
virtual ~Resource();
explicit Resource(std::string name);
/// @brief Returns the `API` associated with a particular resource.
virtual API api() const = 0;
/// @brief Returns the `Name` for a particular resource.
virtual Name get_resource_name() const;
/// @brief Return the resource's name.
virtual std::string name() const;
/// @brief Closes a resource
virtual void close();
private:
std::string name_;
protected:
Name get_resource_name(const std::string& type) const;
};
template <>
struct API::traits<Resource> {
static API api() {
return {"rdk", "resource", "Resource"};
}
};
} // namespace sdk
} // namespace viam