Panda3D
|
00001 // Filename: pStatMonitor.h 00002 // Created by: drose (08Jul00) 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 PSTATMONITOR_H 00016 #define PSTATMONITOR_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "pStatClientData.h" 00021 #include "pStatView.h" 00022 00023 #include "referenceCount.h" 00024 #include "pointerTo.h" 00025 #include "luse.h" 00026 00027 #include "pmap.h" 00028 00029 class PStatCollectorDef; 00030 class PStatServer; 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : PStatMonitor 00034 // Description : This is an abstract class that presents the interface 00035 // to any number of different front-ends for the stats 00036 // monitor. One of these will be created by the 00037 // PStatMonitor as each client is connected; this class 00038 // is responsible for opening up a new strip-chart graph 00039 // or whatever is appropriate. It defines a number of 00040 // empty virtual functions that will be called as new 00041 // data becomes available. 00042 //////////////////////////////////////////////////////////////////// 00043 class PStatMonitor : public ReferenceCount { 00044 public: 00045 // The following functions are primarily for use by internal classes 00046 // to set up the monitor. 00047 PStatMonitor(PStatServer *server); 00048 virtual ~PStatMonitor(); 00049 00050 void hello_from(const string &hostname, const string &progname); 00051 void bad_version(const string &hostname, const string &progname, 00052 int client_major, int client_minor, 00053 int server_major, int server_minor); 00054 void set_client_data(PStatClientData *client_data); 00055 00056 00057 // The following functions are for use by user code to determine 00058 // information about the client data available. 00059 bool is_alive() const; 00060 void close(); 00061 00062 INLINE PStatServer *get_server(); 00063 INLINE const PStatClientData *get_client_data() const; 00064 INLINE string get_collector_name(int collector_index); 00065 const LRGBColor &get_collector_color(int collector_index); 00066 00067 INLINE bool is_client_known() const; 00068 INLINE string get_client_hostname() const; 00069 INLINE string get_client_progname() const; 00070 00071 PStatView &get_view(int thread_index); 00072 PStatView &get_level_view(int collector_index, int thread_index); 00073 00074 00075 // The following virtual methods may be overridden by a derived 00076 // monitor class to customize behavior. 00077 00078 virtual string get_monitor_name()=0; 00079 00080 virtual void initialized(); 00081 virtual void got_hello(); 00082 virtual void got_bad_version(int client_major, int client_minor, 00083 int server_major, int server_minor); 00084 virtual void new_collector(int collector_index); 00085 virtual void new_thread(int thread_index); 00086 virtual void new_data(int thread_index, int frame_number); 00087 00088 virtual void lost_connection(); 00089 virtual void idle(); 00090 virtual bool has_idle(); 00091 00092 virtual bool is_thread_safe(); 00093 00094 virtual void user_guide_bars_changed(); 00095 00096 protected: 00097 PStatServer *_server; 00098 00099 private: 00100 PT(PStatClientData) _client_data; 00101 00102 bool _client_known; 00103 string _client_hostname; 00104 string _client_progname; 00105 00106 typedef pmap<int, PStatView> Views; 00107 Views _views; 00108 typedef pmap<int, Views> LevelViews; 00109 LevelViews _level_views; 00110 00111 typedef pmap<int, LRGBColor> Colors; 00112 Colors _colors; 00113 }; 00114 00115 #include "pStatMonitor.I" 00116 00117 #endif