Panda3D
datagramGenerator.cxx
1 // Filename: datagramGenerator.cxx
2 // Created by: jason (07Jun00)
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 #include "pandabase.h"
17 
18 #include "datagramGenerator.h"
19 #include "temporaryFile.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: DatagramGenerator::Destructor
23 // Access: Published, Virtual
24 // Description: Does nothing since this is class is just
25 // the definition of an interface
26 ////////////////////////////////////////////////////////////////////
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: DatagramGenerator::save_datagram
33 // Access: Published, Virtual
34 // Description: Skips over the next datagram without extracting it,
35 // but saves the relevant file information in the
36 // SubfileInfo object so that its data may be read
37 // later. For non-file-based datagram generators, this
38 // may mean creating a temporary file and copying the
39 // contents of the datagram to disk.
40 //
41 // Returns true on success, false on failure or if this
42 // method is unimplemented.
43 ////////////////////////////////////////////////////////////////////
46  return false;
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: DatagramGenerator::get_filename
51 // Access: Published, Virtual
52 // Description: Returns the filename that provides the source for
53 // these datagrams, if any, or empty string if the
54 // datagrams do not originate from a file on disk.
55 ////////////////////////////////////////////////////////////////////
58  const FileReference *file = get_file();
59  if (file != (FileReference *)NULL) {
60  return file->get_filename();
61  }
62  static const Filename empty_filename;
63  return empty_filename;
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: DatagramGenerator::get_timestamp
68 // Access: Published, Virtual
69 // Description: Returns the on-disk timestamp of the file that was
70 // read, at the time it was opened, if that is
71 // available, or 0 if it is not.
72 ////////////////////////////////////////////////////////////////////
74 get_timestamp() const {
75  return 0;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: DatagramGenerator::get_file
80 // Access: Published, Virtual
81 // Description: Returns the FileReference that provides the source for
82 // these datagrams, if any, or NULL if the datagrams do
83 // not originate from a file on disk.
84 ////////////////////////////////////////////////////////////////////
87  return NULL;
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: DatagramGenerator::get_vfile
92 // Access: Published, Virtual
93 // Description: Returns the VirtualFile that provides the source for
94 // these datagrams, if any, or NULL if the datagrams do
95 // not originate from a VirtualFile.
96 ////////////////////////////////////////////////////////////////////
99  return NULL;
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: DatagramGenerator::get_file_pos
104 // Access: Published, Virtual
105 // Description: Returns the current file position within the data
106 // stream, if any, or 0 if the file position is not
107 // meaningful or cannot be determined.
108 //
109 // For DatagramGenerators that return a meaningful file
110 // position, this will be pointing to the first byte
111 // following the datagram returned after a call to
112 // get_datagram().
113 ////////////////////////////////////////////////////////////////////
114 streampos DatagramGenerator::
116  return 0;
117 }
virtual ~DatagramGenerator()
Does nothing since this is class is just the definition of an interface.
virtual time_t get_timestamp() const
Returns the on-disk timestamp of the file that was read, at the time it was opened, if that is available, or 0 if it is not.
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:29
The abstract base class for a file or directory within the VirtualFileSystem.
Definition: virtualFile.h:37
virtual streampos get_file_pos()
Returns the current file position within the data stream, if any, or 0 if the file position is not me...
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
virtual bool save_datagram(SubfileInfo &info)
Skips over the next datagram without extracting it, but saves the relevant file information in the Su...
virtual const FileReference * get_file()
Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagr...
virtual VirtualFile * get_vfile()
Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagram...
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:29
const Filename & get_filename() const
Returns the filename of the reference.
Definition: fileReference.I:31
virtual const Filename & get_filename()
Returns the filename that provides the source for these datagrams, if any, or empty string if the dat...