Panda3D

fltRecordReader.h

00001 // Filename: fltRecordReader.h
00002 // Created by:  drose (24Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef FLTRECORDREADER_H
00016 #define FLTRECORDREADER_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "fltOpcode.h"
00021 #include "fltError.h"
00022 
00023 #include "datagram.h"
00024 #include "datagramIterator.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : FltRecordReader
00028 // Description : This class turns an istream into a sequence of
00029 //               FltRecords by reading a sequence of Datagrams and
00030 //               extracting the opcode from each one.  It remembers
00031 //               where it is in the file and what the current record
00032 //               is.
00033 ////////////////////////////////////////////////////////////////////
00034 class FltRecordReader {
00035 public:
00036   FltRecordReader(istream &in);
00037   ~FltRecordReader();
00038 
00039   FltOpcode get_opcode() const;
00040   DatagramIterator &get_iterator();
00041   const Datagram &get_datagram();
00042   int get_record_length() const;
00043 
00044   FltError advance(bool ok_eof = false);
00045 
00046   bool eof() const;
00047   bool error() const;
00048 
00049 private:
00050   void read_next_header();
00051 
00052   istream &_in;
00053   Datagram _datagram;
00054   FltOpcode _opcode;
00055   int _record_length;
00056   DatagramIterator *_iterator;
00057 
00058   FltError _next_error;
00059   FltOpcode _next_opcode;
00060   int _next_record_length;
00061 
00062   enum State {
00063     S_begin,
00064     S_normal,
00065     S_eof,
00066     S_error
00067   };
00068   State _state;
00069 };
00070 
00071 #endif
00072 
00073 
 All Classes Functions Variables Enumerations