abstract_plugin_manager.h
Go to the documentation of this file.
00001 /*
00002  *  Copyright 2018, Sebastian Pütz
00003  *
00004  *  Redistribution and use in source and binary forms, with or without
00005  *  modification, are permitted provided that the following conditions
00006  *  are met:
00007  *
00008  *  1. Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  *
00011  *  2. Redistributions in binary form must reproduce the above
00012  *     copyright notice, this list of conditions and the following
00013  *     disclaimer in the documentation and/or other materials provided
00014  *     with the distribution.
00015  *
00016  *  3. Neither the name of the copyright holder nor the names of its
00017  *     contributors may be used to endorse or promote products derived
00018  *     from this software without specific prior written permission.
00019  *
00020  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  *  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031  *  POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  *  abstract_plugin_manager.h
00034  *
00035  *  author: Sebastian Pütz <spuetz@uni-osnabrueck.de>
00036  *
00037  */
00038 
00039 #ifndef MBF_ABSTRACT_NAV__ABSTRACT_PLUGIN_MANAGER_H_
00040 #define MBF_ABSTRACT_NAV__ABSTRACT_PLUGIN_MANAGER_H_
00041 
00042 #include <boost/function.hpp>
00043 
00044 namespace mbf_abstract_nav{
00045 
00046 template <typename PluginType>
00047 class AbstractPluginManager
00048 {
00049  public:
00050 
00051   typedef boost::function<typename PluginType::Ptr(const std::string& plugin)> loadPluginFunction;
00052   typedef boost::function<bool (const std::string& name, const typename PluginType::Ptr& plugin_ptr)> initPluginFunction;
00053 
00054   AbstractPluginManager(
00055       const std::string param_name,
00056       const loadPluginFunction& loadPlugin,
00057       const initPluginFunction& initPlugin
00058   );
00059 
00060   bool loadPlugins();
00061 
00062   bool hasPlugin(const std::string& name);
00063 
00064   std::string getType(const std::string& name);
00065 
00066   const std::vector<std::string>& getLoadedNames();
00067 
00068   typename PluginType::Ptr getPlugin(const std::string& name);
00069 
00070  protected:
00071   std::map<std::string, typename PluginType::Ptr> plugins_;
00072   std::map<std::string, std::string> plugins_type_;
00073   std::vector<std::string> names_;
00074   const std::string param_name_;
00075   const loadPluginFunction loadPlugin_;
00076   const initPluginFunction initPlugin_;
00077 };
00078 } /* namespace mbf_abstract_nav */
00079 
00080 #include "impl/abstract_plugin_manager.tcc"
00081 #endif //MBF_ABSTRACT_NAV__ABSTRACT_PLUGIN_MANAGER_H_


mbf_abstract_nav
Author(s): Sebastian Pütz
autogenerated on Mon Jun 17 2019 20:11:35