Panda3D
pStatClientImpl.I
1 // Filename: pStatClientImpl.I
2 // Created by: drose (23Dec04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PStatClientImpl::set_client_name
18 // Access: Public
19 // Description: Sets the name of the client. This is reported to the
20 // PStatsServer, and will presumably be written in the
21 // title bar or something.
22 ////////////////////////////////////////////////////////////////////
23 INLINE void PStatClientImpl::
24 set_client_name(const string &name) {
25  _client_name = name;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: PStatClientImpl::get_client_name
30 // Access: Public
31 // Description: Retrieves the name of the client as set.
32 ////////////////////////////////////////////////////////////////////
33 INLINE string PStatClientImpl::
34 get_client_name() const {
35  return _client_name;
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PStatClientImpl::set_max_rate
40 // Access: Public
41 // Description: Controls the number of packets that will be sent to
42 // the server. Normally, one packet is sent per frame,
43 // but this can flood the server with more packets than
44 // it can handle if the frame rate is especially good
45 // (e.g. if nothing is onscreen at the moment). Set
46 // this parameter to a reasonable number to prevent this
47 // from happening.
48 //
49 // This number specifies the maximum number of packets
50 // that will be sent to the server per second, per
51 // thread.
52 ////////////////////////////////////////////////////////////////////
53 INLINE void PStatClientImpl::
54 set_max_rate(double rate) {
55  _max_rate = rate;
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: PStatClientImpl::get_max_rate
60 // Access: Public
61 // Description: Returns the maximum number of packets that will be
62 // sent to the server per second, per thread. See
63 // set_max_rate().
64 ////////////////////////////////////////////////////////////////////
65 INLINE double PStatClientImpl::
66 get_max_rate() const {
67  return _max_rate;
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: PStatClientImpl::get_real_time
72 // Access: Public
73 // Description: Returns the time according to the PStatClientImpl's
74 // clock object. It keeps its own clock, instead of
75 // using the global clock object, so the stats won't get
76 // mucked up if you put the global clock in
77 // non-real-time mode or something.
78 ////////////////////////////////////////////////////////////////////
79 INLINE double PStatClientImpl::
80 get_real_time() const {
81  return _clock->get_short_time() + _delta;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: PStatClientImpl::client_main_tick
86 // Access: Public
87 // Description: Called only by PStatClient::client_main_tick().
88 ////////////////////////////////////////////////////////////////////
89 INLINE void PStatClientImpl::
90 client_main_tick() {
91  _last_frame = _clock->get_short_time();
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: PStatClientImpl::client_is_connected
96 // Access: Public
97 // Description: Called only by PStatClient::client_is_connected().
98 ////////////////////////////////////////////////////////////////////
99 INLINE bool PStatClientImpl::
100 client_is_connected() const {
101  return _is_connected;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: PStatClientImpl::client_resume_after_pause
106 // Access: Public
107 // Description: Called only by PStatClient::client_resume_after_pause().
108 ////////////////////////////////////////////////////////////////////
109 INLINE void PStatClientImpl::
110 client_resume_after_pause() {
111  // Simply reset the clock to the beginning of the last frame. This
112  // may lose a frame, but on the other hand we won't skip a whole
113  // slew of frames either.
114  double delta = _clock->get_short_time() - _last_frame;
115  _delta -= delta;
116 }