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-2014 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 
167  void add_property(const char *property);
168 
169 private:
170  virtual const std::string do_get_descr() const = 0;
171 
172  virtual void do_get_help_xml(xmlpp::Element& root) const;
173 
174  // plugin name
175  const char *m_name;
176 
177  /* pointer to the next interface in a plugin chain
178  NULL indicates end of chain
179  */
180  CPluginBase *m_next_interface;
181 
182  /*
183  List of paramaters understudd by this plugin
184  */
185  CParamList m_parameters;
186 
187  /*
188  Specific properties of this plug in
189  */
190  CPropertyFlagHolder m_properties;
191 
192  /*
193  The dynamically loadable module that holds the code of this plugin.
194  */
195  PPluginModule m_module;
196 };
197 
198 
211 template <typename D, typename T>
213 public:
215  typedef D PlugData;
216 
218  typedef T PlugType;
219 
225  TPlugin(const char *name);
226 
231  virtual void get_help(std::ostream& os) const;
232 
233 
234 
236  static ::boost::filesystem::path search_path();
237 
239  const std::string get_long_name() const;
240 
241 };
242 
248 template <typename Plugin>
250  static constexpr bool value = false;
251  typedef void Chained;
252 };
253 
255 
256 #endif
D PlugData
Typedef for the data type descriptor handled by this plug-in.
Definition: plugin_base.hh:215
T PlugType
Typedef for the plugin type descriptor handled by this plug-in.
Definition: plugin_base.hh:218
virtual void get_help(std::ostream &os) const
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:43
The base class for parameters used in complex options.
Definition: parameter.hh:49
std::map< std::string, const CPluginHandlerBase * > HandlerHelpMap
A map that is used to collect the plug-in handlers used in a program.
Definition: handlerbase.hh:36
#define EXPORT_HANDLER
Definition: core/cost.hh:32
A class to hold a list of named parameters.
Definition: optparam.hh:42
std::map< std::string, std::string > CParsedOptions
Definition: optionparser.hh:38
static constexpr bool value
Definition: plugin_base.hh:250
std::shared_ptr< CPluginModule > PPluginModule
Definition: module.hh:76
The base class for all plug-ins.
Definition: plugin_base.hh:67
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:110
EXPORT_CORE const std::string plugin_help
standard string to print out help in the factory plug-in handler
This class holds a set of properties.
The generic base for all plug-ins.
Definition: plugin_base.hh:212
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:46