Panda3D
|
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 "fileReference.h" 00023 #include "virtualFile.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : DatagramInputFile 00027 // Description : This class can be used to read a binary file that 00028 // consists of an arbitrary header followed by a number 00029 // of datagrams. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PUTIL DatagramInputFile : public DatagramGenerator { 00032 PUBLISHED: 00033 INLINE DatagramInputFile(); 00034 INLINE ~DatagramInputFile(); 00035 00036 bool open(const FileReference *file); 00037 INLINE bool open(const Filename &filename); 00038 bool open(istream &in, const Filename &filename = Filename()); 00039 INLINE istream &get_stream(); 00040 00041 void close(); 00042 00043 bool read_header(string &header, size_t num_bytes); 00044 virtual bool get_datagram(Datagram &data); 00045 virtual bool save_datagram(SubfileInfo &info); 00046 virtual bool is_eof(); 00047 virtual bool is_error(); 00048 00049 virtual const Filename &get_filename(); 00050 virtual const FileReference *get_file(); 00051 virtual VirtualFile *get_vfile(); 00052 virtual streampos get_file_pos(); 00053 00054 private: 00055 bool _read_first_datagram; 00056 bool _error; 00057 CPT(FileReference) _file; 00058 PT(VirtualFile) _vfile; 00059 istream *_in; 00060 bool _owns_in; 00061 Filename _filename; 00062 }; 00063 00064 #include "datagramInputFile.I" 00065 00066 #endif