From 0ee8c3a8fb2684403a09e7f51ee7d370c27d5a3f Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Sun, 8 May 2011 15:00:57 +0200 Subject: [PATCH] added ProvidesImport/ProvidesExport to map io handler We now flag the DF3 as an "export-only" handler. Fixes BZDNG-247 --- modules/io/src/img/map_io_dat_handler.hh | 2 ++ modules/io/src/img/map_io_df3_handler.hh | 4 ++++ modules/io/src/img/map_io_dm3_handler.hh | 2 ++ modules/io/src/img/map_io_dx_handler.hh | 3 +++ modules/io/src/img/map_io_handler.hh | 14 ++++++++++++-- modules/io/src/img/map_io_mrc_handler.hh | 2 ++ modules/io/src/img/map_io_nanoscope_handler.hh | 2 ++ modules/io/src/img/map_io_png_handler.hh | 2 ++ modules/io/src/img/map_io_situs_handler.hh | 2 ++ modules/io/src/img/map_io_spi_handler.cc | 2 +- modules/io/src/img/map_io_spi_handler.hh | 2 ++ modules/io/src/img/map_io_tiff_handler.hh | 2 ++ modules/io/src/io_manager.cc | 16 ++++++++-------- 13 files changed, 44 insertions(+), 11 deletions(-) diff --git a/modules/io/src/img/map_io_dat_handler.hh b/modules/io/src/img/map_io_dat_handler.hh index c4f130e44..4bc8ce268 100644 --- a/modules/io/src/img/map_io_dat_handler.hh +++ b/modules/io/src/img/map_io_dat_handler.hh @@ -71,6 +71,8 @@ class DLLEXPORT_OST_IO MapIODatHandler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String("Dat"); } static String GetFormatDescription() {return String("Simple binary format for square images");} }; diff --git a/modules/io/src/img/map_io_df3_handler.hh b/modules/io/src/img/map_io_df3_handler.hh index 7682d0131..53fb9bfd1 100644 --- a/modules/io/src/img/map_io_df3_handler.hh +++ b/modules/io/src/img/map_io_df3_handler.hh @@ -60,6 +60,10 @@ class DLLEXPORT_OST_IO DF3MapIOHandler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + + static bool ProvidesImport() { return false; } + static bool ProvidesExport() { return true; } + static String GetFormatName() { return "DF3"; }; static String GetFormatDescription() { return "PovRay Density file format"; }; }; diff --git a/modules/io/src/img/map_io_dm3_handler.hh b/modules/io/src/img/map_io_dm3_handler.hh index 4b1ad827f..89d5f87c1 100644 --- a/modules/io/src/img/map_io_dm3_handler.hh +++ b/modules/io/src/img/map_io_dm3_handler.hh @@ -49,6 +49,8 @@ class DLLEXPORT_OST_IO MapIODm3Handler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String("Dm3"); } static String GetFormatDescription() {return String("Format used by Gatan Inc.'s Digital Micrograph software");} diff --git a/modules/io/src/img/map_io_dx_handler.hh b/modules/io/src/img/map_io_dx_handler.hh index 640862cdc..ca4ee55c2 100644 --- a/modules/io/src/img/map_io_dx_handler.hh +++ b/modules/io/src/img/map_io_dx_handler.hh @@ -63,6 +63,9 @@ class DLLEXPORT_OST_IO MapIODxHandler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& locx); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } + static String GetFormatName() { return String("Dx"); }; static String GetFormatDescription() { return String("Format used by the OpenDX software package"); }; diff --git a/modules/io/src/img/map_io_handler.hh b/modules/io/src/img/map_io_handler.hh index fe43f7878..163d02413 100644 --- a/modules/io/src/img/map_io_handler.hh +++ b/modules/io/src/img/map_io_handler.hh @@ -50,7 +50,8 @@ public: virtual MapIOHandlerPtr Create() const = 0 ; virtual String GetFormatName() const =0; virtual String GetFormatDescription() const =0; - + virtual bool ProvidesImport() const = 0; + virtual bool ProvidesExport() const = 0; }; typedef boost::shared_ptr<MapIOHandlerFactoryBase> MapIOHandlerFactoryBasePtr; @@ -78,7 +79,16 @@ class MapIOHandlerFactory: public MapIOHandlerFactoryBase virtual String GetFormatDescription() const { return HANDLER::GetFormatDescription(); } - + virtual bool ProvidesImport() const + { + return HANDLER::ProvidesImport(); + } + + virtual bool ProvidesExport() const + { + return HANDLER::ProvidesExport(); + } + virtual MapIOHandlerPtr Create() const { return MapIOHandlerPtr(new HANDLER); } diff --git a/modules/io/src/img/map_io_mrc_handler.hh b/modules/io/src/img/map_io_mrc_handler.hh index f1a14f93a..c12096b68 100644 --- a/modules/io/src/img/map_io_mrc_handler.hh +++ b/modules/io/src/img/map_io_mrc_handler.hh @@ -74,6 +74,8 @@ public: static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String("Mrc"); }; static String GetFormatDescription() { return String("Format used by the MRC software package"); }; diff --git a/modules/io/src/img/map_io_nanoscope_handler.hh b/modules/io/src/img/map_io_nanoscope_handler.hh index 177f48e7b..35bfea611 100644 --- a/modules/io/src/img/map_io_nanoscope_handler.hh +++ b/modules/io/src/img/map_io_nanoscope_handler.hh @@ -58,6 +58,8 @@ public: static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String("Nanoscope"); } static String GetFormatDescription() { return String("Format used by software from Veeco"); } }; diff --git a/modules/io/src/img/map_io_png_handler.hh b/modules/io/src/img/map_io_png_handler.hh index cc6a84d4a..337ccc1df 100644 --- a/modules/io/src/img/map_io_png_handler.hh +++ b/modules/io/src/img/map_io_png_handler.hh @@ -56,6 +56,8 @@ public: static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String("Png");} static String GetFormatDescription() { return String("Portable Network Graphic image format");} }; diff --git a/modules/io/src/img/map_io_situs_handler.hh b/modules/io/src/img/map_io_situs_handler.hh index b3a19cb79..4b5a1a360 100644 --- a/modules/io/src/img/map_io_situs_handler.hh +++ b/modules/io/src/img/map_io_situs_handler.hh @@ -55,6 +55,8 @@ class DLLEXPORT_OST_IO MapIOSitusHandler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return "Situs"; }; static String GetFormatDescription() { return "Format used by the Situs software package"; }; }; diff --git a/modules/io/src/img/map_io_spi_handler.cc b/modules/io/src/img/map_io_spi_handler.cc index f55c9a22d..d22897f4e 100644 --- a/modules/io/src/img/map_io_spi_handler.cc +++ b/modules/io/src/img/map_io_spi_handler.cc @@ -212,7 +212,7 @@ void prep_header(spider_header& header, const img::Size& size, const geom::Vec3& for (int counter = 0; counter < 8; ++counter) { header.szITim[counter] = time_for_header[counter]; } - for (int counter = 0; counter < title_for_header.size(); ++counter) { + for (size_t counter = 0; counter < title_for_header.size(); ++counter) { header.szITit[counter] = title_for_header[counter]; } } diff --git a/modules/io/src/img/map_io_spi_handler.hh b/modules/io/src/img/map_io_spi_handler.hh index cf185731c..aa6f9a438 100644 --- a/modules/io/src/img/map_io_spi_handler.hh +++ b/modules/io/src/img/map_io_spi_handler.hh @@ -65,6 +65,8 @@ class DLLEXPORT_OST_IO MapIOSpiHandler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String("Spider"); }; static String GetFormatDescription() { return String("Format used by the Spider software package"); }; diff --git a/modules/io/src/img/map_io_tiff_handler.hh b/modules/io/src/img/map_io_tiff_handler.hh index 5c6985a3d..c3efe9017 100644 --- a/modules/io/src/img/map_io_tiff_handler.hh +++ b/modules/io/src/img/map_io_tiff_handler.hh @@ -100,6 +100,8 @@ class DLLEXPORT_OST_IO MapIOTiffHandler: public MapIOHandler static bool MatchContent(unsigned char* header); static bool MatchType(const ImageFormatBase& type); static bool MatchSuffix(const String& loc); + static bool ProvidesImport() { return true; } + static bool ProvidesExport() { return true; } static String GetFormatName() { return String( "Tiff"); } static String GetFormatDescription() { return String("Tagged Image File Format"); } diff --git a/modules/io/src/io_manager.cc b/modules/io/src/io_manager.cc index 7c274c080..12e714fd6 100644 --- a/modules/io/src/io_manager.cc +++ b/modules/io/src/io_manager.cc @@ -140,7 +140,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat { if(formatstruct.GetFormatString()!="undefined" ){ for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchType(formatstruct)) { + if((*it)->ProvidesImport() && (*it)->MatchType(formatstruct)) { return (*it)->Create(); } } @@ -149,7 +149,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat String match_suf_string=loc.string(); std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower); for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchSuffix(match_suf_string)) { + if((*it)->ProvidesImport() && (*it)->MatchSuffix(match_suf_string)) { return (*it)->Create(); } } @@ -163,7 +163,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerFile(const boost::filesystem::pat infile.close(); for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchContent(header)) { + if((*it)->ProvidesImport() && (*it)->MatchContent(header)) { return (*it)->Create(); } } @@ -177,7 +177,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerStream(std::istream& stream, { if(formatstruct.GetFormatString()!="undefined" ){ for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchType(formatstruct)) { + if((*it)->ProvidesImport() && (*it)->MatchType(formatstruct)) { return (*it)->Create();; } } @@ -188,7 +188,7 @@ MapIOHandlerPtr IOManager::FindMapImportHandlerStream(std::istream& stream, stream.seekg(0,std::ios::beg); for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchContent(header)) { + if((*it)->ProvidesImport() && (*it)->MatchContent(header)) { return (*it)->Create();; } } @@ -202,7 +202,7 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat { if(formatstruct.GetFormatString()!="undefined" ){ for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchType(formatstruct)) { + if((*it)->ProvidesExport() && (*it)->MatchType(formatstruct)) { return (*it)->Create(); } } @@ -216,7 +216,7 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerFile(const boost::filesystem::pat String match_suf_string=loc.string(); std::transform(match_suf_string.begin(),match_suf_string.end(),match_suf_string.begin(),tolower); for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchSuffix(match_suf_string)) { + if((*it)->ProvidesExport() && (*it)->MatchSuffix(match_suf_string)) { return(*it)->Create(); } } @@ -229,7 +229,7 @@ MapIOHandlerPtr IOManager::FindMapExportHandlerStream(std::istream& stream, cons { if(formatstruct.GetFormatString()!="undefined" ){ for(MapIOFList::const_iterator it=map_io_list_.begin(); it!=map_io_list_.end();++it) { - if((*it)->MatchType(formatstruct)) { + if((*it)->ProvidesExport() && (*it)->MatchType(formatstruct)) { return (*it)->Create(); } } -- GitLab