Panda3D
Loading...
Searching...
No Matches
datagramGenerator.cxx
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 datagramGenerator.cxx
10 * @author jason
11 * @date 2000-06-07
12 */
13
14#include "pandabase.h"
15
16#include "datagramGenerator.h"
17#include "temporaryFile.h"
18
19/**
20 * Does nothing since this is class is just the definition of an interface
21 */
25
26/**
27 * Skips over the next datagram without extracting it, but saves the relevant
28 * file information in the SubfileInfo object so that its data may be read
29 * later. For non-file-based datagram generators, this may mean creating a
30 * temporary file and copying the contents of the datagram to disk.
31 *
32 * Returns true on success, false on failure or if this method is
33 * unimplemented.
34 */
37 return false;
38}
39
40/**
41 * Returns the filename that provides the source for these datagrams, if any,
42 * or empty string if the datagrams do not originate from a file on disk.
43 */
46 const FileReference *file = get_file();
47 if (file != nullptr) {
48 return file->get_filename();
49 }
50 static const Filename empty_filename;
51 return empty_filename;
52}
53
54/**
55 * Returns the on-disk timestamp of the file that was read, at the time it was
56 * opened, if that is available, or 0 if it is not.
57 */
59get_timestamp() const {
60 return 0;
61}
62
63/**
64 * Returns the FileReference that provides the source for these datagrams, if
65 * any, or NULL if the datagrams do not originate from a file on disk.
66 */
68get_file() {
69 return nullptr;
70}
71
72/**
73 * Returns the VirtualFile that provides the source for these datagrams, if
74 * any, or NULL if the datagrams do not originate from a VirtualFile.
75 */
77get_vfile() {
78 return nullptr;
79}
80
81/**
82 * Returns the current file position within the data stream, if any, or 0 if
83 * the file position is not meaningful or cannot be determined.
84 *
85 * For DatagramGenerators that return a meaningful file position, this will be
86 * pointing to the first byte following the datagram returned after a call to
87 * get_datagram().
88 */
89std::streampos DatagramGenerator::
91 return 0;
92}
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...
virtual const FileReference * get_file()
Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagr...
virtual const Filename & get_filename()
Returns the filename that provides the source for these datagrams, if any, or empty string if the dat...
virtual time_t get_timestamp() const
Returns the on-disk timestamp of the file that was read, at the time it was opened,...
virtual bool save_datagram(SubfileInfo &info)
Skips over the next datagram without extracting it, but saves the relevant file information in the Su...
virtual ~DatagramGenerator()
Does nothing since this is class is just the definition of an interface.
virtual VirtualFile * get_vfile()
Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagram...
Keeps a reference-counted pointer to a file on disk.
const Filename & get_filename() const
Returns the filename of the reference.
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
This class records a particular byte sub-range within an existing file on disk.
Definition subfileInfo.h:26
The abstract base class for a file or directory within the VirtualFileSystem.
Definition virtualFile.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.