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

panda/src/pstatclient/pStatCollector.h

Go to the documentation of this file.
00001 // Filename: pStatCollector.h
00002 // Created by:  drose (10Jul00)
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 #ifndef PSTATCOLLECTOR_H
00020 #define PSTATCOLLECTOR_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "pStatThread.h"
00025 #include "pStatClient.h"
00026 
00027 #include <luse.h>
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : PStatCollector
00031 // Description : A lightweight class that represents a single element
00032 //               that may be timed and/or counted via stats.
00033 //
00034 //               Collectors can be used to measure two different kinds
00035 //               of values: elapsed time, and "other".
00036 //
00037 //               To measure elapsed time, call start() and stop() as
00038 //               appropriate to bracket the section of code you want
00039 //               to time (or use a PStatTimer to do this
00040 //               automatically).
00041 //
00042 //               To measure anything else, call set_level() and/or
00043 //               add_level() to set the "level" value associated with
00044 //               this collector.  The meaning of the value set for the
00045 //               "level" is entirely up to the user; it may represent
00046 //               the number of triangles rendered or the kilobytes of
00047 //               texture memory consumed, for instance.  The level set
00048 //               will remain fixed across multiple frames until it is
00049 //               reset via another set_level() or adjusted via a call
00050 //               to add_level().  It may also be completely removed
00051 //               via clear_level().
00052 ////////////////////////////////////////////////////////////////////
00053 class EXPCL_PANDA PStatCollector {
00054 #ifdef DO_PSTATS
00055 
00056 private:
00057   INLINE PStatCollector();
00058   INLINE PStatCollector(PStatClient *client, int index);
00059 
00060 PUBLISHED:
00061   INLINE PStatCollector(const string &name,
00062                         PStatClient *client = NULL);
00063   INLINE PStatCollector(const PStatCollector &parent,
00064                         const string &name);
00065 
00066   INLINE PStatCollector(const PStatCollector &copy);
00067   INLINE void operator = (const PStatCollector &copy);
00068 
00069   INLINE bool is_active();
00070   INLINE void start();
00071   INLINE void stop();
00072 
00073   INLINE void clear_level();
00074   INLINE void set_level(float level);
00075   INLINE void add_level(float increment);
00076   INLINE void sub_level(float decrement);
00077   INLINE float get_level();
00078 
00079 public:
00080   INLINE bool is_active(const PStatThread &thread);
00081   INLINE void start(const PStatThread &thread);
00082   INLINE void start(const PStatThread &thread, float as_of);
00083   INLINE void stop(const PStatThread &thread);
00084   INLINE void stop(const PStatThread &thread, float as_of);
00085 
00086   INLINE void clear_level(const PStatThread &thread);
00087   INLINE void set_level(const PStatThread &thread, float level);
00088   INLINE void add_level(const PStatThread &thread, float increment);
00089   INLINE void sub_level(const PStatThread &thread, float decrement);
00090   INLINE float get_level(const PStatThread &thread);
00091 
00092 private:
00093   PStatClient *_client;
00094   int _index;
00095 
00096 friend class PStatClient;
00097 
00098 #else  // DO_PSTATS
00099 PUBLISHED:
00100   INLINE PStatCollector(const string &name,
00101                         PStatClient *client = NULL);
00102   INLINE PStatCollector(const PStatCollector &parent,
00103                         const string &name);
00104 
00105   INLINE bool is_active() { return false; }
00106   INLINE void start() { }
00107   INLINE void stop() { }
00108 
00109   INLINE void clear_level() { }
00110   INLINE void set_level(float) { }
00111   INLINE void add_level(float) { }
00112   INLINE void sub_level(float) { }
00113   INLINE float get_level() { return 0.0; }
00114 
00115 public:
00116   INLINE bool is_active(const PStatThread &) { return false; }
00117   INLINE void start(const PStatThread &) { }
00118   INLINE void start(const PStatThread &, float) { }
00119   INLINE void stop(const PStatThread &) { }
00120   INLINE void stop(const PStatThread &, float) { }
00121 
00122   INLINE void clear_level(const PStatThread &) { }
00123   INLINE void set_level(const PStatThread &, float) { }
00124   INLINE void add_level(const PStatThread &, float) { }
00125   INLINE void sub_level(const PStatThread &, float) { }
00126   INLINE float get_level(const PStatThread &) { return 0.0; }
00127 
00128 #endif  // DO_PSTATS
00129 };
00130 
00131 #include "pStatCollector.I"
00132 
00133 #endif
00134 

Generated on Fri May 2 00:43:27 2003 for Panda by doxygen1.3