diff --git a/hardware_interface/include/hardware_interface/internal/interface_manager.h b/hardware_interface/include/hardware_interface/internal/interface_manager.h index 392fb58c0..dad46e09f 100644 --- a/hardware_interface/include/hardware_interface/internal/interface_manager.h +++ b/hardware_interface/include/hardware_interface/internal/interface_manager.h @@ -63,7 +63,7 @@ struct CheckIsResourceManager { // method called if C is a ResourceManager template - static yes& callCM(typename std::vector& managers, C* result, typename C::resource_manager_type*) + static void callCM(typename std::vector& managers, C* result, typename C::resource_manager_type*) { std::vector managers_in; // we have to typecase back to base class @@ -74,7 +74,7 @@ struct CheckIsResourceManager { // method called if C is not a ResourceManager template - static no& callCM(typename std::vector& managers, C* result, ...) {} + static void callCM(typename std::vector& managers, C* result, ...) {} // calls ResourceManager::concatManagers if C is a ResourceManager static const void callConcatManagers(typename std::vector& managers, T* result) @@ -83,18 +83,18 @@ struct CheckIsResourceManager { // method called if C is a ResourceManager template - static std::vector callGR(C* iface, typename C::resource_manager_type*) + static void callGR(std::vector &resources, C* iface, typename C::resource_manager_type*) { - return iface->getNames(); + resources = iface->getNames(); } // method called if C is not a ResourceManager template - static std::vector callGR(T* iface, ...) {} + static void callGR(std::vector &resources, T* iface, ...) { } // calls ResourceManager::concatManagers if C is a ResourceManager - static std::vector callGetResources(T* iface) - { return callGR(iface, 0); } + static void callGetResources(std::vector &resources, T* iface) + { return callGR(resources, iface, 0); } }; class InterfaceManager @@ -118,14 +118,7 @@ class InterfaceManager ROS_WARN_STREAM("Replacing previously registered interface '" << iface_name << "'."); } interfaces_[iface_name] = iface; - - std::vector resources; - if(CheckIsResourceManager::value) - { - // it is a ResourceManager. Get the names of the resources - resources = CheckIsResourceManager::callGetResources(iface); - } - resources_[iface_name] = resources; + CheckIsResourceManager::callGetResources(resources_[iface_name], iface); } void registerInterfaceManager(InterfaceManager* iface_man)