Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
loader.h
1 
2 /***************************************************************************
3  * loader.h - Loads plugins from .so shared objects
4  *
5  * Created: Wed Aug 23 15:18:13 2006
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __PLUGIN_LOADER_H_
25 #define __PLUGIN_LOADER_H_
26 
27 #include <core/plugin.h>
28 #include <core/exception.h>
29 
30 #include <string>
31 
32 namespace fawkes {
33 #if 0 /* just to make Emacs auto-indent happy */
34 }
35 #endif
36 
37 class Module;
38 class Configuration;
39 class ModuleManager;
40 
42 {
43  public:
44  PluginLoadException(const char *plugin, const char *message);
45  PluginLoadException(const char *plugin, const char *message, Exception &e);
46  ~PluginLoadException() throw();
47 
48  std::string plugin_name() const;
49 
50  private:
51  std::string __plugin_name;
52 };
53 
55 {
56  public:
57  PluginUnloadException(const char *plugin_type, const char *add_msg = NULL);
58 };
59 
60 
61 class PluginLoader {
62  public:
63 
64  PluginLoader(const char *plugin_base_dir, Configuration *config);
65  ~PluginLoader();
66 
67  Plugin * load(const char *plugin_name);
68  void unload(Plugin *plugin);
69 
70  std::string get_description(const char *plugin_name);
71 
72  bool is_loaded(const char *plugin_name);
73 
74  ModuleManager * get_module_manager() const;
75 
76  private:
77  Module * open_module(const char *plugin_name);
78  Plugin * create_instance(const char *plugin_name, Module *module);
79 
80  private:
81  class Data;
82 
83  Data *d;
84  Configuration *__config;
85 };
86 
87 
88 } // end namespace fawkes
89 
90 #endif