Panda3D
pStatClientImpl.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 pStatClientImpl.I
10  * @author drose
11  * @date 2004-12-23
12  */
13 
14 /**
15  * Sets the name of the client. This is reported to the PStatsServer, and
16  * will presumably be written in the title bar or something.
17  */
18 INLINE void PStatClientImpl::
19 set_client_name(const std::string &name) {
20  _client_name = name;
21 }
22 
23 /**
24  * Retrieves the name of the client as set.
25  */
26 INLINE std::string PStatClientImpl::
27 get_client_name() const {
28  return _client_name;
29 }
30 
31 /**
32  * Controls the number of packets that will be sent to the server. Normally,
33  * one packet is sent per frame, but this can flood the server with more
34  * packets than it can handle if the frame rate is especially good (e.g. if
35  * nothing is onscreen at the moment). Set this parameter to a reasonable
36  * number to prevent this from happening.
37  *
38  * This number specifies the maximum number of packets that will be sent to
39  * the server per second, per thread.
40  */
41 INLINE void PStatClientImpl::
42 set_max_rate(double rate) {
43  _max_rate = rate;
44 }
45 
46 /**
47  * Returns the maximum number of packets that will be sent to the server per
48  * second, per thread. See set_max_rate().
49  */
50 INLINE double PStatClientImpl::
51 get_max_rate() const {
52  return _max_rate;
53 }
54 
55 /**
56  * Returns the time according to the PStatClientImpl's clock object. It keeps
57  * its own clock, instead of using the global clock object, so the stats won't
58  * get mucked up if you put the global clock in non-real-time mode or
59  * something.
60  */
61 INLINE double PStatClientImpl::
62 get_real_time() const {
63  return _clock->get_short_time() + _delta;
64 }
65 
66 /**
67  * Called only by PStatClient::client_main_tick().
68  */
69 INLINE void PStatClientImpl::
70 client_main_tick() {
71  _last_frame = _clock->get_short_time();
72 }
73 
74 /**
75  * Called only by PStatClient::client_is_connected().
76  */
77 INLINE bool PStatClientImpl::
78 client_is_connected() const {
79  return _is_connected;
80 }
81 
82 /**
83  * Called only by PStatClient::client_resume_after_pause().
84  */
85 INLINE void PStatClientImpl::
86 client_resume_after_pause() {
87  // Simply reset the clock to the beginning of the last frame. This may lose
88  // a frame, but on the other hand we won't skip a whole slew of frames
89  // either.
90  double delta = _clock->get_short_time() - _last_frame;
91  _delta -= delta;
92 }