31 #ifndef HARDWARE_INTERFACE_RESOURCE_MANAGER_H 32 #define HARDWARE_INTERFACE_RESOURCE_MANAGER_H 68 template <
class ResourceHandle>
81 std::vector<std::string> out;
82 out.reserve(resource_map_.size());
83 for(
typename ResourceMap::const_iterator it = resource_map_.begin(); it != resource_map_.end(); ++it)
85 out.push_back(it->first);
97 typename ResourceMap::iterator it = resource_map_.find(handle.getName());
98 if (it == resource_map_.end())
100 resource_map_.insert(std::make_pair(handle.getName(), handle));
104 ROS_WARN_STREAM(
"Replacing previously registered handle '" << handle.getName() <<
"' in '" +
117 typename ResourceMap::const_iterator it = resource_map_.find(name);
119 if (it == resource_map_.end())
121 throw std::logic_error(
"Could not find resource '" + name +
"' in '" +
137 resource_manager_type* result)
139 for(
typename std::vector<resource_manager_type*>::iterator it_man = managers.begin();
140 it_man != managers.end(); ++it_man) {
141 std::vector<std::string> handle_names = (*it_man)->getNames();
142 for(std::vector<std::string>::iterator it_nms = handle_names.begin();
143 it_nms != handle_names.end(); ++it_nms) {
158 #endif // HARDWARE_INTERFACE_RESOURCE_MANAGER_H virtual ~ResourceManagerBase()
ResourceMap resource_map_
std::string demangledTypeName()
Convenience method for demangling type names.
virtual ~ResourceManager()
ResourceManager< ResourceHandle > resource_manager_type
Class for handling named resources.
ResourceHandle getHandle(const std::string &name)
Get a resource handle by name.
#define ROS_WARN_STREAM(args)
void registerHandle(const ResourceHandle &handle)
Register a new resource. If the resource name already exists, the previously stored resource value wi...
static void concatManagers(std::vector< resource_manager_type * > &managers, resource_manager_type *result)
Combine a list of interfaces into one.
std::map< std::string, ResourceHandle > ResourceMap
std::vector< std::string > getNames() const
Non-templated Base Class that contains a virtual destructor.