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-2013 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  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(xmlpp::Element& root) const;
132 
133 
140  virtual bool do_save(const std::string& fname, const typename D::type& data) const = 0;
141 
142  virtual 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 
151 
152 #endif