00001 // Filename: pStatClientData.h 00002 // Created by: drose (11Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PSTATCLIENTDATA_H 00016 #define PSTATCLIENTDATA_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "pStatThreadData.h" 00021 00022 #include "pStatClientVersion.h" 00023 #include "referenceCount.h" 00024 #include "pointerTo.h" 00025 #include "bitArray.h" 00026 00027 #include "pvector.h" 00028 #include "vector_int.h" 00029 00030 class PStatReader; 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : PStatClientData 00034 // Description : The data associated with a particular client, but not 00035 // with any one particular frame or thread: the list of 00036 // collectors and threads, for instance. 00037 //////////////////////////////////////////////////////////////////// 00038 class PStatClientData : public PStatClientVersion { 00039 public: 00040 PStatClientData(PStatReader *reader); 00041 ~PStatClientData(); 00042 00043 bool is_alive() const; 00044 void close(); 00045 00046 int get_num_collectors() const; 00047 bool has_collector(int index) const; 00048 const PStatCollectorDef &get_collector_def(int index) const; 00049 string get_collector_name(int index) const; 00050 string get_collector_fullname(int index) const; 00051 bool set_collector_has_level(int index, int thread_index, bool flag); 00052 bool get_collector_has_level(int index, int thread_index) const; 00053 00054 int get_num_toplevel_collectors() const; 00055 int get_toplevel_collector(int index) const; 00056 00057 int get_num_threads() const; 00058 bool has_thread(int index) const; 00059 string get_thread_name(int index) const; 00060 const PStatThreadData *get_thread_data(int index) const; 00061 00062 int get_child_distance(int parent, int child) const; 00063 00064 00065 void add_collector(PStatCollectorDef *def); 00066 void define_thread(int thread_index, const string &name = string()); 00067 00068 void record_new_frame(int thread_index, int frame_number, 00069 PStatFrameData *frame_data); 00070 private: 00071 void slot_collector(int collector_index); 00072 void update_toplevel_collectors(); 00073 00074 private: 00075 bool _is_alive; 00076 PStatReader *_reader; 00077 00078 class Collector { 00079 public: 00080 PStatCollectorDef *_def; 00081 BitArray _is_level; 00082 }; 00083 00084 typedef pvector<Collector> Collectors; 00085 Collectors _collectors; 00086 00087 typedef vector_int ToplevelCollectors; 00088 ToplevelCollectors _toplevel_collectors; 00089 00090 class Thread { 00091 public: 00092 string _name; 00093 PT(PStatThreadData) _data; 00094 }; 00095 typedef pvector<Thread> Threads; 00096 Threads _threads; 00097 00098 static PStatCollectorDef _null_collector; 00099 friend class PStatReader; 00100 }; 00101 00102 #endif 00103