00001 // Filename: pStatFrameData.I 00002 // Created by: drose (10Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: PStatFrameData::is_time_empty 00022 // Access: Public 00023 // Description: Returns true if there are no time events in the frame 00024 // data, false otherwise. 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE bool PStatFrameData:: 00027 is_time_empty() const { 00028 return _time_data.empty(); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: PStatFrameData::is_level_empty 00033 // Access: Public 00034 // Description: Returns true if there are no levels indicated in the 00035 // frame data, false otherwise. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE bool PStatFrameData:: 00038 is_level_empty() const { 00039 return _level_data.empty(); 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: PStatFrameData::is_empty 00044 // Access: Public 00045 // Description: Returns true if the FrameData has no time or level 00046 // data. 00047 //////////////////////////////////////////////////////////////////// 00048 INLINE bool PStatFrameData:: 00049 is_empty() const { 00050 return is_time_empty() && is_level_empty(); 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: PStatFrameData::clear 00055 // Access: Public 00056 // Description: Removes all the data points from the frame data, in 00057 // preparation for building up a new frame's worth. 00058 //////////////////////////////////////////////////////////////////// 00059 INLINE void PStatFrameData:: 00060 clear() { 00061 _time_data.clear(); 00062 _level_data.clear(); 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: PStatFrameData::add_start 00067 // Access: Public 00068 // Description: Adds a 'start collector' data point to the frame 00069 // data. 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE void PStatFrameData:: 00072 add_start(int index, float time) { 00073 #ifdef _DEBUG 00074 nassertv((index & 0x7fff) == index); 00075 #endif 00076 DataPoint dp; 00077 dp._index = index; 00078 dp._value = time; 00079 _time_data.push_back(dp); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: PStatFrameData::add_stop 00084 // Access: Public 00085 // Description: Adds a 'stop collector' data point to the frame 00086 // data. 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE void PStatFrameData:: 00089 add_stop(int index, float time) { 00090 #ifdef _DEBUG 00091 nassertv((index & 0x7fff) == index); 00092 #endif 00093 DataPoint dp; 00094 dp._index = index | 0x8000; 00095 dp._value = time; 00096 _time_data.push_back(dp); 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: PStatFrameData::add_level 00101 // Access: Public 00102 // Description: Adds a particular level value associated with a given 00103 // collector to the frame data. 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE void PStatFrameData:: 00106 add_level(int index, float level) { 00107 #ifdef _DEBUG 00108 nassertv((index & 0xffff) == index); 00109 #endif 00110 DataPoint dp; 00111 dp._index = index; 00112 dp._value = level; 00113 _level_data.push_back(dp); 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: PStatFrameData::get_start 00118 // Access: Public 00119 // Description: Returns the time of the first data point in the frame 00120 // data. This will generally be the time of the start 00121 // of the frame. 00122 //////////////////////////////////////////////////////////////////// 00123 INLINE float PStatFrameData:: 00124 get_start() const { 00125 nassertr(!is_empty(), 0.0); 00126 00127 return _time_data.front()._value; 00128 } 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function: PStatFrameData::get_end 00132 // Access: Public 00133 // Description: Returns the time of the last data point in the frame 00134 // data. This will generally be the time of the end 00135 // of the frame. 00136 //////////////////////////////////////////////////////////////////// 00137 INLINE float PStatFrameData:: 00138 get_end() const { 00139 nassertr(!is_empty(), 0.0); 00140 00141 return _time_data.back()._value; 00142 } 00143 00144 //////////////////////////////////////////////////////////////////// 00145 // Function: PStatFrameData::get_net_time 00146 // Access: Public 00147 // Description: Returns the total time elapsed for the frame. 00148 //////////////////////////////////////////////////////////////////// 00149 INLINE float PStatFrameData:: 00150 get_net_time() const { 00151 nassertr(!is_empty(), 0.0); 00152 00153 return _time_data.back()._value - _time_data.front()._value; 00154 } 00155 00156 //////////////////////////////////////////////////////////////////// 00157 // Function: PStatFrameData::get_num_events 00158 // Access: Public 00159 // Description: Returns the number of individual events stored in the 00160 // FrameData. 00161 //////////////////////////////////////////////////////////////////// 00162 INLINE int PStatFrameData:: 00163 get_num_events() const { 00164 return _time_data.size(); 00165 } 00166 00167 //////////////////////////////////////////////////////////////////// 00168 // Function: PStatFrameData::get_time_collector 00169 // Access: Public 00170 // Description: Returns the index of the collector associated with 00171 // the nth event. 00172 //////////////////////////////////////////////////////////////////// 00173 INLINE int PStatFrameData:: 00174 get_time_collector(int n) const { 00175 nassertr(n >= 0 && n < (int)_time_data.size(), 0); 00176 return _time_data[n]._index & 0x7fff; 00177 } 00178 00179 //////////////////////////////////////////////////////////////////// 00180 // Function: PStatFrameData::is_start 00181 // Access: Public 00182 // Description: Returns true if the nth event represents a start 00183 // event, or false if it represents a stop event. 00184 //////////////////////////////////////////////////////////////////// 00185 INLINE bool PStatFrameData:: 00186 is_start(int n) const { 00187 nassertr(n >= 0 && n < (int)_time_data.size(), 0); 00188 return (_time_data[n]._index & 0x8000) == 0; 00189 } 00190 00191 //////////////////////////////////////////////////////////////////// 00192 // Function: PStatFrameData::get_time 00193 // Access: Public 00194 // Description: Returns the timestamp of the nth event, in seconds 00195 // elapsed since some undefined epoch (which is 00196 // guaranteed to be shared among all events returned 00197 // from a given client). 00198 //////////////////////////////////////////////////////////////////// 00199 INLINE float PStatFrameData:: 00200 get_time(int n) const { 00201 nassertr(n >= 0 && n < (int)_time_data.size(), 0); 00202 return _time_data[n]._value; 00203 } 00204 00205 //////////////////////////////////////////////////////////////////// 00206 // Function: PStatFrameData::get_num_levels 00207 // Access: Public 00208 // Description: Returns the number of individual level values stored 00209 // in the FrameData. 00210 //////////////////////////////////////////////////////////////////// 00211 INLINE int PStatFrameData:: 00212 get_num_levels() const { 00213 return _level_data.size(); 00214 } 00215 00216 //////////////////////////////////////////////////////////////////// 00217 // Function: PStatFrameData::get_level_collector 00218 // Access: Public 00219 // Description: Returns the index of the collector associated with 00220 // the nth level value. 00221 //////////////////////////////////////////////////////////////////// 00222 INLINE int PStatFrameData:: 00223 get_level_collector(int n) const { 00224 nassertr(n >= 0 && n < (int)_level_data.size(), 0); 00225 return _level_data[n]._index; 00226 } 00227 00228 //////////////////////////////////////////////////////////////////// 00229 // Function: PStatFrameData::get_level 00230 // Access: Public 00231 // Description: Returns the height of the nth level value. 00232 //////////////////////////////////////////////////////////////////// 00233 INLINE float PStatFrameData:: 00234 get_level(int n) const { 00235 nassertr(n >= 0 && n < (int)_level_data.size(), 0); 00236 return _level_data[n]._value; 00237 }