Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/pstatserver/pStatViewLevel.cxx

Go to the documentation of this file.
00001 // Filename: pStatViewLevel.cxx
00002 // Created by:  drose (11Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "pStatViewLevel.h"
00020 #include "pStatClientData.h"
00021 
00022 #include <pStatCollectorDef.h>
00023 #include <notify.h>
00024 
00025 #include <algorithm>
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: PStatViewLevel::get_net_value
00029 //       Access: Public
00030 //  Description: Returns the total level value (or elapsed time)
00031 //               represented by this Collector, including all values
00032 //               in its child Collectors.
00033 ////////////////////////////////////////////////////////////////////
00034 float PStatViewLevel::
00035 get_net_value() const {
00036   float net = _value_alone;
00037 
00038   Children::const_iterator ci;
00039   for (ci = _children.begin(); ci != _children.end(); ++ci) {
00040     net += (*ci)->get_net_value();
00041   }
00042 
00043   return net;
00044 }
00045 
00046 
00047 // STL function object for sorting children in order by the
00048 // collector's sort index, used in sort_children(), below.
00049 class SortCollectorLevels {
00050 public:
00051   SortCollectorLevels(const PStatClientData *client_data) :
00052     _client_data(client_data) {
00053   }
00054   bool operator () (const PStatViewLevel *a, const PStatViewLevel *b) const {
00055     return
00056       _client_data->get_collector_def(a->get_collector())._sort >
00057       _client_data->get_collector_def(b->get_collector())._sort;
00058   }
00059   const PStatClientData *_client_data;
00060 };
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: PStatViewLevel::sort_children
00064 //       Access: Public
00065 //  Description: Sorts the children of this view level into order as
00066 //               specified by the client's sort index.
00067 ////////////////////////////////////////////////////////////////////
00068 void PStatViewLevel::
00069 sort_children(const PStatClientData *client_data) {
00070   SortCollectorLevels sort_levels(client_data);
00071 
00072   sort(_children.begin(), _children.end(), sort_levels);
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: PStatViewLevel::get_num_children
00077 //       Access: Public
00078 //  Description: Returns the number of children of this
00079 //               Level/Collector.  These are the Collectors whose
00080 //               value is considered to be part of the total value of
00081 //               this level's Collector.
00082 ////////////////////////////////////////////////////////////////////
00083 int PStatViewLevel::
00084 get_num_children() const {
00085   return _children.size();
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: PStatViewLevel::get_child
00090 //       Access: Public
00091 //  Description: Returns the nth child of this Level/Collector.
00092 ////////////////////////////////////////////////////////////////////
00093 const PStatViewLevel *PStatViewLevel::
00094 get_child(int n) const {
00095   nassertr(n >= 0 && n < (int)_children.size(), NULL);
00096   return _children[n];
00097 }

Generated on Fri May 2 03:21:44 2003 for Panda-Tool by doxygen1.3