pluginlib_msgs.cpp
Go to the documentation of this file.
00001 #include <vigir_pluginlib_msgs/pluginlib_msgs.h>
00002 
00003 namespace vigir_pluginlib
00004 {
00005 bool isDescriptionMatching(const msgs::PluginDescription& plugin_description, const msgs::PluginDescription& filter)
00006 {
00007   if (!filter.name.data.empty() && filter.name.data != plugin_description.name.data)
00008     return false;
00009   if (!filter.type_class_package.data.empty() && filter.type_class_package.data != plugin_description.type_class_package.data)
00010     return false;
00011   if (!filter.type_class.data.empty() && filter.type_class.data != plugin_description.type_class.data)
00012     return false;
00013   if (!filter.base_class_package.data.empty() && filter.base_class_package.data != plugin_description.base_class_package.data)
00014     return false;
00015   if (!filter.base_class.data.empty() && filter.base_class.data != plugin_description.base_class.data)
00016     return false;
00017 
00018   return true;
00019 }
00020 
00021 std::vector<vigir_pluginlib_msgs::PluginDescription> filterDescriptionList(const std::vector<vigir_pluginlib_msgs::PluginDescription>& plugin_descriptions, const msgs::PluginDescription& filter, bool inverse)
00022 {
00023   std::vector<vigir_pluginlib_msgs::PluginDescription> filter_list;
00024   filter_list.push_back(filter);
00025   return filterDescriptionList(plugin_descriptions, filter_list, inverse);
00026 }
00027 
00028 std::vector<vigir_pluginlib_msgs::PluginDescription> filterDescriptionList(const std::vector<msgs::PluginDescription>& plugin_descriptions, const std::vector<msgs::PluginDescription>& filter_list, bool inverse)
00029 {
00030   std::vector<msgs::PluginDescription> result;
00031 
00032   for (const msgs::PluginDescription& plugin_description : plugin_descriptions)
00033   {
00034     bool is_matching = false;
00035     for (const msgs::PluginDescription& filter : filter_list)
00036     {
00037       if (isDescriptionMatching(plugin_description, filter))
00038       {
00039         is_matching = true;
00040         break;
00041       }
00042     }
00043 
00044     if (!inverse == is_matching)
00045         result.push_back(plugin_description);
00046   }
00047 
00048   return result;
00049 }
00050 }


vigir_pluginlib_msgs
Author(s): Alexander Stumpf
autogenerated on Tue Sep 13 2016 03:47:28