Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef VIGIR_PLUGINLIB_PLUGIN_AGGREGATOR_H__
00030 #define VIGIR_PLUGINLIB_PLUGIN_AGGREGATOR_H__
00031
00032 #include <ros/ros.h>
00033
00034 #include <vigir_generic_params/parameter_manager.h>
00035
00036 #include <vigir_pluginlib/plugin_manager.h>
00037
00038
00039
00040 namespace vigir_pluginlib
00041 {
00042 template<class PluginClass>
00043 class PluginAggregator
00044 {
00045 public:
00046
00047 typedef boost::shared_ptr<PluginAggregator<PluginClass>> Ptr;
00048 typedef boost::shared_ptr<const PluginAggregator<PluginClass>> ConstPtr;
00049 typedef boost::weak_ptr<PluginAggregator<PluginClass>> WeakPtr;
00050 typedef boost::weak_ptr<const PluginAggregator<PluginClass>> ConstWeakPtr;
00051
00052 PluginAggregator(const std::string& name = std::string("PluginAggregator"))
00053 : name_(name) {}
00054
00058 virtual void loadPlugins()
00059 {
00060
00061 PluginManager::getPluginsByType(plugins_);
00062
00063 if (plugins_.empty())
00064 ROS_WARN("[%s] loadPlugins: Couldn't find any plugin of type '%s'.", name_.c_str(), vigir_pluginlib::Plugin::getTypeClass<PluginClass>().c_str());
00065 else
00066 {
00067 ROS_INFO("[%s] Plugins loaded:", name_.c_str());
00068 for (const boost::shared_ptr<PluginClass> plugin : plugins_)
00069 {
00070 if (plugin)
00071 ROS_INFO(" %s", plugin->getName().c_str());
00072 }
00073 }
00074 }
00075
00080 virtual std::vector<boost::shared_ptr<PluginClass>> getPlugins() const
00081 {
00082 return plugins_;
00083 }
00084
00089 virtual size_t size() const
00090 {
00091 return plugins_.size();
00092 }
00093
00099 virtual bool loadParams(const vigir_generic_params::ParameterSet& params)
00100 {
00101 bool result = true;
00102
00103 for (const boost::shared_ptr<PluginClass> plugin : plugins_)
00104 {
00105 if (plugin)
00106 result &= plugin->loadParams(params);
00107 }
00108
00109 return result;
00110 }
00111
00112 protected:
00113 std::string name_;
00114 std::vector<boost::shared_ptr<PluginClass>> plugins_;
00115 };
00116 }
00117
00118 #endif