Panda3D
datagramSink.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 datagramSink.cxx
10  * @author jason
11  * @date 2000-06-07
12  */
13 
14 #include "datagramSink.h"
15 #include "fileReference.h"
16 
17 /**
18  * Does nothing since this is class is just the definition of an interface
19  */
21 ~DatagramSink() {
22 }
23 
24 /**
25  * Copies the file data from the entire indicated file (via the vfs) as the
26  * next datagram. This is intended to support potentially very large
27  * datagrams.
28  *
29  * Returns true on success, false on failure or if this method is
30  * unimplemented. On true, fills "result" with the information that
31  * references the copied file, if possible.
32  */
34 copy_datagram(SubfileInfo &result, const Filename &filename) {
35  return false;
36 }
37 
38 /**
39  * Copies the file data from the range of the indicated file (outside of the
40  * vfs) as the next datagram. This is intended to support potentially very
41  * large datagrams.
42  *
43  * Returns true on success, false on failure or if this method is
44  * unimplemented. On true, fills "result" with the information that
45  * references the copied file, if possible.
46  */
48 copy_datagram(SubfileInfo &result, const SubfileInfo &source) {
49  return false;
50 }
51 
52 /**
53  * Returns the filename that provides the target for these datagrams, if any,
54  * or empty string if the datagrams do not get written to a file on disk.
55  */
57 get_filename() {
58  const FileReference *file = get_file();
59  if (file != nullptr) {
60  return file->get_filename();
61  }
62  static const Filename empty_filename;
63  return empty_filename;
64 }
65 
66 /**
67  * Returns the FileReference that provides the target for these datagrams, if
68  * any, or NULL if the datagrams do not written to a file on disk.
69  */
71 get_file() {
72  return nullptr;
73 }
74 
75 /**
76  * Returns the current file position within the data stream, if any, or 0 if
77  * the file position is not meaningful or cannot be determined.
78  *
79  * For DatagramSinks that return a meaningful file position, this will be
80  * pointing to the first byte following the datagram returned after a call to
81  * put_datagram().
82  */
83 std::streampos DatagramSink::
84 get_file_pos() {
85  return 0;
86 }
get_filename
Returns the filename that provides the target for these datagrams, if any, or empty string if the dat...
Definition: datagramSink.h:44
virtual bool copy_datagram(SubfileInfo &result, const Filename &filename)
Copies the file data from the entire indicated file (via the vfs) as the next datagram.
get_file
Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagr...
Definition: datagramSink.h:45
virtual ~DatagramSink()
Does nothing since this is class is just the definition of an interface.
get_file_pos
Returns the current file position within the data stream, if any, or 0 if the file position is not me...
Definition: datagramSink.h:46
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:26
const Filename & get_filename() const
Returns the filename of the reference.
Definition: fileReference.I:25
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.