Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pluginlib/include/pluginlib/class_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ class ClassLoader : public ClassLoaderBase
public:
typedef typename std::map<std::string, ClassDesc>::iterator ClassMapIterator;

public:
/**
* \param package The package containing the base class
* \param base_class The type of the base class for classes to be loaded
* \param attrib_name The attribute to search for in manifext.xml files, defaults to "plugin"
* \param attrib_name The attribute to search for in manifest.xml files, defaults to "plugin"
* \param plugin_xml_paths The list of paths of plugin.xml files, defaults to be crawled via
* ros::package::getPlugins()
* \throws pluginlib::ClassLoaderException if package manifest cannot be found
Expand Down
2 changes: 1 addition & 1 deletion pluginlib/include/pluginlib/class_loader_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#ifndef PLUGINLIB__CLASS_LOADER_BASE_HPP_
#define PLUGINLIB__CLASS_LOADER_BASE_HPP_

#include <vector>
#include <string>
#include <vector>

namespace pluginlib
{
Expand Down
35 changes: 14 additions & 21 deletions pluginlib/include/pluginlib/class_loader_imp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <vector>

#include "ament_index_cpp/get_package_prefix.hpp"
#include "ament_index_cpp/get_package_share_directory.hpp"
#include "ament_index_cpp/get_resource.hpp"
#include "ament_index_cpp/get_resources.hpp"
#include "class_loader/interface_traits.hpp"
Expand All @@ -52,12 +51,6 @@

#include "./class_loader.hpp"

#ifdef _WIN32
#define CLASS_LOADER_IMPL_OS_PATHSEP ";"
#else
#define CLASS_LOADER_IMPL_OS_PATHSEP ":"
#endif

namespace pluginlib
{

Expand Down Expand Up @@ -93,7 +86,7 @@ ClassLoader<T>::ClassLoader(
}
classes_available_ = determineAvailableClasses(plugin_xml_paths_);
RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
"Finished constructring ClassLoader, base = %s, address = %p",
"Finished constructing ClassLoader, base = %s, address = %p",
base_class.c_str(), static_cast<void *>(this));
}

Expand Down Expand Up @@ -166,7 +159,7 @@ T * ClassLoader<T>::createUnmanagedInstance(const std::string & lookup_name, Arg
loadLibraryForClass(lookup_name);
}

T * instance = 0;
T * instance = nullptr;
try {
RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
"Attempting to create instance through low level multi-library class loader.");
Expand Down Expand Up @@ -269,7 +262,7 @@ std::string ClassLoader<T>::extractPackageNameFromPackageXML(const std::string &
tinyxml2::XMLDocument document;
document.LoadFile(package_xml_path.c_str());
tinyxml2::XMLElement * doc_root_node = document.FirstChildElement("package");
if (NULL == doc_root_node) {
if (nullptr == doc_root_node) {
RCUTILS_LOG_ERROR_NAMED("pluginlib.ClassLoader",
"Could not find a root element for package manifest at %s.",
package_xml_path.c_str());
Expand All @@ -279,7 +272,7 @@ std::string ClassLoader<T>::extractPackageNameFromPackageXML(const std::string &
assert(document.RootElement() == doc_root_node);

tinyxml2::XMLElement * package_name_node = doc_root_node->FirstChildElement("name");
if (NULL == package_name_node) {
if (nullptr == package_name_node) {
RCUTILS_LOG_ERROR_NAMED("pluginlib.ClassLoader",
"package.xml at %s does not have a <name> tag! Cannot determine package "
"which exports plugin.",
Expand All @@ -288,7 +281,7 @@ std::string ClassLoader<T>::extractPackageNameFromPackageXML(const std::string &
}

const char * package_name_node_txt = package_name_node->GetText();
if (NULL == package_name_node_txt) {
if (nullptr == package_name_node_txt) {
RCUTILS_LOG_ERROR_NAMED("pluginlib.ClassLoader",
"package.xml at %s has an invalid <name> tag! Cannot determine package "
"which exports plugin.",
Expand Down Expand Up @@ -436,13 +429,13 @@ template<class T>
std::string ClassLoader<T>::getClassLibraryPath(const std::string & lookup_name)
/***************************************************************************/
{
if (classes_available_.find(lookup_name) == classes_available_.end()) {
ClassMapIterator it = classes_available_.find(lookup_name);
if (it == classes_available_.end()) {
std::ostringstream error_msg;
error_msg << "Could not find library corresponding to plugin " << lookup_name <<
". Make sure the plugin description XML file has the correct name of the library.";
throw pluginlib::LibraryLoadException(error_msg.str());
}
ClassMapIterator it = classes_available_.find(lookup_name);
std::string library_name = it->second.library_name_;
RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
"Class %s maps to library %s in classes_available_.",
Expand Down Expand Up @@ -653,14 +646,14 @@ void ClassLoader<T>::processSingleXMLPluginFile(
tinyxml2::XMLDocument document;
document.LoadFile(xml_file.c_str());
tinyxml2::XMLElement * config = document.RootElement();
if (NULL == config) {
if (nullptr == config) {
throw pluginlib::InvalidXMLException(
"XML Document '" + xml_file +
"' has no Root Element. This likely means the XML is malformed or missing.");
return;
}
const char * config_value = config->Value();
if (NULL == config_value) {
if (nullptr == config_value) {
throw pluginlib::InvalidXMLException(
"XML Document '" + xml_file +
"' has an invalid Root Element. This likely means the XML is malformed or missing.");
Expand All @@ -680,9 +673,9 @@ void ClassLoader<T>::processSingleXMLPluginFile(
}

tinyxml2::XMLElement * library = config;
while (library != NULL) {
while (library != nullptr) {
const char * path = library->Attribute("path");
if (NULL == path) {
if (nullptr == path) {
RCUTILS_LOG_ERROR_NAMED("pluginlib.ClassLoader",
"Attribute 'path' in 'library' tag is missing in %s.", xml_file.c_str());
continue;
Expand All @@ -706,23 +699,23 @@ void ClassLoader<T>::processSingleXMLPluginFile(
tinyxml2::XMLElement * class_element = library->FirstChildElement("class");
while (class_element) {
std::string derived_class;
if (class_element->Attribute("type") != NULL) {
if (class_element->Attribute("type") != nullptr) {
derived_class = std::string(class_element->Attribute("type"));
} else {
throw pluginlib::ClassLoaderException(
"Class could not be loaded. Attribute 'type' in class tag is missing.");
}

std::string base_class_type;
if (class_element->Attribute("base_class_type") != NULL) {
if (class_element->Attribute("base_class_type") != nullptr) {
base_class_type = std::string(class_element->Attribute("base_class_type"));
} else {
throw pluginlib::ClassLoaderException(
"Class could not be loaded. Attribute 'base_class_type' in class tag is missing.");
}

std::string lookup_name;
if (class_element->Attribute("name") != NULL) {
if (class_element->Attribute("name") != nullptr) {
lookup_name = class_element->Attribute("name");
RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
"XML file specifies lookup name (i.e. magic name) = %s.",
Expand Down
2 changes: 1 addition & 1 deletion pluginlib/src/list_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the Willow Garage nor the names of its
// * Neither the name of the Metro Robots nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
Expand Down
2 changes: 1 addition & 1 deletion pluginlib/test/unique_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST(PluginlibUniquePtrTest, misspelledPlugin) {
"test_pluginlib/foo"), pluginlib::LibraryLoadException);
}

TEST(PluginlibTest, brokenPlugin) {
TEST(PluginlibUniquePtrTest, brokenPlugin) {
pluginlib::ClassLoader<test_base::Fubar> test_loader("test_pluginlib", "test_base::Fubar");
ASSERT_THROW(
test_loader.createUniqueInstance("test_pluginlib/none"), pluginlib::PluginlibException);
Expand Down