pStatClientImpl.I 4.5 KB

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