Panda3D
 All Classes Functions Variables Enumerations
pStatClientImpl.I
00001 // Filename: pStatClientImpl.I
00002 // Created by:  drose (23Dec04)
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: PStatClientImpl::set_client_name
00018 //       Access: Public
00019 //  Description: Sets the name of the client.  This is reported to the
00020 //               PStatsServer, and will presumably be written in the
00021 //               title bar or something.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE void PStatClientImpl::
00024 set_client_name(const string &name) {
00025   _client_name = name;
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: PStatClientImpl::get_client_name
00030 //       Access: Public
00031 //  Description: Retrieves the name of the client as set.
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE string PStatClientImpl::
00034 get_client_name() const {
00035   return _client_name;
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: PStatClientImpl::set_max_rate
00040 //       Access: Public
00041 //  Description: Controls the number of packets that will be sent to
00042 //               the server.  Normally, one packet is sent per frame,
00043 //               but this can flood the server with more packets than
00044 //               it can handle if the frame rate is especially good
00045 //               (e.g. if nothing is onscreen at the moment).  Set
00046 //               this parameter to a reasonable number to prevent this
00047 //               from happening.
00048 //
00049 //               This number specifies the maximum number of packets
00050 //               that will be sent to the server per second, per
00051 //               thread.
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE void PStatClientImpl::
00054 set_max_rate(double rate) {
00055   _max_rate = rate;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: PStatClientImpl::get_max_rate
00060 //       Access: Public
00061 //  Description: Returns the maximum number of packets that will be
00062 //               sent to the server per second, per thread.  See
00063 //               set_max_rate().
00064 ////////////////////////////////////////////////////////////////////
00065 INLINE double PStatClientImpl::
00066 get_max_rate() const {
00067   return _max_rate;
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: PStatClientImpl::get_real_time
00072 //       Access: Public
00073 //  Description: Returns the time according to the PStatClientImpl's
00074 //               clock object.  It keeps its own clock, instead of
00075 //               using the global clock object, so the stats won't get
00076 //               mucked up if you put the global clock in
00077 //               non-real-time mode or something.
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE double PStatClientImpl::
00080 get_real_time() const {
00081   return _clock->get_short_time() + _delta;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: PStatClientImpl::client_main_tick
00086 //       Access: Public
00087 //  Description: Called only by PStatClient::client_main_tick().
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void PStatClientImpl::
00090 client_main_tick() {
00091   _last_frame = _clock->get_short_time();
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: PStatClientImpl::client_is_connected
00096 //       Access: Public
00097 //  Description: Called only by PStatClient::client_is_connected().
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE bool PStatClientImpl::
00100 client_is_connected() const {
00101   return _is_connected;
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: PStatClientImpl::client_resume_after_pause
00106 //       Access: Public
00107 //  Description: Called only by PStatClient::client_resume_after_pause().
00108 ////////////////////////////////////////////////////////////////////
00109 INLINE void PStatClientImpl::
00110 client_resume_after_pause() {
00111   // Simply reset the clock to the beginning of the last frame.  This
00112   // may lose a frame, but on the other hand we won't skip a whole
00113   // slew of frames either.
00114   double delta = _clock->get_short_time() - _last_frame;
00115   _delta -= delta;
00116 }
 All Classes Functions Variables Enumerations