Panda3D

Loading...
Searching...
No Matches
datagramInputFile.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file datagramInputFile.h
10 * @author drose
11 * @date 2000-10-30
12 */
13
14#ifndef DATAGRAMINPUTFILE_H
15#define DATAGRAMINPUTFILE_H
16
17#include "pandabase.h"
18
19#include "datagramGenerator.h"
20#include "filename.h"
21#include "fileReference.h"
22#include "virtualFile.h"
23
24/**
25 * This class can be used to read a binary file that consists of an arbitrary
26 * header followed by a number of datagrams.
27 */
28 class EXPCL_PANDA_PUTIL DatagramInputFile : public DatagramGenerator {
29PUBLISHED:
30 INLINE DatagramInputFile();
31 INLINE ~DatagramInputFile();
32
33 bool open(const FileReference *file);
34 INLINE bool open(const Filename &filename);
35 bool open(std::istream &in, const Filename &filename = Filename());
36 INLINE std::istream &get_stream();
37
38 void close();
39
40 bool read_header(std::string &header, size_t num_bytes);
41 virtual bool get_datagram(Datagram &data);
42 virtual bool save_datagram(SubfileInfo &info);
43 virtual bool is_eof();
44 virtual bool is_error();
45
46 virtual const Filename &get_filename();
47 virtual time_t get_timestamp() const;
48 virtual const FileReference *get_file();
49 virtual VirtualFile *get_vfile();
50 virtual std::streampos get_file_pos();
51
52 private:
53 bool _read_first_datagram;
54 bool _error;
55 CPT(FileReference) _file;
56 PT(VirtualFile) _vfile;
57 std::istream *_in;
58 bool _owns_in;
59 Filename _filename;
60 time_t _timestamp;
61};
62
63#include "datagramInputFile.I"
64
65#endif
DatagramGenerator::get_file_pos
virtual std::streampos get_file_pos()
Returns the current file position within the data stream, if any, or 0 if the file position is not me...
Definition datagramGenerator.cxx:90
DatagramGenerator::get_file
virtual const FileReference * get_file()
Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagr...
Definition datagramGenerator.cxx:68
DatagramGenerator::get_filename
virtual const Filename & get_filename()
Returns the filename that provides the source for these datagrams, if any, or empty string if the dat...
Definition datagramGenerator.cxx:45
DatagramGenerator::get_timestamp
virtual time_t get_timestamp() const
Returns the on-disk timestamp of the file that was read, at the time it was opened,...
Definition datagramGenerator.cxx:59
DatagramGenerator::save_datagram
virtual bool save_datagram(SubfileInfo &info)
Skips over the next datagram without extracting it, but saves the relevant file information in the Su...
Definition datagramGenerator.cxx:36
DatagramGenerator::DatagramGenerator
DatagramGenerator()
Does nothing since this is class is just the definition of an interface.
Definition datagramGenerator.I:18
DatagramGenerator::get_vfile
virtual VirtualFile * get_vfile()
Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagram...
Definition datagramGenerator.cxx:77
DatagramInputFile::get_datagram
virtual bool get_datagram(Datagram &data)
Reads the next datagram from the file.
Definition datagramInputFile.cxx:126
DatagramInputFile::read_header
bool read_header(std::string &header, size_t num_bytes)
Reads a sequence of bytes from the beginning of the datagram file.
Definition datagramInputFile.cxx:104
DatagramInputFile::is_eof
virtual bool is_eof()
Returns true if the file has reached the end-of-file.
Definition datagramInputFile.cxx:302
DatagramInputFile::close
void close()
Closes the file.
Definition datagramInputFile.cxx:80
DatagramInputFile::open
bool open(const FileReference *file)
Opens the indicated filename for reading.
Definition datagramInputFile.cxx:33
DatagramInputFile::is_error
virtual bool is_error()
Returns true if the file has reached an error condition.
Definition datagramInputFile.cxx:310
DatagramInputFile::get_stream
std::istream & get_stream()
Returns the istream represented by the input file.
Definition datagramInputFile.I:47
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FileReference
Keeps a reference-counted pointer to a file on disk.
Definition fileReference.h:26
Filename
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
SubfileInfo
This class records a particular byte sub-range within an existing file on disk.
Definition subfileInfo.h:26
VirtualFile
The abstract base class for a file or directory within the VirtualFileSystem.
Definition virtualFile.h:35
datagramGenerator.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagramInputFile.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
fileReference.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
filename.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtualFile.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.