Panda3D
pStatViewLevel.cxx
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 pStatViewLevel.cxx
10  * @author drose
11  * @date 2000-07-11
12  */
13 
14 #include "pStatViewLevel.h"
15 #include "pStatClientData.h"
16 
17 #include "pStatCollectorDef.h"
18 #include "pnotify.h"
19 
20 #include <algorithm>
21 
22 /**
23  * Returns the total level value (or elapsed time) represented by this
24  * Collector, including all values in its child Collectors.
25  */
26 double PStatViewLevel::
27 get_net_value() const {
28  double net = _value_alone;
29 
30  Children::const_iterator ci;
31  for (ci = _children.begin(); ci != _children.end(); ++ci) {
32  net += (*ci)->get_net_value();
33  }
34 
35  return net;
36 }
37 
38 
39 // STL function object for sorting children in order by the collector's sort
40 // index, used in sort_children(), below.
41 class SortCollectorLevels {
42 public:
43  SortCollectorLevels(const PStatClientData *client_data) :
44  _client_data(client_data) {
45  }
46  bool operator () (const PStatViewLevel *a, const PStatViewLevel *b) const {
47  return
48  _client_data->get_collector_def(a->get_collector())._sort >
49  _client_data->get_collector_def(b->get_collector())._sort;
50  }
51  const PStatClientData *_client_data;
52 };
53 
54 /**
55  * Sorts the children of this view level into order as specified by the
56  * client's sort index.
57  */
59 sort_children(const PStatClientData *client_data) {
60  SortCollectorLevels sort_levels(client_data);
61 
62  sort(_children.begin(), _children.end(), sort_levels);
63 }
64 
65 /**
66  * Returns the number of children of this Level/Collector. These are the
67  * Collectors whose value is considered to be part of the total value of this
68  * level's Collector.
69  */
72  return _children.size();
73 }
74 
75 /**
76  * Returns the nth child of this Level/Collector.
77  */
79 get_child(int n) const {
80  nassertr(n >= 0 && n < (int)_children.size(), nullptr);
81  return _children[n];
82 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void sort_children(const PStatClientData *client_data)
Sorts the children of this view level into order as specified by the client's sort index.
const PStatViewLevel * get_child(int n) const
Returns the nth child of this Level/Collector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The data associated with a particular client, but not with any one particular frame or thread: the li...
This is a single level value, or band of color, within a View.
double get_net_value() const
Returns the total level value (or elapsed time) represented by this Collector, including all values i...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_collector() const
Returns the Collector index associated with this level.
int get_num_children() const
Returns the number of children of this Level/Collector.