Panda3D
|
00001 // Filename: pStatFrameData.I 00002 // Created by: drose (10Jul00) 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: PStatFrameData::is_time_empty 00018 // Access: Public 00019 // Description: Returns true if there are no time events in the frame 00020 // data, false otherwise. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE bool PStatFrameData:: 00023 is_time_empty() const { 00024 return _time_data.empty(); 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: PStatFrameData::is_level_empty 00029 // Access: Public 00030 // Description: Returns true if there are no levels indicated in the 00031 // frame data, false otherwise. 00032 //////////////////////////////////////////////////////////////////// 00033 INLINE bool PStatFrameData:: 00034 is_level_empty() const { 00035 return _level_data.empty(); 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: PStatFrameData::is_empty 00040 // Access: Public 00041 // Description: Returns true if the FrameData has no time or level 00042 // data. 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE bool PStatFrameData:: 00045 is_empty() const { 00046 return is_time_empty() && is_level_empty(); 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: PStatFrameData::clear 00051 // Access: Public 00052 // Description: Removes all the data points from the frame data, in 00053 // preparation for building up a new frame's worth. 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE void PStatFrameData:: 00056 clear() { 00057 _time_data.clear(); 00058 _level_data.clear(); 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: PStatFrameData::swap 00063 // Access: Public 00064 // Description: Exchanges the data in this object with the data in 00065 // the other. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE void PStatFrameData:: 00068 swap(PStatFrameData &other) { 00069 _time_data.swap(other._time_data); 00070 _level_data.swap(other._level_data); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: PStatFrameData::add_start 00075 // Access: Public 00076 // Description: Adds a 'start collector' data point to the frame 00077 // data. 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE void PStatFrameData:: 00080 add_start(int index, double time) { 00081 #ifdef _DEBUG 00082 nassertv((index & 0x7fff) == index); 00083 #endif 00084 DataPoint dp; 00085 dp._index = index; 00086 dp._value = time; 00087 _time_data.push_back(dp); 00088 } 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: PStatFrameData::add_stop 00092 // Access: Public 00093 // Description: Adds a 'stop collector' data point to the frame 00094 // data. 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE void PStatFrameData:: 00097 add_stop(int index, double time) { 00098 #ifdef _DEBUG 00099 nassertv((index & 0x7fff) == index); 00100 #endif 00101 DataPoint dp; 00102 dp._index = index | 0x8000; 00103 dp._value = time; 00104 _time_data.push_back(dp); 00105 } 00106 00107 //////////////////////////////////////////////////////////////////// 00108 // Function: PStatFrameData::add_level 00109 // Access: Public 00110 // Description: Adds a particular level value associated with a given 00111 // collector to the frame data. 00112 //////////////////////////////////////////////////////////////////// 00113 INLINE void PStatFrameData:: 00114 add_level(int index, double level) { 00115 #ifdef _DEBUG 00116 nassertv((index & 0xffff) == index); 00117 #endif 00118 DataPoint dp; 00119 dp._index = index; 00120 dp._value = level; 00121 _level_data.push_back(dp); 00122 } 00123 00124 //////////////////////////////////////////////////////////////////// 00125 // Function: PStatFrameData::get_start 00126 // Access: Public 00127 // Description: Returns the time of the first data point in the frame 00128 // data. This will generally be the time of the start 00129 // of the frame. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE double PStatFrameData:: 00132 get_start() const { 00133 if (is_empty()) { 00134 return 0.0; 00135 } 00136 00137 return _time_data.front()._value; 00138 } 00139 00140 //////////////////////////////////////////////////////////////////// 00141 // Function: PStatFrameData::get_end 00142 // Access: Public 00143 // Description: Returns the time of the last data point in the frame 00144 // data. This will generally be the time of the end 00145 // of the frame. 00146 //////////////////////////////////////////////////////////////////// 00147 INLINE double PStatFrameData:: 00148 get_end() const { 00149 nassertr(!is_empty(), 0.0); 00150 00151 return _time_data.back()._value; 00152 } 00153 00154 //////////////////////////////////////////////////////////////////// 00155 // Function: PStatFrameData::get_net_time 00156 // Access: Public 00157 // Description: Returns the total time elapsed for the frame. 00158 //////////////////////////////////////////////////////////////////// 00159 INLINE double PStatFrameData:: 00160 get_net_time() const { 00161 nassertr(!is_empty(), 0.0); 00162 00163 return _time_data.back()._value - _time_data.front()._value; 00164 } 00165 00166 //////////////////////////////////////////////////////////////////// 00167 // Function: PStatFrameData::get_num_events 00168 // Access: Public 00169 // Description: Returns the number of individual events stored in the 00170 // FrameData. 00171 //////////////////////////////////////////////////////////////////// 00172 INLINE int PStatFrameData:: 00173 get_num_events() const { 00174 return _time_data.size(); 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: PStatFrameData::get_time_collector 00179 // Access: Public 00180 // Description: Returns the index of the collector associated with 00181 // the nth event. 00182 //////////////////////////////////////////////////////////////////// 00183 INLINE int PStatFrameData:: 00184 get_time_collector(int n) const { 00185 nassertr(n >= 0 && n < (int)_time_data.size(), 0); 00186 return _time_data[n]._index & 0x7fff; 00187 } 00188 00189 //////////////////////////////////////////////////////////////////// 00190 // Function: PStatFrameData::is_start 00191 // Access: Public 00192 // Description: Returns true if the nth event represents a start 00193 // event, or false if it represents a stop event. 00194 //////////////////////////////////////////////////////////////////// 00195 INLINE bool PStatFrameData:: 00196 is_start(int n) const { 00197 nassertr(n >= 0 && n < (int)_time_data.size(), 0); 00198 return (_time_data[n]._index & 0x8000) == 0; 00199 } 00200 00201 //////////////////////////////////////////////////////////////////// 00202 // Function: PStatFrameData::get_time 00203 // Access: Public 00204 // Description: Returns the timestamp of the nth event, in seconds 00205 // elapsed since some undefined epoch (which is 00206 // guaranteed to be shared among all events returned 00207 // from a given client). 00208 //////////////////////////////////////////////////////////////////// 00209 INLINE double PStatFrameData:: 00210 get_time(int n) const { 00211 nassertr(n >= 0 && n < (int)_time_data.size(), 0); 00212 return _time_data[n]._value; 00213 } 00214 00215 //////////////////////////////////////////////////////////////////// 00216 // Function: PStatFrameData::get_num_levels 00217 // Access: Public 00218 // Description: Returns the number of individual level values stored 00219 // in the FrameData. 00220 //////////////////////////////////////////////////////////////////// 00221 INLINE int PStatFrameData:: 00222 get_num_levels() const { 00223 return _level_data.size(); 00224 } 00225 00226 //////////////////////////////////////////////////////////////////// 00227 // Function: PStatFrameData::get_level_collector 00228 // Access: Public 00229 // Description: Returns the index of the collector associated with 00230 // the nth level value. 00231 //////////////////////////////////////////////////////////////////// 00232 INLINE int PStatFrameData:: 00233 get_level_collector(int n) const { 00234 nassertr(n >= 0 && n < (int)_level_data.size(), 0); 00235 return _level_data[n]._index; 00236 } 00237 00238 //////////////////////////////////////////////////////////////////// 00239 // Function: PStatFrameData::get_level 00240 // Access: Public 00241 // Description: Returns the height of the nth level value. 00242 //////////////////////////////////////////////////////////////////// 00243 INLINE double PStatFrameData:: 00244 get_level(int n) const { 00245 nassertr(n >= 0 && n < (int)_level_data.size(), 0); 00246 return _level_data[n]._value; 00247 } 00248 00249 //////////////////////////////////////////////////////////////////// 00250 // Function: PStatFrameData::DataPoint::operator < 00251 // Access: Public 00252 // Description: Orders the data points by time. 00253 //////////////////////////////////////////////////////////////////// 00254 INLINE bool PStatFrameData::DataPoint:: 00255 operator < (const PStatFrameData::DataPoint &other) const { 00256 return _value < other._value; 00257 } 00258