ISIS Core Library 0.7.2 (api 3.0.0)
|
00001 // 00002 // C/C++ Interface: io_interface 00003 // 00004 // Description: 00005 // 00006 // 00007 // Author: Enrico Reimer<reimer@cbs.mpg.de>, (C) 2009 00008 // 00009 // Copyright: See COPYING file that comes with this distribution 00010 // 00011 // 00012 00013 #ifndef IO_INTERFACE_H 00014 #define IO_INTERFACE_H 00015 00016 #ifdef __cplusplus 00017 #include <string> 00018 #include <boost/system/system_error.hpp> 00019 #include "image.hpp" 00020 #include "common.hpp" 00021 #include "../CoreUtils/istring.hpp" 00022 #include "../CoreUtils/progressfeedback.hpp" 00023 00024 namespace isis 00025 { 00026 namespace image_io 00027 { 00028 00030 class FileFormat 00031 { 00032 public: 00033 enum io_modes{read_only=1,write_only=2,both=3}; 00034 protected: 00040 static bool setGender( util::PropertyMap &object, const char *set,const char *entries="female,male,other" ); 00046 static bool hasOrTell( const util::PropertyMap::KeyType &name, const util::PropertyMap &object, LogLevel level ); 00052 template<typename TYPE> static bool 00053 transformOrTell( const util::PropertyMap::KeyType &from, const util::PropertyMap::KeyType &to, util::PropertyMap &object, LogLevel level ) { 00054 if ( hasOrTell( from, object, level ) and object.transform<TYPE>( from, to ) ) { 00055 LOG( Debug, verbose_info ) << "Transformed " << from << " into " << object.propertyValue( to ); 00056 return true; 00057 } 00058 00059 return false; 00060 } 00062 virtual util::istring suffixes(io_modes modes=both)const = 0; 00063 static const float invalid_float; 00064 public: 00065 static void throwGenericError( std::string desc ); 00066 static void throwSystemError( int err, std::string desc = "" ); 00067 boost::filesystem::path plugin_file; 00068 00070 virtual std::pair<std::string, std::string> makeBasename( const std::string &filename )const; 00071 00072 static std::string makeFilename(const util::PropertyMap &img,std::string namePattern); 00073 std::list<std::string> makeUniqueFilenames( const std::list<data::Image> &images, const std::string &namePattern )const; 00074 00075 00077 virtual std::string getName()const = 0; 00078 00089 std::list<util::istring> getSuffixes(io_modes mode = both)const; 00090 00091 00093 virtual util::istring dialects( const std::string &/*filename*/ )const {return util::istring();}; 00094 00096 virtual bool tainted()const {return true;} 00097 00107 virtual int load( std::list<data::Chunk> &chunks, const std::string &filename, const util::istring &dialect, boost::shared_ptr<util::ProgressFeedback> feedback ) 00108 throw( std::runtime_error & ) = 0; //@todo should be locked 00109 00118 virtual void write( const data::Image &image, const std::string &filename, const util::istring &dialect, boost::shared_ptr<util::ProgressFeedback> feedback ) 00119 throw( std::runtime_error & ) = 0; 00120 00130 virtual void write( const std::list<data::Image> &images, const std::string &filename, const util::istring &dialect, boost::shared_ptr<util::ProgressFeedback> feedback ) 00131 throw( std::runtime_error & ); 00132 00133 virtual ~FileFormat() {} 00134 }; 00135 } 00136 } 00137 #else 00138 typedef struct FileFormat FileFormat; 00139 #endif 00140 00141 00142 #ifdef __cplusplus 00143 extern "C" { 00144 #endif 00145 00146 #if defined(__STDC__) || defined(__cplusplus) 00147 #ifdef WIN32 00148 extern __declspec( dllexport ) isis::image_io::FileFormat *factory(); 00149 #else 00150 extern isis::image_io::FileFormat *factory(); 00151 #endif 00152 #else 00153 #ifdef WIN32 00154 extern __declspec( dllexport ) FileFormat *factory(); 00155 #else 00156 extern FileFormat *factory(); 00157 #endif 00158 #endif 00159 00160 #ifdef __cplusplus 00161 } 00162 #endif 00163 00164 #endif //IO_INTERFACE_H