Panda3D

datagramInputFile.h

00001 // Filename: datagramInputFile.h
00002 // Created by:  drose (30Oct00)
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 DATAGRAMINPUTFILE_H
00016 #define DATAGRAMINPUTFILE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "datagramGenerator.h"
00021 #include "filename.h"
00022 #include "virtualFile.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : DatagramInputFile
00026 // Description : This class can be used to read a binary file that
00027 //               consists of an arbitrary header followed by a number
00028 //               of datagrams.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDA_PUTIL DatagramInputFile : public DatagramGenerator {
00031 public:
00032   INLINE DatagramInputFile();
00033 
00034   bool open(Filename filename);
00035   bool open(istream &in);
00036 
00037   void close();
00038 
00039   bool read_header(string &header, size_t num_bytes);
00040   virtual bool get_datagram(Datagram &data);
00041   virtual bool is_eof();
00042   virtual bool is_error();
00043 
00044   virtual VirtualFile *get_file();
00045   virtual streampos get_file_pos();
00046 
00047 private:
00048   bool _read_first_datagram;
00049   bool _error;
00050   PT(VirtualFile) _vfile;
00051   pifstream _in_file;
00052   istream *_in;
00053   bool _owns_in;
00054 };
00055 
00056 #include "datagramInputFile.I"
00057 
00058 #endif
 All Classes Functions Variables Enumerations