00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00027
00028
00029
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