00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifdef DO_PSTATS
00017
00018
00019
00020
00021
00022
00023
00024
00025 INLINE PStatCollector::
00026 PStatCollector(PStatClient *client, int index) :
00027 _client(client),
00028 _index(index),
00029 _level(0.0f)
00030 {
00031 }
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 INLINE PStatCollector::
00042 PStatCollector() :
00043 _client(NULL),
00044 _index(0),
00045 _level(0.0f)
00046 {
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 INLINE PStatCollector::
00070 PStatCollector(const string &name, PStatClient *client) :
00071 _level(0.0f)
00072 {
00073 if (client == (PStatClient *)NULL) {
00074 client = PStatClient::get_global_pstats();
00075 }
00076 (*this) = client->make_collector_with_relname(0, name);
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 INLINE PStatCollector::
00103 PStatCollector(const PStatCollector &parent, const string &name) :
00104 _level(0.0f)
00105 {
00106 nassertv(parent._client != (PStatClient *)NULL);
00107 (*this) =
00108 parent._client->make_collector_with_relname(parent._index, name);
00109 }
00110
00111
00112
00113
00114
00115
00116 INLINE PStatCollector::
00117 PStatCollector(const PStatCollector ©) :
00118 _client(copy._client),
00119 _index(copy._index),
00120 _level(0.0f)
00121 {
00122 }
00123
00124
00125
00126
00127
00128
00129 INLINE void PStatCollector::
00130 operator = (const PStatCollector ©) {
00131 _client = copy._client;
00132 _index = copy._index;
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 INLINE bool PStatCollector::
00144 is_valid() const {
00145 return (_client != (PStatClient *)NULL);
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155 INLINE string PStatCollector::
00156 get_name() const {
00157 if (_client != (PStatClient *)NULL) {
00158 return _client->get_collector_name(_index);
00159 }
00160 return string();
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170 INLINE string PStatCollector::
00171 get_fullname() const {
00172 if (_client != (PStatClient *)NULL) {
00173 return _client->get_collector_fullname(_index);
00174 }
00175 return string();
00176 }
00177
00178
00179
00180
00181
00182
00183 INLINE void PStatCollector::
00184 output(ostream &out) const {
00185 out << "PStatCollector(\"" << get_fullname() << "\")";
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195 INLINE bool PStatCollector::
00196 is_active() {
00197 #ifndef HAVE_THREADS
00198 return _client->is_active(_index, 0);
00199 #else // HAVE_THREADS
00200 return is_active(_client->get_current_thread());
00201 #endif // HAVE_THREADS
00202 }
00203
00204
00205
00206
00207
00208
00209
00210 INLINE bool PStatCollector::
00211 is_started() {
00212 #ifndef HAVE_THREADS
00213 return _client->is_started(_index, 0);
00214 #else // HAVE_THREADS
00215 return is_started(_client->get_current_thread());
00216 #endif // HAVE_THREADS
00217 }
00218
00219
00220
00221
00222
00223
00224
00225 INLINE void PStatCollector::
00226 start() {
00227 #ifndef HAVE_THREADS
00228 _client->start(_index, 0);
00229 #else // HAVE_THREADS
00230 start(_client->get_current_thread());
00231 #endif // HAVE_THREADS
00232 }
00233
00234
00235
00236
00237
00238
00239
00240 INLINE void PStatCollector::
00241 stop() {
00242 #ifndef HAVE_THREADS
00243 _client->stop(_index, 0);
00244 #else // HAVE_THREADS
00245 stop(_client->get_current_thread());
00246 #endif // HAVE_THREADS
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 INLINE void PStatCollector::
00258 clear_level() {
00259 _client->clear_level(_index, 0);
00260 _level = 0.0f;
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270 INLINE void PStatCollector::
00271 set_level(double level) {
00272 _client->set_level(_index, 0, level);
00273 _level = 0.0f;
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 INLINE void PStatCollector::
00290 add_level(double increment) {
00291 _level += increment;
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 INLINE void PStatCollector::
00308 sub_level(double decrement) {
00309 _level -= decrement;
00310 }
00311
00312
00313
00314
00315
00316
00317 INLINE void PStatCollector::
00318 add_level_now(double increment) {
00319 add_level(increment);
00320 flush_level();
00321 }
00322
00323
00324
00325
00326
00327
00328 INLINE void PStatCollector::
00329 sub_level_now(double decrement) {
00330 sub_level(decrement);
00331 flush_level();
00332 }
00333
00334
00335
00336
00337
00338
00339
00340 INLINE void PStatCollector::
00341 flush_level() {
00342 if (_level != 0.0f) {
00343 _client->add_level(_index, 0, _level);
00344 _level = 0.0f;
00345 }
00346 }
00347
00348
00349
00350
00351
00352
00353
00354
00355 INLINE double PStatCollector::
00356 get_level() {
00357 flush_level();
00358 return _client->get_level(_index, 0);
00359 }
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 INLINE void PStatCollector::
00370 clear_thread_level() {
00371 #ifndef HAVE_THREADS
00372 _client->clear_level(_index, 0);
00373 #else // HAVE_THREADS
00374 clear_level(_client->get_current_thread());
00375 #endif // HAVE_THREADS
00376 }
00377
00378
00379
00380
00381
00382
00383
00384
00385 INLINE void PStatCollector::
00386 set_thread_level(double level) {
00387 #ifndef HAVE_THREADS
00388 _client->set_level(_index, 0, level);
00389 #else // HAVE_THREADS
00390 set_level(_client->get_current_thread(), level);
00391 #endif // HAVE_THREADS
00392 }
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403 INLINE void PStatCollector::
00404 add_thread_level(double increment) {
00405 #ifndef HAVE_THREADS
00406 _client->add_level(_index, 0, increment);
00407 #else // HAVE_THREADS
00408 add_level(_client->get_current_thread(), increment);
00409 #endif // HAVE_THREADS
00410 }
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 INLINE void PStatCollector::
00422 sub_thread_level(double decrement) {
00423 #ifndef HAVE_THREADS
00424 _client->add_level(_index, 0, -decrement);
00425 #else // HAVE_THREADS
00426 sub_level(_client->get_current_thread(), decrement);
00427 #endif // HAVE_THREADS
00428 }
00429
00430
00431
00432
00433
00434
00435
00436 INLINE double PStatCollector::
00437 get_thread_level() {
00438 #ifndef HAVE_THREADS
00439 return _client->get_level(_index, 0);
00440 #else // HAVE_THREADS
00441 return get_level(_client->get_current_thread());
00442 #endif // HAVE_THREADS
00443 }
00444
00445
00446
00447
00448
00449
00450
00451
00452 INLINE bool PStatCollector::
00453 is_active(const PStatThread &thread) {
00454 return _client->is_active(_index, thread._index);
00455 }
00456
00457
00458
00459
00460
00461
00462
00463 INLINE bool PStatCollector::
00464 is_started(const PStatThread &thread) {
00465 return _client->is_started(_index, thread._index);
00466 }
00467
00468
00469
00470
00471
00472
00473 INLINE void PStatCollector::
00474 start(const PStatThread &thread) {
00475 nassertv(_client != NULL);
00476 _client->start(_index, thread._index);
00477 }
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 INLINE void PStatCollector::
00489 start(const PStatThread &thread, double as_of) {
00490 _client->start(_index, thread._index, as_of);
00491 }
00492
00493
00494
00495
00496
00497
00498 INLINE void PStatCollector::
00499 stop(const PStatThread &thread) {
00500 _client->stop(_index, thread._index);
00501 }
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512 INLINE void PStatCollector::
00513 stop(const PStatThread &thread, double as_of) {
00514 _client->stop(_index, thread._index, as_of);
00515 }
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525 INLINE void PStatCollector::
00526 clear_level(const PStatThread &thread) {
00527 _client->clear_level(_index, thread._index);
00528 }
00529
00530
00531
00532
00533
00534
00535
00536
00537 INLINE void PStatCollector::
00538 set_level(const PStatThread &thread, double level) {
00539 _client->set_level(_index, thread._index, level);
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 INLINE void PStatCollector::
00552 add_level(const PStatThread &thread, double increment) {
00553 _client->add_level(_index, thread._index, increment);
00554 }
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565 INLINE void PStatCollector::
00566 sub_level(const PStatThread &thread, double decrement) {
00567 _client->add_level(_index, thread._index, -decrement);
00568 }
00569
00570
00571
00572
00573
00574
00575 INLINE double PStatCollector::
00576 get_level(const PStatThread &thread) {
00577 return _client->get_level(_index, thread._index);
00578 }
00579
00580
00581
00582
00583
00584
00585
00586 INLINE int PStatCollector::
00587 get_index() const {
00588 return _index;
00589 }
00590
00591 #else // DO_PSTATS
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601 INLINE PStatCollector::
00602 PStatCollector()
00603 {
00604 }
00605
00606
00607
00608
00609
00610
00611
00612
00613 INLINE PStatCollector::
00614 PStatCollector(const string &, PStatClient *client) {
00615
00616
00617 #ifdef mips
00618 if (client == (PStatClient *)NULL) {
00619 return;
00620 }
00621 #endif
00622 }
00623
00624
00625
00626
00627
00628
00629
00630
00631 INLINE PStatCollector::
00632 PStatCollector(const PStatCollector &parent, const string &) {
00633
00634
00635 #ifdef mips
00636 if (&parent == (const PStatCollector *)NULL) {
00637 return;
00638 }
00639 #endif
00640 }
00641
00642
00643 #endif // DO_PSTATS