Fawkes API Fawkes Development Version
|
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 ~PluginLoadException() throw(); 00047 00048 std::string plugin_name() const; 00049 00050 private: 00051 std::string __plugin_name; 00052 }; 00053 00054 class PluginUnloadException : public Exception 00055 { 00056 public: 00057 PluginUnloadException(const char *plugin_type, const char *add_msg = NULL); 00058 }; 00059 00060 00061 class PluginLoader { 00062 public: 00063 00064 PluginLoader(const char *plugin_base_dir, Configuration *config); 00065 ~PluginLoader(); 00066 00067 Plugin * load(const char *plugin_name); 00068 void unload(Plugin *plugin); 00069 00070 std::string get_description(const char *plugin_name); 00071 00072 bool is_loaded(const char *plugin_name); 00073 00074 private: 00075 Module * open_module(const char *plugin_name); 00076 Plugin * create_instance(const char *plugin_name, Module *module); 00077 00078 private: 00079 PluginLoaderData *d; 00080 Configuration *__config; 00081 }; 00082 00083 00084 } // end namespace fawkes 00085 00086 #endif