Panda3D
datagramSink.cxx
1 // Filename: datagramSink.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 #include "datagramSink.h"
16 #include "fileReference.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: DatagramSink::Destructor
20 // Access: Public, Virtual
21 // Description: Does nothing since this is class is just
22 // the definition of an interface
23 ////////////////////////////////////////////////////////////////////
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: DatagramSink::copy_datagram
30 // Access: Published, Virtual
31 // Description: Copies the file data from the entire indicated
32 // file (via the vfs) as the next datagram. This is
33 // intended to support potentially very large datagrams.
34 //
35 // Returns true on success, false on failure or if this
36 // method is unimplemented. On true, fills "result"
37 // with the information that references the copied file,
38 // if possible.
39 ////////////////////////////////////////////////////////////////////
40 bool DatagramSink::
41 copy_datagram(SubfileInfo &result, const Filename &filename) {
42  return false;
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: DatagramSink::copy_datagram
47 // Access: Published, Virtual
48 // Description: Copies the file data from the range of the indicated
49 // file (outside of the vfs) as the next datagram. This
50 // is intended to support potentially very large
51 // datagrams.
52 //
53 // Returns true on success, false on failure or if this
54 // method is unimplemented. On true, fills "result"
55 // with the information that references the copied file,
56 // if possible.
57 ////////////////////////////////////////////////////////////////////
58 bool DatagramSink::
59 copy_datagram(SubfileInfo &result, const SubfileInfo &source) {
60  return false;
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: DatagramSink::get_filename
65 // Access: Published, Virtual
66 // Description: Returns the filename that provides the target for
67 // these datagrams, if any, or empty string if the
68 // datagrams do not get written to a file on disk.
69 ////////////////////////////////////////////////////////////////////
72  const FileReference *file = get_file();
73  if (file != (FileReference *)NULL) {
74  return file->get_filename();
75  }
76  static const Filename empty_filename;
77  return empty_filename;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: DatagramSink::get_file
82 // Access: Published, Virtual
83 // Description: Returns the FileReference that provides the target for
84 // these datagrams, if any, or NULL if the datagrams do
85 // not written to a file on disk.
86 ////////////////////////////////////////////////////////////////////
89  return NULL;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: DatagramSink::get_file_pos
94 // Access: Published, Virtual
95 // Description: Returns the current file position within the data
96 // stream, if any, or 0 if the file position is not
97 // meaningful or cannot be determined.
98 //
99 // For DatagramSinks that return a meaningful file
100 // position, this will be pointing to the first byte
101 // following the datagram returned after a call to
102 // put_datagram().
103 ////////////////////////////////////////////////////////////////////
104 streampos DatagramSink::
106  return 0;
107 }
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:29
virtual ~DatagramSink()
Does nothing since this is class is just the definition of an interface.
The name of a file, such as a texture file or an Egg file.
Definition: filename.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.
virtual const Filename & get_filename()
Returns the filename that provides the target for these datagrams, if any, or empty string if the dat...
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...
This class records a particular byte sub-range within an existing file on disk.
Definition: subfileInfo.h:29
virtual const FileReference * get_file()
Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagr...
const Filename & get_filename() const
Returns the filename of the reference.
Definition: fileReference.I:31