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 
44 
55  ~PrepareTestPluginPath();
56 
57 };
58 
68 public:
74  CPluginBase(const char *name);
75 
79  virtual ~CPluginBase();
80 
88  void add_parameter(const std::string& name, CParameter *param);
89 
97  void set_parameters(const CParsedOptions& options);
98 
103  void check_parameters();
104 
106  const char *get_name() const;
107 
109  const std::string get_descr() const;
110 
111 
116  void get_short_help(std::ostream& os) const;
117 
121  virtual void get_help(std::ostream& os) const;
122 
126  void get_help_xml(xmlpp::Element& root) const;
127 
132  void append_interface(CPluginBase *plugin);
133 
135  CPluginBase *next_interface();
136 
141  bool has_property(const char *property) const;
142 
143 
150  void set_module(const PPluginModule& module);
151 
155  PPluginModule get_module() const;
156 
161  void add_dependend_handlers(HandlerHelpMap& handler_map);
162 
163 protected:
168  void add_property(const char *property);
169 
170 private:
171  virtual const std::string do_get_descr() const = 0;
172 
173  virtual void do_get_help_xml(xmlpp::Element& root) const;
174 
175  // plugin name
176  const char *m_name;
177 
178  /* pointer to the next interface in a plugin chain
179  NULL indicates end of chain
180  */
181  CPluginBase *m_next_interface;
182 
183  /*
184  List of paramaters understudd by this plugin
185  */
186  CParamList m_parameters;
187 
188  /*
189  Specific properties of this plug in
190  */
191  CPropertyFlagHolder m_properties;
192 
193  /*
194  The dynamically loadable module that holds the code of this plugin.
195  */
196  PPluginModule m_module;
197 };
198 
199 
212 template <typename D, typename T>
214 public:
216  typedef D PlugData;
217 
219  typedef T PlugType;
220 
226  TPlugin(const char *name);
227 
232  virtual void get_help(std::ostream& os) const;
233 
234 
235 
237  static ::boost::filesystem::path search_path();
238 
240  const std::string get_long_name() const;
241 
242 };
243 
244 
246 
247 #endif