ioplugin.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 ph_ioplugin_hh
22 #define ph_ioplugin_hh
23 
24 #include <set>
25 #include <mia/core/plugin_base.hh>
26 #include <mia/core/pixeltype.hh>
27 #include <mia/core/iodata.hh>
28 
30 
36 struct EXPORT_CORE io_plugin_type {
37  static const char *type_descr;
38 
39 };
41 
56 template <typename D>
57 class EXPORT_HANDLER TIOPlugin: public TPlugin<D, io_plugin_type> {
58 
59 public:
61  typedef typename D::type Data;
62 
64  typedef typename std::shared_ptr<Data > PData;
65 
67  typedef std::set<EPixelType> PixelTypeSet;
68 
69  typedef std::set<std::string> SuffixSet;
70 
71 
76  TIOPlugin(const char *name);
77 
82  void add_suffixes(std::multimap<std::string, std::string>& map) const;
83 
91  PData load(const std::string& fname) const;
92 
100  bool save(const std::string& fname, const Data& data) const;
101 
103  const PixelTypeSet& supported_pixel_types() const;
104 
105 
106 
112  const std::string get_preferred_suffix() const;
113 protected:
114 
115  void add_suffix(const std::string& suffix);
116  const SuffixSet& get_suffixes() const;
117 
119  void add_supported_type(EPixelType t);
120 private:
121  PixelTypeSet m_typeset;
122 
123  SuffixSet m_suffixes;
124 
129  virtual PData do_load(const std::string& fname) const = 0;
130 
131  void do_get_help_xml(CXMLElement& root) const;
132 
133 
140  virtual bool do_save(const std::string& fname, const typename D::type& data) const = 0;
141 
142  virtual const std::string do_get_preferred_suffix() const;
143 
144 };
145 
146 EXPORT_CORE extern const char * const io_plugin_property_multi_record;
147 EXPORT_CORE extern const char * const io_plugin_property_history_split;
148 EXPORT_CORE extern const char * const io_plugin_property_has_attributes;
149 EXPORT_CORE extern const char * const io_plugin_property_can_pipe;
150 
152 
153 #endif
EXPORT_CORE const char *const io_plugin_property_can_pipe
EPixelType
Definition: pixeltype.hh:32
std::shared_ptr< Data > PData
shared pointer of the data handled by this plug-in
Definition: ioplugin.hh:64
std::set< EPixelType > PixelTypeSet
the type for the supported pixel types of this IO handler
Definition: ioplugin.hh:67
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:57
EXPORT_CORE const char *const io_plugin_property_has_attributes
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_HANDLER
Definition: core/cost.hh:32
EXPORT_CORE const char *const io_plugin_property_history_split
D::type Data
type of the data handled by this plug-in
Definition: ioplugin.hh:61
EXPORT_CORE const char *const io_plugin_property_multi_record
This class implements a facade for the xml Element.
Definition: xmlinterface.hh:49
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
std::set< std::string > SuffixSet
Definition: ioplugin.hh:69
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