ISIS Core Library 0.7.2 (api 3.0.0)

/scr/tee1/isis/lib/Core/DataStorage/io_factory.hpp

Go to the documentation of this file.
00001 //
00002 // C++ Interface: io_factory
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 
00014 
00015 #ifndef IO_FACTORY_H
00016 #define IO_FACTORY_H
00017 
00018 #include <map>
00019 #include <string>
00020 #include <boost/shared_ptr.hpp>
00021 #include <boost/regex.hpp>
00022 #define BOOST_FILESYSTEM_VERSION 2 //@todo switch to 3 as soon as we drop support for boost < 1.44
00023 #include <boost/filesystem.hpp>
00024 
00025 #include "io_interface.h"
00026 #include "../CoreUtils/progressfeedback.hpp"
00027 
00028 //????
00029 #include "chunk.hpp"
00030 #include "image.hpp"
00031 
00032 namespace isis
00033 {
00034 namespace data
00035 {
00036 
00037 class IOFactory
00038 {
00039 public:
00040     typedef boost::shared_ptr< image_io::FileFormat> FileFormatPtr;
00041     typedef std::list<FileFormatPtr> FileFormatList;
00042     friend class util::Singletons;
00043 
00044 private:
00045     boost::shared_ptr<util::ProgressFeedback> m_feedback;
00046 public:
00055     static std::list<data::Image> load( const util::slist &paths, util::istring suffix_override = "", util::istring dialect = "" );
00063     static std::list<data::Image> load( const std::string &path, util::istring suffix_override = "", util::istring dialect = "" );
00072     static size_t load( std::list<data::Chunk> &chunks, const std::string &path, util::istring suffix_override = "", util::istring dialect = "" );
00073 
00074     static bool write( const data::Image &image, const std::string &path, util::istring suffix_override = "", util::istring dialect = "" );
00075     static bool write( std::list<data::Image> images, const std::string &path, util::istring suffix_override = "", util::istring dialect = "" );
00076 
00078     static FileFormatList getFormats();
00079 
00080     static void setProgressFeedback( boost::shared_ptr<util::ProgressFeedback> feedback );
00081 
00088     static FileFormatList getFileFormatList( std::string filename, util::istring suffix_override = "", util::istring dialect = "" );
00096     static std::list<data::Image> chunkListToImageList( std::list<Chunk> &chunks );
00097 protected:
00098     size_t loadFile( std::list<Chunk> &ret, const boost::filesystem::path &filename, util::istring suffix_override = "", util::istring dialect = "" );
00099     size_t loadPath( std::list<Chunk> &ret, const boost::filesystem::path &path, util::istring suffix_override = "", util::istring dialect = "" );
00100 
00101     static IOFactory &get();
00102     IOFactory();//shall not be created directly
00103     FileFormatList io_formats;
00104 
00105     /*
00106      * each ImageFormat will be registered in a map after plugin has been loaded
00107      * @param plugin pointer to the plugin to register
00108      *
00109      * @return true if registration was successful, false otherwise
00110      * */
00111     bool registerFileFormat( const FileFormatPtr plugin );
00112     unsigned int findPlugins( const std::string &path );
00113 private:
00118     std::map<util::istring, FileFormatList> io_suffix;
00119     IOFactory &operator =( IOFactory & ); //dont do that
00120 };
00121 
00122 }
00123 }
00124 
00125 #endif //IO_FACTORY_H