Panda3D
cConnectionRepository.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file cConnectionRepository.I
10  * @author drose
11  * @date 2004-05-17
12  */
13 
14 /**
15  * Returns the DCFile object associated with this repository.
16  */
19  return _dc_file;
20 }
21 
22 /**
23  * Returns true if this repository can have 'owner' views of distributed
24  * objects.
25  */
26 INLINE bool CConnectionRepository::
27 has_owner_view() const {
28  return _has_owner_view;
29 }
30 
31 /**
32  * Set true to specify this repository should process distributed updates
33  * internally in C++ code, or false if it should return them to Python.
34  */
35 INLINE void CConnectionRepository::
36 set_handle_c_updates(bool handle_c_updates) {
37  _handle_c_updates = handle_c_updates;
38 }
39 
40 /**
41  * Returns true if this repository will process distributed updates internally
42  * in C++ code, or false if it will return them to Python.
43  */
44 INLINE bool CConnectionRepository::
46  return _handle_c_updates;
47 }
48 
49 /**
50  * Sets the client_datagram flag. If this is true, incoming datagrams are not
51  * expected to be prefixed with the server routing information like message
52  * sender, channel number, etc.; otherwise, these server fields are parsed and
53  * removed from each incoming datagram.
54  */
55 INLINE void CConnectionRepository::
56 set_client_datagram(bool client_datagram) {
57  _client_datagram = client_datagram;
58 }
59 
60 /**
61  * Returns the client_datagram flag.
62  */
63 INLINE bool CConnectionRepository::
65  return _client_datagram;
66 }
67 
68 /**
69  * Sets the handle_datagrams_internally flag. When true, certain message
70  * types can be handled by the C++ code in in this module. When false, all
71  * datagrams, regardless of message type, are passed up to Python for
72  * processing.
73  *
74  * The CMU distributed-object implementation requires this to be set false.
75  */
76 INLINE void CConnectionRepository::
77 set_handle_datagrams_internally(bool handle_datagrams_internally) {
78  _handle_datagrams_internally = handle_datagrams_internally;
79 }
80 
81 /**
82  * Returns the handle_datagrams_internally flag.
83  */
84 INLINE bool CConnectionRepository::
86  return _handle_datagrams_internally;
87 }
88 
89 /**
90  * Returns the current setting of TCP header size. See set_tcp_header_size().
91  */
92 INLINE int CConnectionRepository::
94  return _tcp_header_size;
95 }
96 
97 #ifdef HAVE_PYTHON
98 /**
99  * Records the pointer to the Python class that derives from
100  * CConnectionRepository. This allows the C++ implementation to directly
101  * manipulation some python structures on the repository.
102  */
103 INLINE void CConnectionRepository::
104 set_python_repository(PyObject *python_repository) {
105  _python_repository = python_repository;
106 }
107 #endif // HAVE_PYTHON
108 
109 #ifdef HAVE_NET
110 /**
111  * Returns the QueuedConnectionManager object associated with the repository.
112  */
113 INLINE QueuedConnectionManager &CConnectionRepository::
114 get_qcm() {
115  return _qcm;
116 }
117 #endif // HAVE_NET
118 
119 #ifdef HAVE_NET
120 /**
121  * Returns the ConnectionWriter object associated with the repository.
122  */
123 INLINE ConnectionWriter &CConnectionRepository::
124 get_cw() {
125  return _cw;
126 }
127  INLINE ConnectionWriter &get_cw();
128 #endif // HAVE_NET
129 
130 #ifdef HAVE_NET
131 /**
132  * Returns the QueuedConnectionReader object associated with the repository.
133  */
134 INLINE QueuedConnectionReader &CConnectionRepository::
135 get_qcr() {
136  return _qcr;
137 }
138  INLINE QueuedConnectionReader &get_qcr();
139 #endif // HAVE_NET
140 
141 #ifdef WANT_NATIVE_NET
142 /**
143  * Returns the Buffered_DatagramConnection object associated with the
144  * repository.
145  */
146 INLINE Buffered_DatagramConnection &CConnectionRepository::
147 get_bdc() {
148  return _bdc;
149 }
150  INLINE Buffered_DatagramConnection &get_bdc();
151 #endif
152 
153 /**
154  * Fills the datagram object with the datagram most recently retrieved by
155  * check_datagram().
156  */
157 INLINE void CConnectionRepository::
159  ReMutexHolder holder(_lock);
160  dg = _dg;
161 }
162 
163 /**
164  * Fills the DatagramIterator object with the iterator for the datagram most
165  * recently retrieved by check_datagram(). This iterator has already read
166  * past the datagram header and the message type, and is positioned at the
167  * beginning of data.
168  */
169 INLINE void CConnectionRepository::
171  ReMutexHolder holder(_lock);
172  di = _di;
173 }
174 
175 /**
176  * Returns the channel(s) to which the current message was sent, according to
177  * the datagram headers. This information is not available to the client.
178  */
179 INLINE CHANNEL_TYPE CConnectionRepository::
180 get_msg_channel(int offset) const {
181  ReMutexHolder holder(_lock);
182  nassertr(offset < (int)_msg_channels.size(),0);
183  return _msg_channels[offset];
184 }
185 
186 INLINE int CConnectionRepository::
187 get_msg_channel_count() const {
188  ReMutexHolder holder(_lock);
189  return _msg_channels.size();
190 }
191 
192 /**
193  * Returns the sender ID of the current message, according to the datagram
194  * headers. This information is not available to the client.
195  */
196 INLINE CHANNEL_TYPE CConnectionRepository::
197 get_msg_sender() const {
198  ReMutexHolder holder(_lock);
199  return _msg_sender;
200 }
201 
202 /**
203  * Returns the security code associated with the current message, according to
204  * the datagram headers. This information is not available to the client.
205  * INLINE unsigned char CConnectionRepository:: get_sec_code() const { return
206  * _sec_code; }
207  */
208 
209 /**
210  * Returns the type ID of the current message, according to the datagram
211  * headers.
212  */
213 INLINE unsigned int CConnectionRepository::
214 get_msg_type() const {
215  ReMutexHolder holder(_lock);
216  return _msg_type;
217 }
218 
219 /**
220  * Returns event string that will be thrown if the datagram reader queue
221  * overflows.
222  */
223 INLINE const std::string &CConnectionRepository::
225  return _overflow_event_name;
226 }
227 
228 /**
229  * Returns true if repository is queueing outgoing messages into a message
230  * bundle
231  */
232 INLINE bool CConnectionRepository::
234  ReMutexHolder holder(_lock);
235  return _bundling_msgs > 0;
236 }
237 
238 /**
239  * Enable/disable outbound message bundling
240  */
241 INLINE void CConnectionRepository::
243  ReMutexHolder holder(_lock);
244  // don't allow enabledisable while bundling
245  nassertv(_bundling_msgs == 0);
246  _want_message_bundling = flag;
247 }
248 
249 /**
250  * Returns true if message bundling enabled
251  */
252 INLINE bool CConnectionRepository::
254  ReMutexHolder holder(_lock);
255  return _want_message_bundling;
256 }
257 
258 /**
259  * Enables/disables quiet zone mode
260  */
261 INLINE void CConnectionRepository::
262 set_in_quiet_zone(bool flag) {
263  ReMutexHolder holder(_lock);
264  _in_quiet_zone = flag;
265 }
266 
267 /**
268  * Returns true if repository is in quiet zone mode
269  */
270 INLINE bool CConnectionRepository::
272  ReMutexHolder holder(_lock);
273  return _in_quiet_zone;
274 }
275 
276 /**
277  * Sets the simulated disconnect flag. While this is true, no datagrams will
278  * be retrieved from or sent to the server. The idea is to simulate a
279  * temporary network outage.
280  */
281 INLINE void CConnectionRepository::
282 set_simulated_disconnect(bool simulated_disconnect) {
283  _simulated_disconnect = simulated_disconnect;
284 }
285 
286 /**
287  * Returns the simulated disconnect flag. While this is true, no datagrams
288  * will be retrieved from or sent to the server. The idea is to simulate a
289  * temporary network outage.
290  */
291 INLINE bool CConnectionRepository::
293  return _simulated_disconnect;
294 }
295 
296 /**
297  * Toggles the current setting of the verbose flag. When true, this describes
298  * every message going back and forth on the wire.
299  */
300 INLINE void CConnectionRepository::
302  _verbose = !_verbose;
303 }
304 
305 /**
306  * Directly sets the verbose flag. When true, this describes every message
307  * going back and forth on the wire.
308  */
309 INLINE void CConnectionRepository::
310 set_verbose(bool verbose) {
311  _verbose = verbose;
312 }
313 
314 /**
315  * Returns the current setting of the verbose flag. When true, this describes
316  * every message going back and forth on the wire.
317  */
318 INLINE bool CConnectionRepository::
319 get_verbose() const {
320  return _verbose;
321 }
322 
323 /**
324  * Directly sets the time_warning field. When non zero, this describes every
325  * message going back and forth on the wire when the msg handling time is over
326  * it
327  */
328 INLINE void CConnectionRepository::
329 set_time_warning(float time_warning) {
330  _time_warning = time_warning;
331 }
332 
333 /**
334  * Returns the current setting of the time_warning field.
335  */
336 INLINE float CConnectionRepository::
338  return _time_warning;
339 }
CConnectionRepository::get_simulated_disconnect
bool get_simulated_disconnect() const
Returns the simulated disconnect flag.
Definition: cConnectionRepository.I:292
CConnectionRepository::set_in_quiet_zone
void set_in_quiet_zone(bool flag)
Enables/disables quiet zone mode.
Definition: cConnectionRepository.I:262
CConnectionRepository::set_want_message_bundling
void set_want_message_bundling(bool flag)
Enable/disable outbound message bundling.
Definition: cConnectionRepository.I:242
ReMutexHolder
Similar to MutexHolder, but for a reentrant mutex.
Definition: reMutexHolder.h:25
CConnectionRepository::get_handle_datagrams_internally
bool get_handle_datagrams_internally() const
Returns the handle_datagrams_internally flag.
Definition: cConnectionRepository.I:85
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
CConnectionRepository::get_client_datagram
bool get_client_datagram() const
Returns the client_datagram flag.
Definition: cConnectionRepository.I:64
CConnectionRepository::set_handle_datagrams_internally
void set_handle_datagrams_internally(bool handle_datagrams_internally)
Sets the handle_datagrams_internally flag.
Definition: cConnectionRepository.I:77
CConnectionRepository::get_datagram
void get_datagram(Datagram &dg)
Fills the datagram object with the datagram most recently retrieved by check_datagram().
Definition: cConnectionRepository.I:158
CConnectionRepository::get_in_quiet_zone
bool get_in_quiet_zone() const
Returns true if repository is in quiet zone mode.
Definition: cConnectionRepository.I:271
DCFile
Represents the complete list of Distributed Class descriptions as read from a .dc file.
Definition: dcFile.h:32
CConnectionRepository::set_verbose
void set_verbose(bool verbose)
Directly sets the verbose flag.
Definition: cConnectionRepository.I:310
CConnectionRepository::get_tcp_header_size
int get_tcp_header_size() const
Returns the current setting of TCP header size.
Definition: cConnectionRepository.I:93
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
CConnectionRepository::set_handle_c_updates
void set_handle_c_updates(bool handle_c_updates)
Set true to specify this repository should process distributed updates internally in C++ code,...
Definition: cConnectionRepository.I:36
CConnectionRepository::get_verbose
bool get_verbose() const
Returns the current setting of the verbose flag.
Definition: cConnectionRepository.I:319
ConnectionWriter
This class handles threaded delivery of datagrams to various TCP or UDP sockets.
Definition: connectionWriter.h:35
CConnectionRepository::set_simulated_disconnect
void set_simulated_disconnect(bool simulated_disconnect)
Sets the simulated disconnect flag.
Definition: cConnectionRepository.I:282
CConnectionRepository::has_owner_view
bool has_owner_view() const
Returns true if this repository can have 'owner' views of distributed objects.
Definition: cConnectionRepository.I:27
CConnectionRepository::set_time_warning
void set_time_warning(float time_warning)
Directly sets the time_warning field.
Definition: cConnectionRepository.I:329
CConnectionRepository::get_time_warning
float get_time_warning() const
Returns the current setting of the time_warning field.
Definition: cConnectionRepository.I:337
CConnectionRepository::get_dc_file
DCFile & get_dc_file()
Returns the DCFile object associated with this repository.
Definition: cConnectionRepository.I:18
Buffered_DatagramConnection
Definition: buffered_datagramconnection.h:35
CConnectionRepository::get_msg_type
unsigned int get_msg_type() const
Returns the security code associated with the current message, according to the datagram headers.
Definition: cConnectionRepository.I:214
CConnectionRepository::get_overflow_event_name
static const std::string & get_overflow_event_name()
Returns event string that will be thrown if the datagram reader queue overflows.
Definition: cConnectionRepository.I:224
QueuedConnectionManager
This flavor of ConnectionManager will queue up all of the reset-connection messages from the Connecti...
Definition: queuedConnectionManager.h:35
CConnectionRepository::get_want_message_bundling
bool get_want_message_bundling() const
Returns true if message bundling enabled.
Definition: cConnectionRepository.I:253
CConnectionRepository::get_msg_sender
CHANNEL_TYPE get_msg_sender() const
Returns the sender ID of the current message, according to the datagram headers.
Definition: cConnectionRepository.I:197
CConnectionRepository::get_msg_channel
CHANNEL_TYPE get_msg_channel(int offset=0) const
Returns the channel(s) to which the current message was sent, according to the datagram headers.
Definition: cConnectionRepository.I:180
CConnectionRepository::is_bundling_messages
bool is_bundling_messages() const
Returns true if repository is queueing outgoing messages into a message bundle.
Definition: cConnectionRepository.I:233
CConnectionRepository::get_handle_c_updates
bool get_handle_c_updates() const
Returns true if this repository will process distributed updates internally in C++ code,...
Definition: cConnectionRepository.I:45
CConnectionRepository::get_datagram_iterator
void get_datagram_iterator(DatagramIterator &di)
Fills the DatagramIterator object with the iterator for the datagram most recently retrieved by check...
Definition: cConnectionRepository.I:170
QueuedConnectionReader
This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for...
Definition: queuedConnectionReader.h:33
CConnectionRepository::set_client_datagram
void set_client_datagram(bool client_datagram)
Sets the client_datagram flag.
Definition: cConnectionRepository.I:56
CConnectionRepository::toggle_verbose
void toggle_verbose()
Toggles the current setting of the verbose flag.
Definition: cConnectionRepository.I:301