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 _OSGSCENEFILEHANDLER_H_
00040 #define _OSGSCENEFILEHANDLER_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <string>
00046 #include <list>
00047 #include <map>
00048 #include <iostream>
00049
00050 #include <OSGSystemDef.h>
00051 #include <OSGBaseTypes.h>
00052 #include <OSGSceneFileType.h>
00053 #include <OSGPathHandler.h>
00054
00055 OSG_BEGIN_NAMESPACE
00056
00057 class GraphOpSeq;
00058
00063 class OSG_SYSTEMLIB_DLLMAPPING SceneFileHandler
00064 {
00065
00066 public:
00067
00068 typedef std::vector<FieldContainerPtr> FCPtrStore;
00069
00070
00074 static SceneFileHandler &the(void);
00075
00077
00081 virtual ~SceneFileHandler(void);
00082
00084
00088 virtual SceneFileType *getFileType(const Char8 *fileNameOrExtension);
00089
00090 virtual int getSuffixList(std::list<const Char8*> & suffixList,
00091 UInt32 flags = SceneFileType::OSG_READ_SUPPORTED |
00092 SceneFileType::OSG_WRITE_SUPPORTED);
00093
00095
00099 typedef void (*progresscbfp) (UInt32 p);
00100 void setReadProgressCB(progresscbfp fp);
00101 progresscbfp getReadProgressCB(void);
00102
00104
00108 virtual NodePtr read (std::istream &is, const Char8* ext,
00109 GraphOpSeq *graphOpSeq = _defaultgraphOpSeq);
00110
00111 virtual FCPtrStore readTopNodes (std::istream &is, const Char8* ext,
00112 GraphOpSeq *graphOpSeq = _defaultgraphOpSeq);
00113
00114 virtual NodePtr read (const Char8 *fileName,
00115 GraphOpSeq *graphOpSeq = _defaultgraphOpSeq);
00116
00117 virtual FCPtrStore readTopNodes (const Char8 *fileName,
00118 GraphOpSeq *graphOpSeq = _defaultgraphOpSeq);
00119
00121
00125 virtual bool write(const NodePtr &node, std::ostream &os, const Char8 *ext, bool compress = false);
00126 virtual bool write(const NodePtr &node, const Char8 *fileName, bool compress = false);
00127
00129
00133 virtual PathHandler* getPathHandler(void );
00134 virtual void setPathHandler(PathHandler *pathHandler);
00135
00137
00141 virtual GraphOpSeq *getDefaultGraphOp(void );
00142 virtual void setDefaultGraphOp(GraphOpSeq *graphOpSeq);
00143
00145
00149 virtual bool setOptions(const Char8 *suffix, const Char8 *options);
00150 virtual const Char8 *getOptions(const Char8 *suffix);
00151
00153
00157 void print (void);
00158
00160
00161 protected:
00162
00163 typedef std::list< SceneFileType *> FileTypeList;
00164 typedef std::map <IDString, FileTypeList *> FileTypeMap;
00165
00166 struct FindOverride
00167 {
00168 UInt32 uiRefPriority;
00169
00170 bool operator() (SceneFileType *fileTypeP);
00171 };
00172
00173
00177 static SceneFileHandler *_the;
00178
00179 FileTypeMap _suffixTypeMap;
00180
00181
00182 static bool addSceneFileType(SceneFileType &fileType);
00183 static bool subSceneFileType(SceneFileType &fileType);
00184
00186
00190 SceneFileHandler(void);
00191 SceneFileHandler(const SceneFileHandler &obj);
00192
00194
00195 private:
00196
00197 friend class OSG_SYSTEMLIB_DLLMAPPING SceneFileType;
00198
00199 std::string initPathHandler(const Char8 *fileName);
00200
00202 void operator =(const SceneFileHandler &source);
00203
00204 typedef struct
00205 {
00206 UInt64 length;
00207 std::istream *is;
00208 } progressS;
00209
00210 void startReadProgressThread(std::istream &is);
00211 void stopReadProgressThread(void);
00212 static void readProgress(void *data);
00213
00214 progresscbfp _readProgressFP;
00215 progressS _progressData;
00216 bool _readReady;
00217
00218 PathHandler *_pathHandler;
00219 PathHandler _defaultPathHandler;
00220
00221 static GraphOpSeq *_defaultgraphOpSeq;
00222
00223 };
00224
00225 typedef SceneFileHandler* SceneFileHandlerP;
00226
00227 OSG_END_NAMESPACE
00228
00229 #define OSGSCENEFILEHANDLER_HEADER_CVSID "@(#)$Id: $"
00230
00231 #endif // OSGIMAGEFILEHANDLER_CLASS_DECLARATION