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 
52  ~PrepareTestPluginPath();
53 
54 };
55 
65 public:
71  CPluginBase(const char *name);
72 
76  virtual ~CPluginBase();
77 
78 
84  void set_priority(unsigned p);
85 
89  unsigned get_priority() const;
90 
91 
96  void append_interface(CPluginBase *plugin);
97 
99  CPluginBase *next_interface();
100 
105  bool has_property(const char *property) const;
106 
107 
114  void set_module(const PPluginModule& module);
115 
119  PPluginModule get_module() const;
120 
125  void add_dependend_handlers(HandlerHelpMap& handler_map);
126 
131  void add_property(const char *property);
132 
133 
134 private:
135 
136 
137  /* pointer to the next interface in a plugin chain
138  NULL indicates end of chain
139  */
140  CPluginBase *m_next_interface;
141 
142  /*
143  Specific properties of this plug in
144  */
145  CPropertyFlagHolder m_properties;
146 
147  unsigned m_priority;
148 
149  /*
150  The dynamically loadable module that holds the code of this plugin.
151  */
152  PPluginModule m_module;
153 
154 };
155 
156 
169 template <typename D, typename T>
171 public:
173  typedef D PlugData;
174 
176  typedef T PlugType;
177 
183  TPlugin(const char *name);
184 
189  virtual void get_help(std::ostream& os) const;
190 
191 
192  static const char * get_data_path_part();
193 
194  static const char * get_type_path_part();
195 
196 
198  const std::string get_long_name() const;
199 
200 };
201 
207 template <typename Plugin>
209  static constexpr bool value = false;
210  typedef void Chained;
211 };
212 
214 
215 #endif
D PlugData
Typedef for the data type descriptor handled by this plug-in.
Definition: plugin_base.hh:173
T PlugType
Typedef for the plugin type descriptor handled by this plug-in.
Definition: plugin_base.hh:176
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
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
#define EXPORT_HANDLER
Definition: core/cost.hh:32
std::shared_ptr< CPluginModule > PPluginModule
Definition: module.hh:80
The base class for all plug-ins.
Definition: plugin_base.hh:64
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
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:170
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36