Defines a resource manager for use by anything that tracks resources.
More...
#include <resource_manager.hpp>
|
| std::shared_ptr< Resource > | resource (const std::string &name) |
| | Returns a resource.
|
| |
| template<typename T > |
| std::shared_ptr< T > | resource (const std::string &name) |
| | Returns a resource after dynamically downcasting to T.
|
| |
| void | replace_all (const std::unordered_map< Name, std::shared_ptr< Resource > > &resources) |
| | Replaces all resources in the manager.
|
| |
| void | add (const Name &name, std::shared_ptr< Resource > resource) |
| | Adds a single resource to the manager.
|
| |
| void | add (std::string name, std::shared_ptr< Resource > resource) |
| | Adds a single resource to the manager.
|
| |
| void | remove (const Name &name) |
| | Remodes a single resource from the manager.
|
| |
| void | replace_one (const Name &name, const std::function< std::shared_ptr< Resource >()> &create_resource) |
| | Replaces an existing resource. No-op if the named resource does not exist.
|
| |
|
const std::unordered_map< std::string, std::shared_ptr< Resource > > & | resources () const |
| | Returns a reference to the existing resources within the manager.
|
| |
Defines a resource manager for use by anything that tracks resources.
◆ add() [1/2]
| void viam::sdk::ResourceManager::add |
( |
const Name & | name, |
|
|
std::shared_ptr< Resource > | resource ) |
Adds a single resource to the manager.
- Parameters
-
| name | The name of the resource. |
| resource | The resource being added. |
◆ add() [2/2]
| void viam::sdk::ResourceManager::add |
( |
std::string | name, |
|
|
std::shared_ptr< Resource > | resource ) |
Adds a single resource to the manager.
- Parameters
-
| name | The name of the resource. |
| resource | The resource being added. |
◆ remove()
| void viam::sdk::ResourceManager::remove |
( |
const Name & | name | ) |
|
Remodes a single resource from the manager.
- Parameters
-
| name | The name of the resource to remove. |
◆ replace_all()
| void viam::sdk::ResourceManager::replace_all |
( |
const std::unordered_map< Name, std::shared_ptr< Resource > > & | resources | ) |
|
Replaces all resources in the manager.
- Parameters
-
| resources | The resources to replace with. |
◆ replace_one()
| void viam::sdk::ResourceManager::replace_one |
( |
const Name & | name, |
|
|
const std::function< std::shared_ptr< Resource >()> & | create_resource ) |
Replaces an existing resource. No-op if the named resource does not exist.
- Parameters
-
| name | The name of the resource to replace. |
| create_resource | Callback to construct the new resource that is replacing the existing one. |
◆ resource() [1/2]
| std::shared_ptr< Resource > viam::sdk::ResourceManager::resource |
( |
const std::string & | name | ) |
|
Returns a resource.
- Parameters
-
| name | the name of the desired resource. |
- Exceptions
-
| `Exception` | if the desired resource does not exist. |
◆ resource() [2/2]
template<typename T >
| std::shared_ptr< T > viam::sdk::ResourceManager::resource |
( |
const std::string & | name | ) |
|
|
inline |
Returns a resource after dynamically downcasting to T.
- Parameters
-
| name | of the desired resource. |
- Exceptions
-
| `Exception` | if the desired resource does not exist. |
The documentation for this class was generated from the following file: