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>
26#include <mia/core/pixeltype.hh>
27#include <mia/core/iodata.hh>
28
30
36struct EXPORT_CORE io_plugin_type {
37 static const char *type_descr;
38
39};
41
56template <typename D>
57class EXPORT_HANDLER TIOPlugin: public TPlugin<D, io_plugin_type>
58{
59
60public:
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
105
106
107
113 const std::string get_preferred_suffix() const;
114protected:
115
116 void add_suffix(const std::string& suffix);
117 const SuffixSet& get_suffixes() const;
118
121private:
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
147EXPORT_CORE extern const char *const io_plugin_property_multi_record;
148EXPORT_CORE extern const char *const io_plugin_property_history_split;
149EXPORT_CORE extern const char *const io_plugin_property_has_attributes;
150EXPORT_CORE extern const char *const io_plugin_property_can_pipe;
151
153
154#endif
virtual void do_get_help_xml(CXMLElement &root) const
This class implements a facade for the xml Element.
Definition: xmlinterface.hh:50
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:58
std::set< std::string > SuffixSet
Definition: ioplugin.hh:70
void add_supported_type(EPixelType t)
add pixel type t to the list of supported types
TIOPlugin(const char *name)
D::type Data
type of the data handled by this plug-in
Definition: ioplugin.hh:62
std::shared_ptr< Data > PData
shared pointer of the data handled by this plug-in
Definition: ioplugin.hh:65
void add_suffixes(std::multimap< std::string, std::string > &map) const
const PixelTypeSet & supported_pixel_types() const
std::set< EPixelType > PixelTypeSet
the type for the supported pixel types of this IO handler
Definition: ioplugin.hh:68
bool save(const std::string &fname, const Data &data) const
const std::string get_preferred_suffix() const
PData load(const std::string &fname) const
void add_suffix(const std::string &suffix)
const SuffixSet & get_suffixes() const
The generic base for all plug-ins.
Definition: plugin_base.hh:172
#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
EXPORT_CORE const char *const io_plugin_property_can_pipe
EXPORT_CORE const char *const io_plugin_property_has_attributes
EXPORT_CORE const char *const io_plugin_property_history_split
EXPORT_CORE const char *const io_plugin_property_multi_record
EPixelType
Definition: pixeltype.hh:33