00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2010 by the OpenStructure authors 00005 // Copyright (C) 2003-2010 by the IPLT authors 00006 // 00007 // This library is free software; you can redistribute it and/or modify it under 00008 // the terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 3.0 of the License, or (at your option) 00010 // any later version. 00011 // This library is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00014 // details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this library; if not, write to the Free Software Foundation, Inc., 00018 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 //------------------------------------------------------------------------------ 00020 #ifndef OST_IO_MAP_IO_PLUGIN_H 00021 #define OST_IO_MAP_IO_PLUGIN_H 00022 00023 #include <boost/shared_ptr.hpp> 00024 #include <boost/filesystem/operations.hpp> 00025 #include <ost/io/module_config.hh> 00026 #include <ost/img/map.hh> 00027 #include <ost/img/alg/normalizer.hh> 00028 #include <ost/io/img/image_format.hh> 00029 #include <ost/io/io_utils.hh> 00030 00031 namespace ost { namespace io { 00032 00033 class DLLEXPORT_OST_IO MapIOHandler { 00034 public: 00035 virtual ~MapIOHandler() {}; 00036 virtual void Import(img::MapHandle& surf, const boost::filesystem::path& loc, const ImageFormatBase& formatstruct) = 0; 00037 virtual void Import(img::MapHandle& surf, std::istream& stream,const ImageFormatBase& formatstruct) = 0; 00038 virtual void Export(const img::MapHandle& ent, const boost::filesystem::path& loc,const ImageFormatBase& formatstruct) const = 0; 00039 virtual void Export(const img::MapHandle& ent, std::ostream& stream,const ImageFormatBase& formatstruct) const = 0; 00040 }; 00041 00042 typedef boost::shared_ptr<MapIOHandler> MapIOHandlerPtr; 00043 00044 class DLLEXPORT_OST_IO MapIOHandlerFactoryBase { 00045 public: 00046 virtual ~MapIOHandlerFactoryBase() {} 00047 virtual bool MatchContent(unsigned char* header) const = 0; 00048 virtual bool MatchType(const ImageFormatBase& type) const = 0; 00049 virtual bool MatchSuffix(const String& loc) const =0 ; 00050 virtual MapIOHandlerPtr Create() const = 0 ; 00051 virtual String GetFormatName() const =0; 00052 virtual String GetFormatDescription() const =0; 00053 00054 }; 00055 00056 typedef boost::shared_ptr<MapIOHandlerFactoryBase> MapIOHandlerFactoryBasePtr; 00057 00058 template <class HANDLER> 00059 class MapIOHandlerFactory: public MapIOHandlerFactoryBase 00060 { 00061 00062 virtual bool MatchContent(unsigned char* header) const { 00063 return HANDLER::MatchContent(header); 00064 } 00065 00066 virtual bool MatchType(const ImageFormatBase& type) const { 00067 return HANDLER::MatchType(type); 00068 } 00069 00070 virtual bool MatchSuffix(const String& loc) const { 00071 return HANDLER::MatchSuffix(loc); 00072 } 00073 00074 virtual String GetFormatName() const { 00075 return HANDLER::GetFormatName(); 00076 } 00077 00078 virtual String GetFormatDescription() const { 00079 return HANDLER::GetFormatDescription(); 00080 } 00081 00082 virtual MapIOHandlerPtr Create() const { 00083 return MapIOHandlerPtr(new HANDLER); 00084 } 00085 }; 00086 00087 00088 }} // ns 00089 00090 #endif
1.5.8