Panda3D
 All Classes Functions Variables Enumerations
datagramInputFile.I
1 // Filename: datagramInputFile.I
2 // Created by: drose (30Oct00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: DatagramInputFile::Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE DatagramInputFile::
22 DatagramInputFile() {
23  _error = false;
24  _read_first_datagram = false;
25  _in = (istream *)NULL;
26  _owns_in = false;
27  _timestamp = 0;
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: DatagramInputFile::Destructor
32 // Access: Published
33 // Description:
34 ////////////////////////////////////////////////////////////////////
35 INLINE DatagramInputFile::
36 ~DatagramInputFile() {
37  close();
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: DatagramInputFile::open
42 // Access: Published
43 // Description: Opens the indicated filename for reading. Returns
44 // true on success, false on failure.
45 ////////////////////////////////////////////////////////////////////
46 INLINE bool DatagramInputFile::
47 open(const Filename &filename) {
48  return open(new FileReference(filename));
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: DatagramInputFile::get_stream
53 // Access: Published
54 // Description: Returns the istream represented by the input file.
55 ////////////////////////////////////////////////////////////////////
56 INLINE istream &DatagramInputFile::
58  static ifstream null_stream;
59  nassertr(_in != NULL, null_stream);
60  return *_in;
61 }
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:29
void close()
Closes the file.
bool open(const FileReference *file)
Opens the indicated filename for reading.
istream & get_stream()
Returns the istream represented by the input file.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44