Panda3D
 All Classes Functions Variables Enumerations
cConnectionRepository.I
00001 // Filename: cConnectionRepository.I
00002 // Created by:  drose (17May04)
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: CConnectionRepository::get_dc_file
00018 //       Access: Published
00019 //  Description: Returns the DCFile object associated with this
00020 //               repository.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE DCFile &CConnectionRepository::
00023 get_dc_file() {
00024   return _dc_file;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: CConnectionRepository::has_owner_view
00029 //       Access: Published
00030 //  Description: Returns true if this repository can have 'owner'
00031 //               views of distributed objects.
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE bool CConnectionRepository::
00034 has_owner_view() const {
00035   return _has_owner_view;
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: CConnectionRepository::set_handle_c_updates
00040 //       Access: Published
00041 //  Description: Set true to specify this repository should process
00042 //               distributed updates internally in C++ code, or false
00043 //               if it should return them to Python.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE void CConnectionRepository::
00046 set_handle_c_updates(bool handle_c_updates) {
00047   _handle_c_updates = handle_c_updates;
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: CConnectionRepository::get_handle_c_updates
00052 //       Access: Published
00053 //  Description: Returns true if this repository will process
00054 //               distributed updates internally in C++ code, or false
00055 //               if it will return them to Python.
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE bool CConnectionRepository::
00058 get_handle_c_updates() const {
00059   return _handle_c_updates;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: CConnectionRepository::set_client_datagram
00064 //       Access: Published
00065 //  Description: Sets the client_datagram flag.  If this is true,
00066 //               incoming datagrams are not expected to be prefixed
00067 //               with the server routing information like message
00068 //               sender, channel number, etc.; otherwise, these server
00069 //               fields are parsed and removed from each incoming
00070 //               datagram.
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE void CConnectionRepository::
00073 set_client_datagram(bool client_datagram) {
00074   _client_datagram = client_datagram;
00075 }
00076 
00077 ////////////////////////////////////////////////////////////////////
00078 //     Function: CConnectionRepository::get_client_datagram
00079 //       Access: Published
00080 //  Description: Returns the client_datagram flag.
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE bool CConnectionRepository::
00083 get_client_datagram() const {
00084   return _client_datagram;
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: CConnectionRepository::set_handle_datagrams_internally
00089 //       Access: Published
00090 //  Description: Sets the handle_datagrams_internally flag.  When
00091 //               true, certain message types can be handled by the C++
00092 //               code in in this module.  When false, all datagrams,
00093 //               regardless of message type, are passed up to Python
00094 //               for processing.
00095 //
00096 //               The CMU distributed-object implementation requires
00097 //               this to be set false.
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE void CConnectionRepository::
00100 set_handle_datagrams_internally(bool handle_datagrams_internally) {
00101   _handle_datagrams_internally = handle_datagrams_internally;
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: CConnectionRepository::get_handle_datagrams_internally
00106 //       Access: Published
00107 //  Description: Returns the handle_datagrams_internally flag.
00108 ////////////////////////////////////////////////////////////////////
00109 INLINE bool CConnectionRepository::
00110 get_handle_datagrams_internally() const {
00111   return _handle_datagrams_internally;
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: CConnectionRepository::get_tcp_header_size
00116 //       Access: Public
00117 //  Description: Returns the current setting of TCP header size.
00118 //               See set_tcp_header_size().
00119 ////////////////////////////////////////////////////////////////////
00120 INLINE int CConnectionRepository::
00121 get_tcp_header_size() const {
00122   return _tcp_header_size;
00123 }
00124 
00125 #ifdef HAVE_PYTHON
00126 ////////////////////////////////////////////////////////////////////
00127 //     Function: CConnectionRepository::set_python_repository
00128 //       Access: Published
00129 //  Description: Records the pointer to the Python class that derives
00130 //               from CConnectionRepository.  This allows the C++
00131 //               implementation to directly manipulation some python
00132 //               structures on the repository.
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE void CConnectionRepository::
00135 set_python_repository(PyObject *python_repository) {
00136   _python_repository = python_repository;
00137 }
00138 #endif  // HAVE_PYTHON
00139 
00140 #ifdef HAVE_NET
00141 ////////////////////////////////////////////////////////////////////
00142 //     Function: CConnectionRepository::get_qcm
00143 //       Access: Published
00144 //  Description: Returns the QueuedConnectionManager object associated
00145 //               with the repository.
00146 ////////////////////////////////////////////////////////////////////
00147 INLINE QueuedConnectionManager &CConnectionRepository::
00148 get_qcm() {
00149   return _qcm;
00150 }
00151 #endif  // HAVE_NET
00152 
00153 #ifdef HAVE_NET
00154 ////////////////////////////////////////////////////////////////////
00155 //     Function: CConnectionRepository::get_cw
00156 //       Access: Published
00157 //  Description: Returns the ConnectionWriter object associated
00158 //               with the repository.
00159 ////////////////////////////////////////////////////////////////////
00160 INLINE ConnectionWriter &CConnectionRepository::
00161 get_cw() {
00162   return _cw;
00163 }
00164   INLINE ConnectionWriter &get_cw();
00165 #endif  // HAVE_NET
00166 
00167 #ifdef HAVE_NET
00168 ////////////////////////////////////////////////////////////////////
00169 //     Function: CConnectionRepository::get_qcr
00170 //       Access: Published
00171 //  Description: Returns the QueuedConnectionReader object associated
00172 //               with the repository.
00173 ////////////////////////////////////////////////////////////////////
00174 INLINE QueuedConnectionReader &CConnectionRepository::
00175 get_qcr() {
00176   return _qcr;
00177 }
00178   INLINE QueuedConnectionReader &get_qcr();
00179 #endif  // HAVE_NET
00180 
00181 #ifdef WANT_NATIVE_NET
00182 ////////////////////////////////////////////////////////////////////
00183 //     Function: CConnectionRepository::get_bdc
00184 //       Access: Published
00185 //  Description: Returns the Buffered_DatagramConnection object associated
00186 //               with the repository.
00187 ////////////////////////////////////////////////////////////////////
00188 INLINE Buffered_DatagramConnection &CConnectionRepository::
00189 get_bdc() {
00190   return _bdc;
00191 }
00192   INLINE Buffered_DatagramConnection &get_bdc();
00193 #endif
00194 
00195 ////////////////////////////////////////////////////////////////////
00196 //     Function: CConnectionRepository::get_datagram
00197 //       Access: Published
00198 //  Description: Fills the datagram object with the datagram most
00199 //               recently retrieved by check_datagram().
00200 ////////////////////////////////////////////////////////////////////
00201 INLINE void CConnectionRepository::
00202 get_datagram(Datagram &dg) {
00203   ReMutexHolder holder(_lock);
00204   dg = _dg;
00205 }
00206 
00207 ////////////////////////////////////////////////////////////////////
00208 //     Function: CConnectionRepository::get_datagram_iterator
00209 //       Access: Published
00210 //  Description: Fills the DatagramIterator object with the iterator
00211 //               for the datagram most recently retrieved by
00212 //               check_datagram().  This iterator has already read
00213 //               past the datagram header and the message type, and is
00214 //               positioned at the beginning of data.
00215 ////////////////////////////////////////////////////////////////////
00216 INLINE void CConnectionRepository::
00217 get_datagram_iterator(DatagramIterator &di) {
00218   ReMutexHolder holder(_lock);
00219   di = _di;
00220 }
00221 
00222 ////////////////////////////////////////////////////////////////////
00223 //     Function: CConnectionRepository::get_msg_channel
00224 //       Access: Published
00225 //  Description: Returns the channel(s) to which the current message
00226 //               was sent, according to the datagram headers.  This
00227 //               information is not available to the client.
00228 ////////////////////////////////////////////////////////////////////
00229 INLINE CHANNEL_TYPE CConnectionRepository::
00230 get_msg_channel(int offset) const {
00231   ReMutexHolder holder(_lock);
00232   nassertr(offset < (int)_msg_channels.size(),0);
00233   return _msg_channels[offset];
00234 }
00235 
00236 INLINE int CConnectionRepository::
00237 get_msg_channel_count() const {
00238   ReMutexHolder holder(_lock);
00239   return _msg_channels.size();
00240 }
00241 
00242 ////////////////////////////////////////////////////////////////////
00243 //     Function: CConnectionRepository::get_msg_sender
00244 //       Access: Published
00245 //  Description: Returns the sender ID of the current message,
00246 //               according to the datagram headers.  This information
00247 //               is not available to the client.
00248 ////////////////////////////////////////////////////////////////////
00249 INLINE CHANNEL_TYPE CConnectionRepository::
00250 get_msg_sender() const {
00251   ReMutexHolder holder(_lock);
00252   return _msg_sender;
00253 }
00254 
00255 ////////////////////////////////////////////////////////////////////
00256 //     Function: CConnectionRepository::get_sec_code
00257 //       Access: Published
00258 //  Description: Returns the security code associated with the current
00259 //               message, according to the datagram headers.  This
00260 //               information is not available to the client.
00261 ////////////////////////////////////////////////////////////////////
00262 //INLINE unsigned char CConnectionRepository::
00263 //get_sec_code() const {
00264 //  return _sec_code;
00265 //}
00266 
00267 ////////////////////////////////////////////////////////////////////
00268 //     Function: CConnectionRepository::get_msg_type
00269 //       Access: Published
00270 //  Description: Returns the type ID of the current message,
00271 //               according to the datagram headers.
00272 ////////////////////////////////////////////////////////////////////
00273 INLINE unsigned int CConnectionRepository::
00274 get_msg_type() const {
00275   ReMutexHolder holder(_lock);
00276   return _msg_type;
00277 }
00278 
00279 ////////////////////////////////////////////////////////////////////
00280 //     Function: CConnectionRepository::get_overflow_event_name
00281 //       Access: Published
00282 //  Description: Returns event string that will be thrown if the
00283 //               datagram reader queue overflows.
00284 ////////////////////////////////////////////////////////////////////
00285 INLINE const string &CConnectionRepository::
00286 get_overflow_event_name() {
00287   return _overflow_event_name;
00288 }
00289 
00290 ////////////////////////////////////////////////////////////////////
00291 //     Function: CConnectionRepository::is_bundling_messages
00292 //       Access: Published
00293 //  Description: Returns true if repository is queueing outgoing messages
00294 //               into a message bundle
00295 ////////////////////////////////////////////////////////////////////
00296 INLINE bool CConnectionRepository::
00297 is_bundling_messages() const {
00298   ReMutexHolder holder(_lock);
00299   return _bundling_msgs > 0;
00300 }
00301 
00302 ////////////////////////////////////////////////////////////////////
00303 //     Function: CConnectionRepository::set_want_message_bundling
00304 //       Access: Published
00305 //  Description: Enable/disable outbound message bundling
00306 ////////////////////////////////////////////////////////////////////
00307 INLINE void CConnectionRepository::
00308 set_want_message_bundling(bool flag) {
00309   ReMutexHolder holder(_lock);
00310   // don't allow enable/disable while bundling
00311   nassertv(_bundling_msgs == 0);
00312   _want_message_bundling = flag;
00313 }
00314 
00315 ////////////////////////////////////////////////////////////////////
00316 //     Function: CConnectionRepository::get_want_message_bundling
00317 //       Access: Published
00318 //  Description: Returns true if message bundling enabled
00319 ////////////////////////////////////////////////////////////////////
00320 INLINE bool CConnectionRepository::
00321 get_want_message_bundling() const {
00322   ReMutexHolder holder(_lock);
00323   return _want_message_bundling;
00324 }
00325 
00326 ////////////////////////////////////////////////////////////////////
00327 //     Function: CConnectionRepository::set_in_quiet_zone
00328 //       Access: Published
00329 //  Description: Enables/disables quiet zone mode
00330 ////////////////////////////////////////////////////////////////////
00331 INLINE void CConnectionRepository::
00332 set_in_quiet_zone(bool flag) {
00333   ReMutexHolder holder(_lock);
00334   _in_quiet_zone = flag;
00335 }
00336 
00337 ////////////////////////////////////////////////////////////////////
00338 //     Function: CConnectionRepository::get_in_quiet_zone
00339 //       Access: Published
00340 //  Description: Returns true if repository is in quiet zone mode
00341 ////////////////////////////////////////////////////////////////////
00342 INLINE bool CConnectionRepository::
00343 get_in_quiet_zone() const {
00344   ReMutexHolder holder(_lock);
00345   return _in_quiet_zone;
00346 }
00347 
00348 ////////////////////////////////////////////////////////////////////
00349 //     Function: CConnectionRepository::set_simulated_disconnect
00350 //       Access: Published
00351 //  Description: Sets the simulated disconnect flag.  While this is
00352 //               true, no datagrams will be retrieved from or sent to
00353 //               the server.  The idea is to simulate a temporary
00354 //               network outage.
00355 ////////////////////////////////////////////////////////////////////
00356 INLINE void CConnectionRepository::
00357 set_simulated_disconnect(bool simulated_disconnect) {
00358   _simulated_disconnect = simulated_disconnect;
00359 }
00360 
00361 ////////////////////////////////////////////////////////////////////
00362 //     Function: CConnectionRepository::get_simulated_disconnect
00363 //       Access: Published
00364 //  Description: Returns the simulated disconnect flag.  While this is
00365 //               true, no datagrams will be retrieved from or sent to
00366 //               the server.  The idea is to simulate a temporary
00367 //               network outage.
00368 ////////////////////////////////////////////////////////////////////
00369 INLINE bool CConnectionRepository::
00370 get_simulated_disconnect() const {
00371   return _simulated_disconnect;
00372 }
00373 
00374 ////////////////////////////////////////////////////////////////////
00375 //     Function: CConnectionRepository::toggle_verbose
00376 //       Access: Published
00377 //  Description: Toggles the current setting of the verbose flag.
00378 //               When true, this describes every message going back
00379 //               and forth on the wire.
00380 ////////////////////////////////////////////////////////////////////
00381 INLINE void CConnectionRepository::
00382 toggle_verbose() {
00383   _verbose = !_verbose;
00384 }
00385 
00386 ////////////////////////////////////////////////////////////////////
00387 //     Function: CConnectionRepository::set_verbose
00388 //       Access: Published
00389 //  Description: Directly sets the verbose flag.  When true, this
00390 //               describes every message going back and forth on the
00391 //               wire.
00392 ////////////////////////////////////////////////////////////////////
00393 INLINE void CConnectionRepository::
00394 set_verbose(bool verbose) {
00395   _verbose = verbose;
00396 }
00397 
00398 ////////////////////////////////////////////////////////////////////
00399 //     Function: CConnectionRepository::get_verbose
00400 //       Access: Published
00401 //  Description: Returns the current setting of the verbose flag.
00402 //               When true, this describes every message going back
00403 //               and forth on the wire.
00404 ////////////////////////////////////////////////////////////////////
00405 INLINE bool CConnectionRepository::
00406 get_verbose() const {
00407   return _verbose;
00408 }
00409 
00410 ////////////////////////////////////////////////////////////////////
00411 //     Function: CConnectionRepository::set_time_warning
00412 //       Access: Published
00413 //  Description: Directly sets the time_warning field.  When non zero, this
00414 //               describes every message going back and forth on the
00415 //               wire when the msg handling time is over it
00416 ////////////////////////////////////////////////////////////////////
00417 INLINE void CConnectionRepository::
00418 set_time_warning(float time_warning) {
00419   _time_warning = time_warning;
00420 }
00421 
00422 ////////////////////////////////////////////////////////////////////
00423 //     Function: CConnectionRepository::get_time_warning
00424 //       Access: Published
00425 //  Description: Returns the current setting of the time_warning field.
00426 ////////////////////////////////////////////////////////////////////
00427 INLINE float CConnectionRepository::
00428 get_time_warning() const {
00429   return _time_warning;
00430 }
 All Classes Functions Variables Enumerations