Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGSceneFileHandler.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
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     /*==========================  PUBLIC  =================================*/
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     /*=========================  PROTECTED  ===============================*/
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     /*==========================  PRIVATE  ================================*/
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

Generated on Thu Aug 25 04:09:07 2005 for OpenSG by  doxygen 1.4.3