My Project
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 
60 public:
62  typedef typename D::type Data;
63 
65  typedef typename std::shared_ptr<Data > PData;
66 
68  typedef std::set<EPixelType> PixelTypeSet;
69 
70  typedef std::set<std::string> SuffixSet;
71 
72 
77  TIOPlugin(const char *name);
78 
83  void add_suffixes(std::multimap<std::string, std::string>& map) const;
84 
92  PData load(const std::string& fname) const;
93 
101  bool save(const std::string& fname, const Data& data) const;
102 
104  const PixelTypeSet& supported_pixel_types() const;
105 
106 
107 
113  const std::string get_preferred_suffix() const;
114 protected:
115 
116  void add_suffix(const std::string& suffix);
117  const SuffixSet& get_suffixes() const;
118 
120  void add_supported_type(EPixelType t);
121 private:
122  PixelTypeSet m_typeset;
123 
124  SuffixSet m_suffixes;
125 
130  virtual PData do_load(const std::string& fname) const = 0;
131 
132  void do_get_help_xml(CXMLElement& root) const;
133 
134 
141  virtual bool do_save(const std::string& fname, const typename D::type& data) const = 0;
142 
143  virtual const std::string do_get_preferred_suffix() const;
144 
145 };
146 
147 EXPORT_CORE extern const char *const io_plugin_property_multi_record;
148 EXPORT_CORE extern const char *const io_plugin_property_history_split;
149 EXPORT_CORE extern const char *const io_plugin_property_has_attributes;
150 EXPORT_CORE extern const char *const io_plugin_property_can_pipe;
151 
153 
154 #endif
io_plugin_property_history_split
const EXPORT_CORE char *const io_plugin_property_history_split
iodata.hh
plugin_base.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
CParamTranslator::do_get_help_xml
virtual void do_get_help_xml(CXMLElement &root) const
io_plugin_property_multi_record
const EXPORT_CORE char *const io_plugin_property_multi_record
TIOPlugin::Data
D::type Data
type of the data handled by this plug-in
Definition: ioplugin.hh:62
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition: core/cost.hh:32
CXMLElement
This class implements a facade for the xml Element.
Definition: xmlinterface.hh:49
io_plugin_property_can_pipe
const EXPORT_CORE char *const io_plugin_property_can_pipe
TIOPlugin
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:57
TPlugin
The generic base for all plug-ins.
Definition: plugin_base.hh:171
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
TIOPlugin::PData
std::shared_ptr< Data > PData
shared pointer of the data handled by this plug-in
Definition: ioplugin.hh:65
TIOPlugin::PixelTypeSet
std::set< EPixelType > PixelTypeSet
the type for the supported pixel types of this IO handler
Definition: ioplugin.hh:68
EPixelType
EPixelType
Definition: pixeltype.hh:32
io_plugin_property_has_attributes
const EXPORT_CORE char *const io_plugin_property_has_attributes
pixeltype.hh
TIOPlugin::SuffixSet
std::set< std::string > SuffixSet
Definition: ioplugin.hh:70