OpenStructure
map_io_handler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 #ifndef OST_IO_MAP_IO_PLUGIN_H
21 #define OST_IO_MAP_IO_PLUGIN_H
22 
23 #include <boost/shared_ptr.hpp>
24 #include <boost/filesystem/operations.hpp>
25 #include <ost/io/module_config.hh>
26 #include <ost/img/map.hh>
27 #include <ost/img/alg/normalizer.hh>
29 #include <ost/io/io_utils.hh>
30 
31 namespace ost { namespace io {
32 
34 public:
35  virtual ~MapIOHandler() {};
36  virtual void Import(img::MapHandle& surf, const boost::filesystem::path& loc, const ImageFormatBase& formatstruct) = 0;
37  virtual void Import(img::MapHandle& surf, std::istream& stream,const ImageFormatBase& formatstruct) = 0;
38  virtual void Export(const img::MapHandle& ent, const boost::filesystem::path& loc,const ImageFormatBase& formatstruct) const = 0;
39  virtual void Export(const img::MapHandle& ent, std::ostream& stream,const ImageFormatBase& formatstruct) const = 0;
40 };
41 
42 typedef boost::shared_ptr<MapIOHandler> MapIOHandlerPtr;
43 
45 public:
47  virtual bool MatchContent(unsigned char* header) const = 0;
48  virtual bool MatchType(const ImageFormatBase& type) const = 0;
49  virtual bool MatchSuffix(const String& loc) const =0 ;
50  virtual MapIOHandlerPtr Create() const = 0 ;
51  virtual String GetFormatName() const =0;
52  virtual String GetFormatDescription() const =0;
53 
54 };
55 
56 typedef boost::shared_ptr<MapIOHandlerFactoryBase> MapIOHandlerFactoryBasePtr;
57 
58 template <class HANDLER>
60 {
61 
62  virtual bool MatchContent(unsigned char* header) const {
63  return HANDLER::MatchContent(header);
64  }
65 
66  virtual bool MatchType(const ImageFormatBase& type) const {
67  return HANDLER::MatchType(type);
68  }
69 
70  virtual bool MatchSuffix(const String& loc) const {
71  return HANDLER::MatchSuffix(loc);
72  }
73 
74  virtual String GetFormatName() const {
75  return HANDLER::GetFormatName();
76  }
77 
78  virtual String GetFormatDescription() const {
79  return HANDLER::GetFormatDescription();
80  }
81 
82  virtual MapIOHandlerPtr Create() const {
83  return MapIOHandlerPtr(new HANDLER);
84  }
85 };
86 
87 
88 }} // ns
89 
90 #endif