00001 // Filename: datagramInputFile.h 00002 // Created by: drose (30Oct00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef DATAGRAMINPUTFILE_H 00020 #define DATAGRAMINPUTFILE_H 00021 00022 #include <pandabase.h> 00023 00024 #include "datagramGenerator.h" 00025 #include "filename.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : DatagramInputFile 00029 // Description : This class can be used to read a binary file that 00030 // consists of an arbitrary header followed by a number 00031 // of datagrams. 00032 //////////////////////////////////////////////////////////////////// 00033 class EXPCL_PANDA DatagramInputFile : public DatagramGenerator { 00034 public: 00035 INLINE DatagramInputFile(); 00036 00037 bool open(Filename filename); 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 INLINE void close(); 00045 00046 private: 00047 bool _read_first_datagram; 00048 bool _error; 00049 ifstream _in_file; 00050 istream *_in; 00051 bool _owns_in; 00052 }; 00053 00054 #include "datagramInputFile.I" 00055 00056 #endif