Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

LWFile.h

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: LWFile.h,v 1.5 2002/02/16 12:41:39 tksuoran Exp $
00022 */
00023 
00024 
00025 #ifndef TEDDY__IMPORTS__LW_FILE__H
00026 #define TEDDY__IMPORTS__LW_FILE__H
00027 
00028 
00029 #include "Teddy/TeddyConfig.h"
00030 #if defined( TEDDY_INCLUDE_LW_SCENE )
00031 
00032 
00033 #include "Teddy/Imports/lwdef.h"
00034 #include "Teddy/SysSupport/Types.h"
00035 #include "Teddy/SysSupport/Messages.h"
00036 
00037 
00038 //  Forward declarations
00039 namespace Teddy {
00040     namespace SysSupport { class EndianIn; };
00041 };
00042 using namespace Teddy::SysSupport;
00043     
00044 
00045 namespace Teddy   {
00046 namespace Imports {
00047 
00048 
00049 #define DOMAIN_STACK_SIZE             20
00050 #define LWFILE_OPTION_SMOOTH_M         1
00051 #define LWFILE_OPTION_SKIP_MATERIAL_M  2
00052 
00053 
00061 class LWFile {
00062 public:
00063     LWFile( const std::string &fname, Uint32 options );
00064     ~LWFile();
00065 
00066     void    open      ( const std::string &fname );
00067     void    close     ();
00068     void    setOptions( Uint32 options );
00069     Uint32  getOptions();
00070     void    setLen    ( Uint32 len );  //  Length told in the file
00071     Uint32  getLen    () const;
00072     void    setType   ( ID4 file_type );
00073     ID4     getType   () const;
00074 
00075     void    pushDomain( Uint32 len );              
00076     U4      popDomain ( bool skip_rest = false );  
00077     U4      domainLeft();
00078     U4      bytesRead ();
00079 
00080     ID4     read_ID4  ();
00081     I1      read_I1   ();
00082     I2      read_I2   ();
00083     I4      read_I4   ();
00084     U1      read_U1   ();
00085     U2      read_U2   ();
00086     U4      read_U4   ();
00087     F4      read_F4   ();
00088     S0      read_S0   ();
00089     VX      read_VX   ();
00090     COL4    read_COL4 ();
00091     COL12   read_COL12();
00092     VEC12   read_VEC12();
00093     FP4     read_FP4  ();
00094     ANG4    read_ANG4 ();
00095     FNAM0   read_FNAM0();
00096 
00097 protected:
00098     ID4       file_type;
00099     EndianIn *is;
00100     Uint32    domain_end;
00101     Uint32    bytes_read;
00102     Uint32    options;
00103     Uint32    file_len;
00104 
00105     Uint32    d_ends[DOMAIN_STACK_SIZE];  
00106     Uint32   *dsp;                        
00107 };
00108 
00109 
00110 extern char *did( ID4 id );
00111 
00112 
00113 };  //  namespace Imports
00114 };  //  namespace Teddy
00115 
00116 
00117 #endif  //  TEDDY_INCLUDE_LW_SCENE
00118 #endif  //  TEDDY__IMPORTS__LW_FILE__H
00119 
00120