plugin_base.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_core_plugin_base_hh
22 #define mia_core_plugin_base_hh
23 
24 #include <map>
25 #include <set>
26 #include <string>
27 #include <ostream>
28 
29 #include <boost/filesystem/path.hpp>
30 
31 #include <mia/core/defines.hh>
32 #include <mia/core/module.hh>
33 #include <mia/core/optparam.hh>
35 
37 
39 
40 
42 EXPORT_CORE extern const std::string plugin_help;
43 
53 public:
59  CPluginBase(const char *name);
60 
64  virtual ~CPluginBase();
65 
73  void add_parameter(const std::string& name, CParameter *param);
74 
82  void set_parameters(const CParsedOptions& options);
83 
88  void check_parameters();
89 
91  const char *get_name() const;
92 
94  const std::string get_descr() const;
95 
96 
101  void get_short_help(std::ostream& os) const;
102 
106  virtual void get_help(std::ostream& os) const;
107 
111  void get_help_xml(xmlpp::Element& root) const;
112 
117  void append_interface(CPluginBase *plugin);
118 
120  CPluginBase *next_interface();
121 
126  bool has_property(const char *property) const;
127 
128 
135  void set_module(const PPluginModule& module);
136 
140  PPluginModule get_module() const;
141 
146  void add_dependend_handlers(HandlerHelpMap& handler_map);
147 
148 protected:
153  void add_property(const char *property);
154 
155 private:
156  virtual const std::string do_get_descr() const = 0;
157 
158  virtual void do_get_help_xml(xmlpp::Element& root) const;
159 
160  // plugin name
161  const char *m_name;
162 
163  /* pointer to the next interface in a plugin chain
164  NULL indicates end of chain
165  */
166  CPluginBase *m_next_interface;
167 
168  /*
169  List of paramaters understudd by this plugin
170  */
171  CParamList m_parameters;
172 
173  /*
174  Specific properties of this plug in
175  */
176  CPropertyFlagHolder m_properties;
177 
178  /*
179  The dynamically loadable module that holds the code of this plugin.
180  */
181  PPluginModule m_module;
182 };
183 
184 
197 template <typename D, typename T>
199 public:
201  typedef D PlugData;
202 
204  typedef T PlugType;
205 
211  TPlugin(const char *name);
212 
217  virtual void get_help(std::ostream& os) const;
218 
219 
220 
222  static ::boost::filesystem::path search_path();
223 
225  const std::string get_long_name() const;
226 
227 };
228 
229 
231 
232 #endif