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