Skip to content
Merged
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
22 changes: 11 additions & 11 deletions include/pluginlib/class_loader_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ClassLoader<T>::ClassLoader(
throw pluginlib::ClassLoaderException("Unable to find package: " + package_);
}

if (plugin_xml_paths_.size() == 0) {
if (0 == plugin_xml_paths_.size()) {
plugin_xml_paths_ = getPluginXmlPaths(package_, attrib_name_);
}
classes_available_ = determineAvailableClasses(plugin_xml_paths_);
Expand Down Expand Up @@ -290,17 +290,17 @@ 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 (doc_root_node == NULL) {
if (NULL == doc_root_node) {
ROS_ERROR_NAMED("pluginlib.ClassLoader",
"Could not find a root element for package manifest at %s.",
package_xml_path.c_str());
return "";
}

assert(doc_root_node == document.RootElement());
assert(document.RootElement() == doc_root_node);

tinyxml2::XMLElement * package_name_node = doc_root_node->FirstChildElement("name");
if (package_name_node == NULL) {
if (NULL == package_name_node) {
ROS_ERROR_NAMED("pluginlib.ClassLoader",
"package.xml at %s does not have a <name> tag! Cannot determine package "
"which exports plugin.",
Expand Down Expand Up @@ -334,7 +334,7 @@ std::vector<std::string> ClassLoader<T>::getAllLibraryPathsToTry(
std::vector<std::string> all_paths;
std::vector<std::string> all_paths_without_extension = getCatkinLibraryPaths();
all_paths_without_extension.push_back(getROSBuildLibraryPath(exporting_package_name));
bool debug_library_suffix = (class_loader::systemLibrarySuffix().compare(0, 1, "d") == 0);
bool debug_library_suffix = (0 == class_loader::systemLibrarySuffix().compare(0, 1, "d"));
std::string non_debug_suffix;
if (debug_library_suffix) {
non_debug_suffix = class_loader::systemLibrarySuffix().substr(1);
Expand Down Expand Up @@ -525,7 +525,7 @@ ClassLoader<T>::getPackageFromPluginXMLFilePath(const std::string & plugin_xml_f
std::string package_path = ros::package::getPath(package);

// package_path is a substr of passed plugin xml path
if (plugin_xml_file_path.find(package_path) == 0) {
if (0 == plugin_xml_file_path.find(package_path)) {
package_name = package;
break;
}
Expand Down Expand Up @@ -608,7 +608,7 @@ void ClassLoader<T>::loadLibraryForClass(const std::string & lookup_name)
}

std::string library_path = getClassLibraryPath(lookup_name);
if (library_path == "") {
if ("" == library_path) {
ROS_DEBUG_NAMED("pluginlib.ClassLoader", "No path could be found to the library containing %s.",
lookup_name.c_str());
std::ostringstream error_msg;
Expand Down Expand Up @@ -641,7 +641,7 @@ void ClassLoader<T>::processSingleXMLPluginFile(
tinyxml2::XMLDocument document;
document.LoadFile(xml_file.c_str());
tinyxml2::XMLElement * config = document.RootElement();
if (config == NULL) {
if (NULL == config) {
throw pluginlib::InvalidXMLException(
"XML Document has no Root Element. This likely means the XML is malformed or missing.");
return;
Expand All @@ -662,14 +662,14 @@ void ClassLoader<T>::processSingleXMLPluginFile(
tinyxml2::XMLElement * library = config;
while (library != NULL) {
std::string library_path = library->Attribute("path");
if (library_path.size() == 0) {
if (0 == library_path.size()) {
ROS_ERROR_NAMED("pluginlib.ClassLoader",
"Failed to find Path Attirbute in library element in %s", xml_file.c_str());
continue;
}

std::string package_name = getPackageFromPluginXMLFilePath(xml_file);
if (package_name == "") {
if ("" == package_name) {
ROS_ERROR_NAMED("pluginlib.ClassLoader",
"Could not find package manifest (neither package.xml or deprecated "
"manifest.xml) at same directory level as the plugin XML file %s. "
Expand Down Expand Up @@ -772,7 +772,7 @@ std::string ClassLoader<T>::stripAllButFileFromPath(const std::string & path)
{
std::string only_file;
size_t c = path.find_last_of(getPathSeparator());
if (c == std::string::npos) {
if (std::string::npos == c) {
return path;
} else {
return path.substr(c, path.size());
Expand Down
12 changes: 6 additions & 6 deletions src/plugin_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ string getTypedClassLoaderTemplateWithBaseSet()
string class_with_type_set;
for(unsigned int c = 0; c < class_template.size(); c++)
{
if(class_template.at(c) == '$')
if('$' == class_template.at(c))
class_with_type_set += baseClass();
else if(class_template.at(c) == '@')
else if('@' == class_template.at(c))
class_with_type_set += "#include \"" + baseClassHeader() + "\"";
else
class_with_type_set.push_back(class_template.at(c));
Expand Down Expand Up @@ -317,7 +317,7 @@ vector<string> parseToStringVector(std::string newline_delimited_str)
for(unsigned int c = 0; c < newline_delimited_str.size(); c++)
{
char ch = newline_delimited_str.at(c);
if(ch == '\n')
if('\n' == ch)
{
parse_result.push_back(next);
next = "";
Expand All @@ -333,11 +333,11 @@ void processUserCommand()
{
string verb = commandVerb();

if (verb == "find")
if ("find" == verb)
handleFindPluginRequest();
else if (verb == "list")
else if ("list" == verb)
handleListPluginsRequest();
else if(verb == "load")
else if("load" == verb)
handleLoadPluginRequest();
else
cout << "Error: Unknown verb for plugin_tool, available verbs are 'load', 'list', and 'find'." << endl;
Expand Down
2 changes: 1 addition & 1 deletion test/unique_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TEST(PluginlibUniquePtrTest, workingPlugin) {
try {
pluginlib::UniquePtr<test_base::Fubar> foo = test_loader.createUniqueInstance("pluginlib/foo");
foo->initialize(10.0);
EXPECT_EQ(foo->result(), 100.0);
EXPECT_EQ(100.0, foo->result());
} catch (pluginlib::PluginlibException & ex) {
FAIL() << "Throwing exception: " << ex.what();
return;
Expand Down
2 changes: 1 addition & 1 deletion test/utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TEST(PluginlibTest, workingPlugin) {
try {
boost::shared_ptr<test_base::Fubar> foo = test_loader.createInstance("pluginlib/foo");
foo->initialize(10.0);
EXPECT_EQ(foo->result(), 100.0);
EXPECT_EQ(100.0, foo->result());
} catch (pluginlib::PluginlibException & ex) {
FAIL() << "Throwing exception: " << ex.what();
return;
Expand Down