pStatFrameData.I 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. // Filename: pStatFrameData.I
  2. // Created by: drose (10Jul00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: PStatFrameData::is_time_empty
  20. // Access: Public
  21. // Description: Returns true if there are no time events in the frame
  22. // data, false otherwise.
  23. ////////////////////////////////////////////////////////////////////
  24. INLINE bool PStatFrameData::
  25. is_time_empty() const {
  26. return _time_data.empty();
  27. }
  28. ////////////////////////////////////////////////////////////////////
  29. // Function: PStatFrameData::is_level_empty
  30. // Access: Public
  31. // Description: Returns true if there are no levels indicated in the
  32. // frame data, false otherwise.
  33. ////////////////////////////////////////////////////////////////////
  34. INLINE bool PStatFrameData::
  35. is_level_empty() const {
  36. return _level_data.empty();
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: PStatFrameData::is_empty
  40. // Access: Public
  41. // Description: Returns true if the FrameData has no time or level
  42. // data.
  43. ////////////////////////////////////////////////////////////////////
  44. INLINE bool PStatFrameData::
  45. is_empty() const {
  46. return is_time_empty() && is_level_empty();
  47. }
  48. ////////////////////////////////////////////////////////////////////
  49. // Function: PStatFrameData::clear
  50. // Access: Public
  51. // Description: Removes all the data points from the frame data, in
  52. // preparation for building up a new frame's worth.
  53. ////////////////////////////////////////////////////////////////////
  54. INLINE void PStatFrameData::
  55. clear() {
  56. _time_data.clear();
  57. _level_data.clear();
  58. }
  59. ////////////////////////////////////////////////////////////////////
  60. // Function: PStatFrameData::add_start
  61. // Access: Public
  62. // Description: Adds a 'start collector' data point to the frame
  63. // data.
  64. ////////////////////////////////////////////////////////////////////
  65. INLINE void PStatFrameData::
  66. add_start(int index, float time) {
  67. nassertv((index & 0x7fff) == index);
  68. DataPoint dp;
  69. dp._index = index;
  70. dp._value = time;
  71. _time_data.push_back(dp);
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: PStatFrameData::add_stop
  75. // Access: Public
  76. // Description: Adds a 'stop collector' data point to the frame
  77. // data.
  78. ////////////////////////////////////////////////////////////////////
  79. INLINE void PStatFrameData::
  80. add_stop(int index, float time) {
  81. nassertv((index & 0x7fff) == index);
  82. DataPoint dp;
  83. dp._index = index | 0x8000;
  84. dp._value = time;
  85. _time_data.push_back(dp);
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: PStatFrameData::add_level
  89. // Access: Public
  90. // Description: Adds a particular level value associated with a given
  91. // collector to the frame data.
  92. ////////////////////////////////////////////////////////////////////
  93. INLINE void PStatFrameData::
  94. add_level(int index, float level) {
  95. nassertv((index & 0xffff) == index);
  96. DataPoint dp;
  97. dp._index = index;
  98. dp._value = level;
  99. _level_data.push_back(dp);
  100. }
  101. ////////////////////////////////////////////////////////////////////
  102. // Function: PStatFrameData::get_start
  103. // Access: Public
  104. // Description: Returns the time of the first data point in the frame
  105. // data. This will generally be the time of the start
  106. // of the frame.
  107. ////////////////////////////////////////////////////////////////////
  108. INLINE float PStatFrameData::
  109. get_start() const {
  110. nassertr(!is_empty(), 0.0);
  111. return _time_data.front()._value;
  112. }
  113. ////////////////////////////////////////////////////////////////////
  114. // Function: PStatFrameData::get_end
  115. // Access: Public
  116. // Description: Returns the time of the last data point in the frame
  117. // data. This will generally be the time of the end
  118. // of the frame.
  119. ////////////////////////////////////////////////////////////////////
  120. INLINE float PStatFrameData::
  121. get_end() const {
  122. nassertr(!is_empty(), 0.0);
  123. return _time_data.back()._value;
  124. }
  125. ////////////////////////////////////////////////////////////////////
  126. // Function: PStatFrameData::get_net_time
  127. // Access: Public
  128. // Description: Returns the total time elapsed for the frame.
  129. ////////////////////////////////////////////////////////////////////
  130. INLINE float PStatFrameData::
  131. get_net_time() const {
  132. nassertr(!is_empty(), 0.0);
  133. return _time_data.back()._value - _time_data.front()._value;
  134. }
  135. ////////////////////////////////////////////////////////////////////
  136. // Function: PStatFrameData::get_num_events
  137. // Access: Public
  138. // Description: Returns the number of individual events stored in the
  139. // FrameData.
  140. ////////////////////////////////////////////////////////////////////
  141. INLINE int PStatFrameData::
  142. get_num_events() const {
  143. return _time_data.size();
  144. }
  145. ////////////////////////////////////////////////////////////////////
  146. // Function: PStatFrameData::get_time_collector
  147. // Access: Public
  148. // Description: Returns the index of the collector associated with
  149. // the nth event.
  150. ////////////////////////////////////////////////////////////////////
  151. INLINE int PStatFrameData::
  152. get_time_collector(int n) const {
  153. nassertr(n >= 0 && n < (int)_time_data.size(), 0);
  154. return _time_data[n]._index & 0x7fff;
  155. }
  156. ////////////////////////////////////////////////////////////////////
  157. // Function: PStatFrameData::is_start
  158. // Access: Public
  159. // Description: Returns true if the nth event represents a start
  160. // event, or false if it represents a stop event.
  161. ////////////////////////////////////////////////////////////////////
  162. INLINE bool PStatFrameData::
  163. is_start(int n) const {
  164. nassertr(n >= 0 && n < (int)_time_data.size(), 0);
  165. return (_time_data[n]._index & 0x8000) == 0;
  166. }
  167. ////////////////////////////////////////////////////////////////////
  168. // Function: PStatFrameData::get_time
  169. // Access: Public
  170. // Description: Returns the timestamp of the nth event, in seconds
  171. // elapsed since some undefined epoch (which is
  172. // guaranteed to be shared among all events returned
  173. // from a given client).
  174. ////////////////////////////////////////////////////////////////////
  175. INLINE float PStatFrameData::
  176. get_time(int n) const {
  177. nassertr(n >= 0 && n < (int)_time_data.size(), 0);
  178. return _time_data[n]._value;
  179. }
  180. ////////////////////////////////////////////////////////////////////
  181. // Function: PStatFrameData::get_num_levels
  182. // Access: Public
  183. // Description: Returns the number of individual level values stored
  184. // in the FrameData.
  185. ////////////////////////////////////////////////////////////////////
  186. INLINE int PStatFrameData::
  187. get_num_levels() const {
  188. return _level_data.size();
  189. }
  190. ////////////////////////////////////////////////////////////////////
  191. // Function: PStatFrameData::get_level_collector
  192. // Access: Public
  193. // Description: Returns the index of the collector associated with
  194. // the nth level value.
  195. ////////////////////////////////////////////////////////////////////
  196. INLINE int PStatFrameData::
  197. get_level_collector(int n) const {
  198. nassertr(n >= 0 && n < (int)_level_data.size(), 0);
  199. return _level_data[n]._index;
  200. }
  201. ////////////////////////////////////////////////////////////////////
  202. // Function: PStatFrameData::get_level
  203. // Access: Public
  204. // Description: Returns the height of the nth level value.
  205. ////////////////////////////////////////////////////////////////////
  206. INLINE float PStatFrameData::
  207. get_level(int n) const {
  208. nassertr(n >= 0 && n < (int)_level_data.size(), 0);
  209. return _level_data[n]._value;
  210. }