Panda3D

socketStreamRecorder.I

00001 // Filename: socketStreamRecorder.I
00002 // Created by:  drose (28Jan04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: SocketStreamRecorder::Constructor
00018 //       Access: Published
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE SocketStreamRecorder::
00022 SocketStreamRecorder() :
00023   _stream(NULL),
00024   _owns_stream(false),
00025   _closed(true)
00026 {
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: SocketStreamRecorder::Constructor
00031 //       Access: Published
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE SocketStreamRecorder::
00035 SocketStreamRecorder(SocketStream *stream, bool owns_stream) :
00036   _stream(stream),
00037   _owns_stream(owns_stream),
00038   _closed(false)
00039 {
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: SocketStreamRecorder::Destructor
00044 //       Access: Published
00045 //  Description:
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE SocketStreamRecorder::
00048 ~SocketStreamRecorder() {
00049   if (_owns_stream) {
00050     delete _stream;
00051   }
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: SocketStreamRecorder::send_datagram
00056 //       Access: Public
00057 //  Description: See SocketStream::send_datagram().
00058 ////////////////////////////////////////////////////////////////////
00059 bool SocketStreamRecorder::
00060 send_datagram(const Datagram &dg) {
00061   if (_stream != (SocketStream *)NULL) {
00062     return _stream->send_datagram(dg);
00063   }
00064   return true;
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: SocketStreamRecorder::is_closed
00069 //       Access: Published
00070 //  Description: See SocketStream::is_closed().
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE bool SocketStreamRecorder::
00073 is_closed() {
00074   if (_stream != (SocketStream *)NULL) {
00075     return _stream->is_closed();
00076   }
00077   return is_playing() && _closed;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: SocketStreamRecorder::close
00082 //       Access: Published
00083 //  Description: See SocketStream::close().
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE void SocketStreamRecorder::
00086 close() {
00087   if (_stream != (SocketStream *)NULL) {
00088     _stream->close();
00089   }
00090   _closed = true;
00091 }
00092 
00093 ////////////////////////////////////////////////////////////////////
00094 //     Function: SocketStreamRecorder::set_collect_tcp
00095 //       Access: Published
00096 //  Description: See SocketStream::set_collect_tcp().
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE void SocketStreamRecorder::
00099 set_collect_tcp(bool collect_tcp) {
00100   if (_stream != (SocketStream *)NULL) {
00101     _stream->set_collect_tcp(collect_tcp);
00102   }
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: SocketStreamRecorder::get_collect_tcp
00107 //       Access: Published
00108 //  Description: See SocketStream::get_collect_tcp().
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE bool SocketStreamRecorder::
00111 get_collect_tcp() const {
00112   if (_stream != (SocketStream *)NULL) {
00113     return _stream->get_collect_tcp();
00114   }
00115   return false;
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: SocketStreamRecorder::set_collect_tcp_interval
00120 //       Access: Published
00121 //  Description: See SocketStream::set_collect_tcp_interval().
00122 ////////////////////////////////////////////////////////////////////
00123 INLINE void SocketStreamRecorder::
00124 set_collect_tcp_interval(double interval) {
00125   if (_stream != (SocketStream *)NULL) {
00126     _stream->set_collect_tcp_interval(interval);
00127   }
00128 }
00129 
00130 ////////////////////////////////////////////////////////////////////
00131 //     Function: SocketStreamRecorder::get_collect_tcp_interval
00132 //       Access: Published
00133 //  Description: See SocketStream::get_collect_tcp_interval().
00134 ////////////////////////////////////////////////////////////////////
00135 INLINE double SocketStreamRecorder::
00136 get_collect_tcp_interval() const {
00137   if (_stream != (SocketStream *)NULL) {
00138     return _stream->get_collect_tcp_interval();
00139   }
00140   return 0.0;
00141 }
00142 
00143 ////////////////////////////////////////////////////////////////////
00144 //     Function: SocketStreamRecorder::consider_flush
00145 //       Access: Published
00146 //  Description: See SocketStream::consider_flush()
00147 ////////////////////////////////////////////////////////////////////
00148 INLINE bool SocketStreamRecorder::
00149 consider_flush() {
00150   if (_stream != (SocketStream *)NULL) {
00151     return _stream->consider_flush();
00152   }
00153   return true;
00154 }
00155 
00156 ////////////////////////////////////////////////////////////////////
00157 //     Function: SocketStreamRecorder::flush
00158 //       Access: Published
00159 //  Description: See SocketStream::flush()
00160 ////////////////////////////////////////////////////////////////////
00161 INLINE bool SocketStreamRecorder::
00162 flush() {
00163   if (_stream != (SocketStream *)NULL) {
00164     return _stream->flush();
00165   }
00166   return true;
00167 }
 All Classes Functions Variables Enumerations