My Project
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-2017 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 
30 #include <mia/core/module.hh>
32 
34 
36 
37 
39 EXPORT_CORE extern const std::string plugin_help;
40 
41 
53 
54 };
55 
65 {
66 public:
72  CPluginBase(const char *name);
73 
77  virtual ~CPluginBase();
78 
79 
85  void set_priority(unsigned p);
86 
90  unsigned get_priority() const;
91 
92 
97  void append_interface(CPluginBase *plugin);
98 
100  CPluginBase *next_interface();
101 
106  bool has_property(const char *property) const;
107 
108 
115  void set_module(const PPluginModule& module);
116 
120  PPluginModule get_module() const;
121 
126  void add_dependend_handlers(HandlerHelpMap& handler_map);
127 
132  void add_property(const char *property);
133 
134 
135 private:
136 
137 
138  /* pointer to the next interface in a plugin chain
139  NULL indicates end of chain
140  */
141  CPluginBase *m_next_interface;
142 
143  /*
144  Specific properties of this plug in
145  */
146  CPropertyFlagHolder m_properties;
147 
148  unsigned m_priority;
149 
150  /*
151  The dynamically loadable module that holds the code of this plugin.
152  */
153  PPluginModule m_module;
154 
155 };
156 
157 
170 template <typename D, typename T>
172 {
173 public:
175  typedef D PlugData;
176 
178  typedef T PlugType;
179 
185  TPlugin(const char *name);
186 
191  virtual void get_help(std::ostream& os) const;
192 
193 
194  static const char *get_data_path_part();
195 
196  static const char *get_type_path_part();
197 
198 
200  const std::string get_long_name() const;
201 
202 };
203 
209 template <typename Plugin>
211  static constexpr bool value = false;
212  typedef void Chained;
213 };
214 
216 
217 #endif
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
module.hh
TPlugin::PlugType
T PlugType
Typedef for the plugin type descriptor handled by this plug-in.
Definition: plugin_base.hh:178
import_handler.hh
plugin_help
const EXPORT_CORE std::string plugin_help
standard string to print out help in the factory plug-in handler
CPluginBase
The base class for all plug-ins.
Definition: plugin_base.hh:64
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
HandlerHelpMap
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:35
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition: core/cost.hh:32
plugin_can_chain::Chained
void Chained
Definition: plugin_base.hh:212
CPropertyFlagHolder
This class holds a set of properties.
Definition: property_flags.hh:41
PPluginModule
std::shared_ptr< CPluginModule > PPluginModule
Definition: module.hh:81
TPlugin
The generic base for all plug-ins.
Definition: plugin_base.hh:171
plugin_can_chain::value
static constexpr bool value
Definition: plugin_base.hh:211
TPlugin::PlugData
D PlugData
Typedef for the data type descriptor handled by this plug-in.
Definition: plugin_base.hh:175
plugin_can_chain
Definition: plugin_base.hh:210
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
CParamTranslator::get_help
void get_help(std::ostream &os) const
paramtranslator.hh
CParamTranslator
Definition: paramtranslator.hh:34
property_flags.hh
PrepareTestPluginPath
Definition: plugin_base.hh:50