Panda3D
pStatView.h
1 // Filename: pStatView.h
2 // Created by: drose (10Jul00)
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 PSTATVIEW_H
16 #define PSTATVIEW_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "pStatClientData.h"
21 #include "pStatThreadData.h"
22 #include "pStatViewLevel.h"
23 #include "pmap.h"
24 #include "pointerTo.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : PStatView
28 // Description : A View boils down the frame data to a linear list of
29 // times spent in a number of different Collectors,
30 // within a particular thread. This automatically
31 // accounts for overlapping start/stop times and nested
32 // Collectors in a sensible way.
33 ////////////////////////////////////////////////////////////////////
34 class PStatView {
35 public:
36  PStatView();
37  ~PStatView();
38 
39  void constrain(int collector, bool show_level);
40  void unconstrain();
41 
42  void set_thread_data(const PStatThreadData *thread_data);
43  INLINE const PStatThreadData *get_thread_data();
44  INLINE const PStatClientData *get_client_data();
45 
46  void set_to_frame(const PStatFrameData &frame_data);
47  INLINE void set_to_frame(int frame_number);
48  INLINE void set_to_time(double time);
49 
50  bool all_collectors_known() const;
51  double get_net_value() const;
52 
54 
55  bool has_level(int collector) const;
56  PStatViewLevel *get_level(int collector);
57 
58  INLINE bool get_show_level() const;
59  INLINE int get_level_index() const;
60 
61 private:
62  void update_time_data(const PStatFrameData &frame_data);
63  void update_level_data(const PStatFrameData &frame_data);
64 
65  void clear_levels();
66  bool reset_level(PStatViewLevel *level);
67 
68  int _constraint;
69  bool _show_level;
70  bool _all_collectors_known;
71 
73  Levels _levels;
74 
75  int _level_index;
76 
77  CPT(PStatClientData) _client_data;
78  CPT(PStatThreadData) _thread_data;
79 };
80 
81 #include "pStatView.I"
82 
83 #endif
84 
const PStatViewLevel * get_top_level()
Returns a pointer to the level that corresponds to the Collector we've constrained to...
Definition: pStatView.cxx:270
void set_to_frame(const PStatFrameData &frame_data)
Supplies the View with the data for the current frame.
Definition: pStatView.cxx:216
The data associated with a particular client, but not with any one particular frame or thread: the li...
void unconstrain()
Restores the view to the full frame.
Definition: pStatView.cxx:183
double get_net_value() const
Returns the total value accounted for by the frame (or by whatever Collector we are constrained to)...
Definition: pStatView.cxx:250
void set_to_time(double time)
Sets to the frame that occurred at the indicated time (or the nearest available frame), extracted from the View's PStatThreadData pointer.
Definition: pStatView.I:64
const PStatClientData * get_client_data()
Returns the current PStatClientData associated with the view.
Definition: pStatView.I:37
This is a single level value, or band of color, within a View.
Contains the raw timing and level data for a single frame.
A View boils down the frame data to a linear list of times spent in a number of different Collectors...
Definition: pStatView.h:34
bool all_collectors_known() const
After a call to set_to_frame(), this returns true if all collectors in the FrameData are known by the...
Definition: pStatView.cxx:237
A collection of FrameData structures for recently-received frames within a particular thread...
const PStatThreadData * get_thread_data()
Returns the current PStatThreadData associated with the view.
Definition: pStatView.I:25
void constrain(int collector, bool show_level)
Changes the focus of the View.
Definition: pStatView.cxx:170
int get_level_index() const
Returns an index number that can be used to determine when the set of known levels has changed...
Definition: pStatView.I:89
bool get_show_level() const
Returns true if we are showing level data, false if time data.
Definition: pStatView.I:75
bool has_level(int collector) const
Returns true if there is a level defined for the particular collector, false otherwise.
Definition: pStatView.cxx:281
PStatViewLevel * get_level(int collector)
Returns a pointer to the level that corresponds to the indicated Collector.
Definition: pStatView.cxx:297