00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef OSGIMAGEFILEHANDLER_CLASS_DECLARATION
00040 #define OSGIMAGEFILEHANDLER_CLASS_DECLARATION
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <list>
00046 #include <map>
00047
00048 #include <OSGSystemDef.h>
00049 #include <OSGBaseTypes.h>
00050 #include <OSGIDStringLink.h>
00051 #include <OSGImageFileType.h>
00052
00053
00054 OSG_BEGIN_NAMESPACE
00055
00056 class PathHandler;
00057
00062 class OSG_SYSTEMLIB_DLLMAPPING ImageFileHandler {
00063
00064 friend class ImageFileType;
00065
00066
00067 public:
00068
00072 virtual ~ImageFileHandler (void);
00073
00075
00079 virtual ImagePtr read ( const char *fileName, const char *mimeType = 0);
00080
00081 virtual bool read ( ImagePtr &image,
00082 const char *fileName, const char *mimeType = 0);
00083
00084 virtual bool write ( const ImagePtr &image,
00085 const char *fileName, const char *mimeType = 0);
00086
00088
00092 virtual PathHandler* getPathHandler(void );
00093 virtual void setPathHandler(PathHandler *pPathHandler);
00094
00096
00100 virtual UInt64 restore ( ImagePtr &image,
00101 const UChar8 *buffer, Int32 memSize = -1 );
00102
00103 virtual UInt64 store ( const ImagePtr &image, const char *mimeType,
00104 UChar8 *buffer, Int32 memSize = -1 );
00105
00106 virtual UChar8* store ( const ImagePtr &image, UInt64 &memSize,
00107 const char *mimeType = 0);
00109
00113 ImageFileType * getFileType ( const char *mimeType,
00114 const char *fileName = 0,
00115 bool validateHeader = false);
00116
00117 ImageFileType * getDefaultType (void);
00118
00119 virtual int getSuffixList(std::list<const Char8*> & suffixList,
00120 UInt32 flags = ImageFileType::OSG_READ_SUPPORTED |
00121 ImageFileType::OSG_WRITE_SUPPORTED);
00122
00124
00128 void dump (void);
00129
00131
00135 static ImageFileHandler & the (void);
00136
00139
00140 protected:
00141
00142
00143 private:
00144
00145 static ImageFileHandler *_the;
00146
00147 std::map<IDString, ImageFileType *> _suffixTypeMap;
00148
00149 static bool addImageFileType (ImageFileType &fileType);
00150
00151 PathHandler* _pPathHandler;
00152
00153 static const std::string _fileNameKey;
00154
00155 static const std::string _fullFilePathKey;
00156
00157
00161 ImageFileHandler (void);
00162 ImageFileHandler(const ImageFileHandler &obj);
00163
00165 };
00166
00167 typedef ImageFileHandler* ImageFileHandlerP;
00168
00169 OSG_END_NAMESPACE
00170
00171 #endif // OSGIMAGEFILEHANDLER_CLASS_DECLARATION