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 
98 
101 
106  bool has_property(const char *property) const;
107 
108 
115  void set_module(const PPluginModule& module);
116 
121 
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
The base class for all plug-ins.
Definition: plugin_base.hh:65
void add_dependend_handlers(HandlerHelpMap &handler_map)
void add_property(const char *property)
void append_interface(CPluginBase *plugin)
virtual ~CPluginBase()
void set_priority(unsigned p)
void set_module(const PPluginModule &module)
bool has_property(const char *property) const
CPluginBase * next_interface()
PPluginModule get_module() const
unsigned get_priority() const
CPluginBase(const char *name)
This class holds a set of properties.
The generic base for all plug-ins.
Definition: plugin_base.hh:172
D PlugData
Typedef for the data type descriptor handled by this plug-in.
Definition: plugin_base.hh:175
TPlugin(const char *name)
T PlugType
Typedef for the plugin type descriptor handled by this plug-in.
Definition: plugin_base.hh:178
static const char * get_type_path_part()
static const char * get_data_path_part()
const std::string get_long_name() const
virtual void get_help(std::ostream &os) const
#define EXPORT_HANDLER
Definition: core/cost.hh:32
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
std::shared_ptr< CPluginModule > PPluginModule
Definition: module.hh:81
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_CORE const std::string plugin_help
standard string to print out help in the factory plug-in handler
static constexpr bool value
Definition: plugin_base.hh:211