Panda3D
socketStreamRecorder.I
1 // Filename: socketStreamRecorder.I
2 // Created by: drose (28Jan04)
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: SocketStreamRecorder::Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE SocketStreamRecorder::
22 SocketStreamRecorder() :
23  _stream(NULL),
24  _owns_stream(false),
25  _closed(true)
26 {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: SocketStreamRecorder::Constructor
31 // Access: Published
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE SocketStreamRecorder::
35 SocketStreamRecorder(SocketStream *stream, bool owns_stream) :
36  _stream(stream),
37  _owns_stream(owns_stream),
38  _closed(false)
39 {
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: SocketStreamRecorder::Destructor
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 INLINE SocketStreamRecorder::
48 ~SocketStreamRecorder() {
49  if (_owns_stream) {
50  delete _stream;
51  }
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: SocketStreamRecorder::send_datagram
56 // Access: Public
57 // Description: See SocketStream::send_datagram().
58 ////////////////////////////////////////////////////////////////////
59 bool SocketStreamRecorder::
60 send_datagram(const Datagram &dg) {
61  if (_stream != (SocketStream *)NULL) {
62  return _stream->send_datagram(dg);
63  }
64  return true;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: SocketStreamRecorder::is_closed
69 // Access: Published
70 // Description: See SocketStream::is_closed().
71 ////////////////////////////////////////////////////////////////////
72 INLINE bool SocketStreamRecorder::
73 is_closed() {
74  if (_stream != (SocketStream *)NULL) {
75  return _stream->is_closed();
76  }
77  return is_playing() && _closed;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: SocketStreamRecorder::close
82 // Access: Published
83 // Description: See SocketStream::close().
84 ////////////////////////////////////////////////////////////////////
85 INLINE void SocketStreamRecorder::
86 close() {
87  if (_stream != (SocketStream *)NULL) {
88  _stream->close();
89  }
90  _closed = true;
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: SocketStreamRecorder::set_collect_tcp
95 // Access: Published
96 // Description: See SocketStream::set_collect_tcp().
97 ////////////////////////////////////////////////////////////////////
98 INLINE void SocketStreamRecorder::
99 set_collect_tcp(bool collect_tcp) {
100  if (_stream != (SocketStream *)NULL) {
101  _stream->set_collect_tcp(collect_tcp);
102  }
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: SocketStreamRecorder::get_collect_tcp
107 // Access: Published
108 // Description: See SocketStream::get_collect_tcp().
109 ////////////////////////////////////////////////////////////////////
110 INLINE bool SocketStreamRecorder::
111 get_collect_tcp() const {
112  if (_stream != (SocketStream *)NULL) {
113  return _stream->get_collect_tcp();
114  }
115  return false;
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: SocketStreamRecorder::set_collect_tcp_interval
120 // Access: Published
121 // Description: See SocketStream::set_collect_tcp_interval().
122 ////////////////////////////////////////////////////////////////////
123 INLINE void SocketStreamRecorder::
124 set_collect_tcp_interval(double interval) {
125  if (_stream != (SocketStream *)NULL) {
126  _stream->set_collect_tcp_interval(interval);
127  }
128 }
129 
130 ////////////////////////////////////////////////////////////////////
131 // Function: SocketStreamRecorder::get_collect_tcp_interval
132 // Access: Published
133 // Description: See SocketStream::get_collect_tcp_interval().
134 ////////////////////////////////////////////////////////////////////
135 INLINE double SocketStreamRecorder::
136 get_collect_tcp_interval() const {
137  if (_stream != (SocketStream *)NULL) {
138  return _stream->get_collect_tcp_interval();
139  }
140  return 0.0;
141 }
142 
143 ////////////////////////////////////////////////////////////////////
144 // Function: SocketStreamRecorder::consider_flush
145 // Access: Published
146 // Description: See SocketStream::consider_flush()
147 ////////////////////////////////////////////////////////////////////
148 INLINE bool SocketStreamRecorder::
149 consider_flush() {
150  if (_stream != (SocketStream *)NULL) {
151  return _stream->consider_flush();
152  }
153  return true;
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: SocketStreamRecorder::flush
158 // Access: Published
159 // Description: See SocketStream::flush()
160 ////////////////////////////////////////////////////////////////////
161 INLINE bool SocketStreamRecorder::
162 flush() {
163  if (_stream != (SocketStream *)NULL) {
164  return _stream->flush();
165  }
166  return true;
167 }
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43