loader.h

00001
00002 /***************************************************************************
00003  *  loader.h - Loads plugins from .so shared objects
00004  *
00005  *  Created: Wed Aug 23 15:18:13 2006
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __PLUGIN_LOADER_H_
00025 #define __PLUGIN_LOADER_H_
00026 
00027 #include <core/plugin.h>
00028 #include <core/exception.h>
00029
00030 #include <string>
00031
00032 namespace fawkes {
00033 #if 0 /* just to make Emacs auto-indent happy */
00034 }
00035 #endif
00036 
00037 class Module;
00038 class Configuration;
00039 class PluginLoaderData;
00040
00041 class PluginLoadException : public Exception
00042 {
00043  public:
00044   PluginLoadException(const char *plugin, const char *message);
00045   PluginLoadException(const char *plugin, const char *message, Exception &e);
00046 };
00047
00048 class PluginUnloadException : public Exception
00049 {
00050  public:
00051   PluginUnloadException(const char *plugin_type, const char *add_msg = NULL);
00052 };
00053
00054
00055 class PluginLoader {
00056  public:
00057
00058   PluginLoader(const char *plugin_base_dir, Configuration *config);
00059   ~PluginLoader();
00060
00061   Plugin * load(const char *plugin_name);
00062   void     unload(Plugin *plugin);
00063
00064   std::string  get_description(const char *plugin_name);
00065
00066   bool     is_loaded(const char *plugin_name);
00067
00068  private:
00069   Module * open_module(const char *plugin_name);
00070   Plugin * create_instance(const char *plugin_name, Module *module);
00071
00072  private:
00073   PluginLoaderData *d;
00074   Configuration    *__config;
00075 };
00076
00077
00078 } // end namespace fawkes
00079
00080 #endif