00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }}
00089
00090 #endif