socketStreamRecorder.I 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // Filename: socketStreamRecorder.I
  2. // Created by: drose (28Jan04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: SocketStreamRecorder::Constructor
  20. // Access: Published
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE SocketStreamRecorder::
  24. SocketStreamRecorder() :
  25. _stream(NULL),
  26. _owns_stream(false),
  27. _closed(true)
  28. {
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function: SocketStreamRecorder::Constructor
  32. // Access: Published
  33. // Description:
  34. ////////////////////////////////////////////////////////////////////
  35. INLINE SocketStreamRecorder::
  36. SocketStreamRecorder(SocketStream *stream, bool owns_stream) :
  37. _stream(stream),
  38. _owns_stream(owns_stream),
  39. _closed(false)
  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. // Function: SocketStreamRecorder::send_datagram
  55. // Access: Public
  56. // Description: See SocketStream::send_datagram().
  57. ////////////////////////////////////////////////////////////////////
  58. bool SocketStreamRecorder::
  59. send_datagram(const Datagram &dg) {
  60. if (_stream != (SocketStream *)NULL) {
  61. return _stream->send_datagram(dg);
  62. }
  63. return true;
  64. }
  65. ////////////////////////////////////////////////////////////////////
  66. // Function: SocketStreamRecorder::is_closed
  67. // Access: Published
  68. // Description: See SocketStream::is_closed().
  69. ////////////////////////////////////////////////////////////////////
  70. INLINE bool SocketStreamRecorder::
  71. is_closed() {
  72. if (_stream != (SocketStream *)NULL) {
  73. return _stream->is_closed();
  74. }
  75. return is_playing() && _closed;
  76. }
  77. ////////////////////////////////////////////////////////////////////
  78. // Function: SocketStreamRecorder::close
  79. // Access: Published
  80. // Description: See SocketStream::close().
  81. ////////////////////////////////////////////////////////////////////
  82. INLINE void SocketStreamRecorder::
  83. close() {
  84. if (_stream != (SocketStream *)NULL) {
  85. _stream->close();
  86. }
  87. _closed = true;
  88. }
  89. ////////////////////////////////////////////////////////////////////
  90. // Function: SocketStreamRecorder::set_collect_tcp
  91. // Access: Published
  92. // Description: See SocketStream::set_collect_tcp().
  93. ////////////////////////////////////////////////////////////////////
  94. INLINE void SocketStreamRecorder::
  95. set_collect_tcp(bool collect_tcp) {
  96. if (_stream != (SocketStream *)NULL) {
  97. _stream->set_collect_tcp(collect_tcp);
  98. }
  99. }
  100. ////////////////////////////////////////////////////////////////////
  101. // Function: SocketStreamRecorder::get_collect_tcp
  102. // Access: Published
  103. // Description: See SocketStream::get_collect_tcp().
  104. ////////////////////////////////////////////////////////////////////
  105. INLINE bool SocketStreamRecorder::
  106. get_collect_tcp() const {
  107. if (_stream != (SocketStream *)NULL) {
  108. return _stream->get_collect_tcp();
  109. }
  110. return false;
  111. }
  112. ////////////////////////////////////////////////////////////////////
  113. // Function: SocketStreamRecorder::set_collect_tcp_interval
  114. // Access: Published
  115. // Description: See SocketStream::set_collect_tcp_interval().
  116. ////////////////////////////////////////////////////////////////////
  117. INLINE void SocketStreamRecorder::
  118. set_collect_tcp_interval(double interval) {
  119. if (_stream != (SocketStream *)NULL) {
  120. _stream->set_collect_tcp_interval(interval);
  121. }
  122. }
  123. ////////////////////////////////////////////////////////////////////
  124. // Function: SocketStreamRecorder::get_collect_tcp_interval
  125. // Access: Published
  126. // Description: See SocketStream::get_collect_tcp_interval().
  127. ////////////////////////////////////////////////////////////////////
  128. INLINE double SocketStreamRecorder::
  129. get_collect_tcp_interval() const {
  130. if (_stream != (SocketStream *)NULL) {
  131. return _stream->get_collect_tcp_interval();
  132. }
  133. return 0.0;
  134. }
  135. ////////////////////////////////////////////////////////////////////
  136. // Function: SocketStreamRecorder::consider_flush
  137. // Access: Published
  138. // Description: See SocketStream::consider_flush()
  139. ////////////////////////////////////////////////////////////////////
  140. INLINE bool SocketStreamRecorder::
  141. consider_flush() {
  142. if (_stream != (SocketStream *)NULL) {
  143. return _stream->consider_flush();
  144. }
  145. return true;
  146. }
  147. ////////////////////////////////////////////////////////////////////
  148. // Function: SocketStreamRecorder::flush
  149. // Access: Published
  150. // Description: See SocketStream::flush()
  151. ////////////////////////////////////////////////////////////////////
  152. INLINE bool SocketStreamRecorder::
  153. flush() {
  154. if (_stream != (SocketStream *)NULL) {
  155. return _stream->flush();
  156. }
  157. return true;
  158. }