Viam C++ SDK current
Loading...
Searching...
No Matches
Public Member Functions | List of all members
viam::sdk::ResourceManager Class Reference

Defines a resource manager for use by anything that tracks resources. More...

#include <resource_manager.hpp>

Public Member Functions

std::shared_ptr< Resourceresource (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, std::shared_ptr< Resource > 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.
 

Detailed Description

Defines a resource manager for use by anything that tracks resources.

Member Function Documentation

◆ add() [1/2]

void viam::sdk::ResourceManager::add ( const Name & name,
std::shared_ptr< Resource > resource )

Adds a single resource to the manager.

Parameters
nameThe name of the resource.
resourceThe 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
nameThe name of the resource.
resourceThe resource being added.

◆ remove()

void viam::sdk::ResourceManager::remove ( const Name & name)

Remodes a single resource from the manager.

Parameters
nameThe 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
resourcesThe resources to replace with.

◆ replace_one()

void viam::sdk::ResourceManager::replace_one ( const Name & name,
std::shared_ptr< Resource > resource )

Replaces an existing resource. No-op if the named resource does not exist.

Parameters
nameThe name of the resource to replace.
resourceThe 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
namethe 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
nameof the desired resource.
Exceptions
`Exception`if the desired resource does not exist.

The documentation for this class was generated from the following file: