Panda3D

pStatThreadData.h
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pStatThreadData.h
10 * @author drose
11 * @date 2000-07-08
12 */
13
14 #ifndef PSTATTHREADDATA_H
15 #define PSTATTHREADDATA_H
16
17 #include "pandatoolbase.h"
18
19 #include "referenceCount.h"
20
21 #include "pdeque.h"
22
23 class PStatCollectorDef;
24 class PStatFrameData;
25 class PStatClientData;
26
27 /**
28 * A collection of FrameData structures for recently-received frames within a
29 * particular thread. This holds the raw data as reported by the client, and
30 * it automatically handles frames received out-of-order or skipped. You can
31 * ask for a particular frame by frame number or time and receive the data for
32 * the nearest frame.
33 */
34 class PStatThreadData : public ReferenceCount {
35 public:
36 PStatThreadData(const PStatClientData *client_data);
37 ~PStatThreadData();
38
39 INLINE const PStatClientData *get_client_data() const;
40
41 bool is_empty() const;
42
43 int get_latest_frame_number() const;
44 int get_oldest_frame_number() const;
45 bool has_frame(int frame_number) const;
46 const PStatFrameData &get_frame(int frame_number) const;
47
48 double get_latest_time() const;
49 double get_oldest_time() const;
50 const PStatFrameData &get_frame_at_time(double time) const;
51 int get_frame_number_at_time(double time, int hint = -1) const;
52
53 const PStatFrameData &get_latest_frame() const;
54
55 bool get_elapsed_frames(int &then_i, int &now_i) const;
56 double get_frame_rate() const;
57
58
59 void set_history(double time);
60 double get_history() const;
61
62 void record_new_frame(int frame_number, PStatFrameData *frame_data);
63
64 private:
65 void compute_elapsed_frames();
66 const PStatClientData *_client_data;
67
68 typedef pdeque<PStatFrameData *> Frames;
69 Frames _frames;
70 int _first_frame_number;
71 double _history;
72
73 bool _computed_elapsed_frames;
74 bool _got_elapsed_frames;
75 int _then_i;
76 int _now_i;
77
78 static PStatFrameData _null_frame;
79 };
80
81 #include "pStatThreadData.I"
82
83 #endif
PStatClientData
The data associated with a particular client, but not with any one particular frame or thread: the li...
Definition: pStatClientData.h:36
PStatCollectorDef
Defines the details about the Collectors: the name, the suggested color, etc.
Definition: pStatCollectorDef.h:29
PStatFrameData
Contains the raw timing and level data for a single frame.
Definition: pStatFrameData.h:33
PStatThreadData
A collection of FrameData structures for recently-received frames within a particular thread.
Definition: pStatThreadData.h:34
PStatThreadData::set_history
void set_history(double time)
Sets the number of seconds worth of frames that will be retained by the ThreadData structure as each ...
Definition: pStatThreadData.cxx:237
PStatThreadData::get_elapsed_frames
bool get_elapsed_frames(int &then_i, int &now_i) const
Computes the oldest frame number not older than pstats_average_time seconds, and the newest frame num...
Definition: pStatThreadData.cxx:203
PStatThreadData::get_frame_number_at_time
int get_frame_number_at_time(double time, int hint=-1) const
Returns the frame number of the latest frame not later than the indicated time.
Definition: pStatThreadData.cxx:154
PStatThreadData::is_empty
bool is_empty() const
Returns true if the structure contains no frames, false otherwise.
Definition: pStatThreadData.cxx:47
PStatThreadData::get_history
double get_history() const
Returns the number of seconds worth of frames that will be retained by the ThreadData structure as ea...
Definition: pStatThreadData.cxx:247
PStatThreadData::get_frame_rate
double get_frame_rate() const
Computes the average frame rate over the past pstats_average_time seconds, by counting up the number ...
Definition: pStatThreadData.cxx:218
PStatThreadData::get_frame_at_time
const PStatFrameData & get_frame_at_time(double time) const
Returns the FrameData structure associated with the latest frame not later than the indicated time.
Definition: pStatThreadData.cxx:142
PStatThreadData::get_latest_frame
const PStatFrameData & get_latest_frame() const
Returns the FrameData associated with the most recent frame.
Definition: pStatThreadData.cxx:191
PStatThreadData::get_client_data
const PStatClientData * get_client_data() const
Returns a pointer to the ClientData structure associated with this data.
Definition: pStatThreadData.I:18
PStatThreadData::has_frame
bool has_frame(int frame_number) const
Returns true if we have received data for the indicated frame number from the client and we still hav...
Definition: pStatThreadData.cxx:74
PStatThreadData::get_frame
const PStatFrameData & get_frame(int frame_number) const
Returns a FrameData structure associated with the indicated frame number.
Definition: pStatThreadData.cxx:87
PStatThreadData::get_latest_frame_number
int get_latest_frame_number() const
Returns the frame number of the most recent frame stored in the data.
Definition: pStatThreadData.cxx:55
PStatThreadData::get_oldest_frame_number
int get_oldest_frame_number() const
Returns the frame number of the oldest frame still stored in the data.
Definition: pStatThreadData.cxx:64
PStatThreadData::get_latest_time
double get_latest_time() const
Returns the timestamp (in seconds elapsed since connection) of the latest available frame.
Definition: pStatThreadData.cxx:122
PStatThreadData::record_new_frame
void record_new_frame(int frame_number, PStatFrameData *frame_data)
Makes room for and stores a new frame's worth of data.
Definition: pStatThreadData.cxx:261
PStatThreadData::get_oldest_time
double get_oldest_time() const
Returns the timestamp (in seconds elapsed since connection) of the oldest available frame.
Definition: pStatThreadData.cxx:132
ReferenceCount
A base class for all things that want to be reference-counted.
Definition: referenceCount.h:38
pdeque< PStatFrameData * >
pStatThreadData.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pdeque.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.