25 PStatMonitor(
PStatServer *server) : _server(server) {
26 _client_known =
false;
41 hello_from(
const string &hostname,
const string &progname) {
43 _client_hostname = hostname;
44 _client_progname = progname;
56 int client_major,
int client_minor,
57 int server_major,
int server_minor) {
59 _client_hostname = hostname;
60 _client_progname = progname;
62 server_major, server_minor);
71 _client_data = client_data;
80 if (_client_data.is_null()) {
84 return _client_data->is_alive();
92 if (!_client_data.is_null()) {
93 _client_data->close();
106 ci = _colors.find(collector_index);
107 if (ci != _colors.end()) {
112 if (!_client_data.is_null() &&
113 _client_data->has_collector(collector_index)) {
115 _client_data->get_collector_def(collector_index);
117 LRGBColor sc(def._suggested_color.r,
118 def._suggested_color.g,
119 def._suggested_color.b);
120 if (sc != LRGBColor::zero()) {
121 ci = _colors.insert(Colors::value_type(collector_index, sc)).first;
128 string fullname = _client_data->get_collector_fullname(collector_index);
129 unsigned int hash = 0;
130 for (string::const_iterator ci = fullname.begin(); ci != fullname.end(); ++ci) {
131 hash = hash * 37 + (
unsigned int)(*ci);
137 LRGBColor random_color;
138 random_color[0] = (double)rand() / (double)RAND_MAX;
139 random_color[1] = (double)rand() / (double)RAND_MAX;
140 random_color[2] = (double)rand() / (double)RAND_MAX;
142 ci = _colors.insert(Colors::value_type(collector_index, random_color)).first;
154 vi = _views.find(thread_index);
155 if (vi == _views.end()) {
156 vi = _views.insert(Views::value_type(thread_index,
PStatView())).first;
157 (*vi).second.set_thread_data(_client_data->get_thread_data(thread_index));
169 LevelViews::iterator lvi;
170 lvi = _level_views.find(collector_index);
171 if (lvi == _level_views.end()) {
172 lvi = _level_views.insert(LevelViews::value_type(collector_index,
Views())).first;
174 Views &views = (*lvi).second;
177 vi = views.find(thread_index);
178 if (vi == views.end()) {
179 vi = views.insert(Views::value_type(thread_index,
PStatView())).first;
180 (*vi).second.set_thread_data(_client_data->get_thread_data(thread_index));
181 (*vi).second.constrain(collector_index,
true);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void bad_version(const std::string &hostname, const std::string &progname, int client_major, int client_minor, int server_major, int server_minor)
Called shortly after startup time with the greeting from the client.
void set_client_data(PStatClientData *client_data)
Called by the PStatServer at setup time to set the new data pointer for the first time.
virtual void initialized()
Called after the monitor has been fully set up.
virtual bool has_idle()
Should be redefined to return true if you want to redefine idle() and expect it to be called.
virtual void new_data(int thread_index, int frame_number)
Called as each frame's data is made available.
const LRGBColor & get_collector_color(int collector_index)
Returns the color associated with the indicated collector.
PStatView & get_level_view(int collector_index, int thread_index)
Returns a view on the level value (as opposed to elapsed time) for the given collector over the given...
virtual void got_bad_version(int client_major, int client_minor, int server_major, int server_minor)
Like got_hello(), this is called when the "hello" message has been received from the client.
The data associated with a particular client, but not with any one particular frame or thread: the li...
void close()
Closes the client connection if it is active.
virtual bool is_thread_safe()
Should be redefined to return true if this monitor class can handle running in a sub-thread.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_alive() const
Returns true if the client is alive and connected, false otherwise.
virtual void got_hello()
Called when the "hello" message has been received from the client.
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
PStatView & get_view(int thread_index)
Returns a view on the given thread index.
virtual void lost_connection()
Called whenever the connection to the client has been lost.
virtual void new_thread(int thread_index)
Called whenever a new Thread definition is received from the client.
virtual void idle()
If has_idle() returns true, this will be called periodically to allow the monitor to update its displ...
virtual void user_guide_bars_changed()
Called when the user guide bars have been changed.
The overall manager of the network connections.
void hello_from(const std::string &hostname, const std::string &progname)
Called shortly after startup time with the greeting from the client.
Defines the details about the Collectors: the name, the suggested color, etc.
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.