00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PSTATCOLLECTOR_H
00016 #define PSTATCOLLECTOR_H
00017
00018 #include "pandabase.h"
00019
00020 #include "pStatThread.h"
00021 #include "pStatClient.h"
00022
00023 class Thread;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 class EXPCL_PANDA_PSTATCLIENT PStatCollector {
00050 #ifdef DO_PSTATS
00051
00052 private:
00053 INLINE PStatCollector(PStatClient *client, int index);
00054
00055 public:
00056 INLINE PStatCollector();
00057
00058 PUBLISHED:
00059 INLINE PStatCollector(const string &name,
00060 PStatClient *client = NULL);
00061 INLINE PStatCollector(const PStatCollector &parent,
00062 const string &name);
00063
00064 INLINE PStatCollector(const PStatCollector ©);
00065 INLINE void operator = (const PStatCollector ©);
00066
00067 INLINE bool is_valid() const;
00068 INLINE string get_name() const;
00069 INLINE string get_fullname() const;
00070 INLINE void output(ostream &out) const;
00071
00072 INLINE bool is_active();
00073 INLINE bool is_started();
00074 INLINE void start();
00075 INLINE void stop();
00076
00077 INLINE void clear_level();
00078 INLINE void set_level(double level);
00079 INLINE void add_level(double increment);
00080 INLINE void sub_level(double decrement);
00081 INLINE void add_level_now(double increment);
00082 INLINE void sub_level_now(double decrement);
00083 INLINE void flush_level();
00084 INLINE double get_level();
00085
00086 INLINE void clear_thread_level();
00087 INLINE void set_thread_level(double level);
00088 INLINE void add_thread_level(double increment);
00089 INLINE void sub_thread_level(double decrement);
00090 INLINE double get_thread_level();
00091
00092 INLINE bool is_active(const PStatThread &thread);
00093 INLINE bool is_started(const PStatThread &thread);
00094 INLINE void start(const PStatThread &thread);
00095 INLINE void start(const PStatThread &thread, double as_of);
00096 INLINE void stop(const PStatThread &thread);
00097 INLINE void stop(const PStatThread &thread, double as_of);
00098
00099 INLINE void clear_level(const PStatThread &thread);
00100 INLINE void set_level(const PStatThread &thread, double level);
00101 INLINE void add_level(const PStatThread &thread, double increment);
00102 INLINE void sub_level(const PStatThread &thread, double decrement);
00103 INLINE double get_level(const PStatThread &thread);
00104
00105 INLINE int get_index() const;
00106
00107 private:
00108 PStatClient *_client;
00109 int _index;
00110 double _level;
00111
00112 friend class PStatClient;
00113
00114 #else // DO_PSTATS
00115 public:
00116 INLINE PStatCollector();
00117
00118 PUBLISHED:
00119 INLINE PStatCollector(const string &name,
00120 PStatClient *client = NULL);
00121 INLINE PStatCollector(const PStatCollector &parent,
00122 const string &name);
00123
00124 INLINE bool is_active() { return false; }
00125 INLINE bool is_started() { return false; }
00126 INLINE void start() { }
00127 INLINE void stop() { }
00128
00129 INLINE void clear_level() { }
00130 INLINE void set_level(double) { }
00131 INLINE void add_level(double) { }
00132 INLINE void sub_level(double) { }
00133 INLINE void add_level_now(double) { }
00134 INLINE void sub_level_now(double) { }
00135 INLINE void flush_level() { }
00136 INLINE double get_level() { return 0.0; }
00137
00138 INLINE bool is_active(const PStatThread &) { return false; }
00139 INLINE void start(const PStatThread &) { }
00140 INLINE void start(const PStatThread &, double) { }
00141 INLINE void stop(const PStatThread &) { }
00142 INLINE void stop(const PStatThread &, double) { }
00143
00144 INLINE void clear_level(const PStatThread &) { }
00145 INLINE void set_level(const PStatThread &, double) { }
00146 INLINE void add_level(const PStatThread &, double) { }
00147 INLINE void sub_level(const PStatThread &, double) { }
00148 INLINE double get_level(const PStatThread &) { return 0.0; }
00149
00150 INLINE int get_index() const { return 0; }
00151
00152 #endif // DO_PSTATS
00153 };
00154
00155 #include "pStatCollector.I"
00156
00157 inline ostream &operator << (ostream &out, const PStatCollector &pcol) {
00158 #ifdef DO_PSTATS
00159 pcol.output(out);
00160 #endif // DO_PSTATS
00161 return out;
00162 }
00163
00164 #endif
00165