Panda3D

Loading...
Searching...
No Matches
pStatMonitor.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pStatMonitor.h
10 * @author drose
11 * @date 2000-07-08
12 */
13
14#ifndef PSTATMONITOR_H
15#define PSTATMONITOR_H
16
17#include "pandatoolbase.h"
18
19#include "pStatClientData.h"
20#include "pStatView.h"
21
22#include "referenceCount.h"
23#include "pointerTo.h"
24#include "luse.h"
25
26#include "pmap.h"
27
28 class PStatCollectorDef;
29 class PStatServer;
30
31/**
32 * This is an abstract class that presents the interface to any number of
33 * different front-ends for the stats monitor. One of these will be created
34 * by the PStatMonitor as each client is connected; this class is responsible
35 * for opening up a new strip-chart graph or whatever is appropriate. It
36 * defines a number of empty virtual functions that will be called as new data
37 * becomes available.
38 */
39 class PStatMonitor : public ReferenceCount {
40 public:
41 // The following functions are primarily for use by internal classes to set
42 // up the monitor.
43 PStatMonitor(PStatServer *server);
44 virtual ~PStatMonitor();
45
46 void hello_from(const std::string &hostname, const std::string &progname);
47 void bad_version(const std::string &hostname, const std::string &progname,
48 int client_major, int client_minor,
49 int server_major, int server_minor);
50 void set_client_data(PStatClientData *client_data);
51
52
53 // The following functions are for use by user code to determine information
54 // about the client data available.
55 bool is_alive() const;
56 void close();
57
58 INLINE PStatServer *get_server();
59 INLINE const PStatClientData *get_client_data() const;
60 INLINE std::string get_collector_name(int collector_index);
61 const LRGBColor &get_collector_color(int collector_index);
62
63 INLINE bool is_client_known() const;
64 INLINE std::string get_client_hostname() const;
65 INLINE std::string get_client_progname() const;
66
67 PStatView &get_view(int thread_index);
68 PStatView &get_level_view(int collector_index, int thread_index);
69
70
71 // The following virtual methods may be overridden by a derived monitor
72 // class to customize behavior.
73
74 virtual std::string get_monitor_name()=0;
75
76 virtual void initialized();
77 virtual void got_hello();
78 virtual void got_bad_version(int client_major, int client_minor,
79 int server_major, int server_minor);
80 virtual void new_collector(int collector_index);
81 virtual void new_thread(int thread_index);
82 virtual void new_data(int thread_index, int frame_number);
83
84 virtual void lost_connection();
85 virtual void idle();
86 virtual bool has_idle();
87
88 virtual bool is_thread_safe();
89
90 virtual void user_guide_bars_changed();
91
92 protected:
93 PStatServer *_server;
94
95 private:
96 PT(PStatClientData) _client_data;
97
98 bool _client_known;
99 std::string _client_hostname;
100 std::string _client_progname;
101
102 typedef pmap<int, PStatView> Views;
103 Views _views;
104 typedef pmap<int, Views> LevelViews;
105 LevelViews _level_views;
106
107 typedef pmap<int, LRGBColor> Colors;
108 Colors _colors;
109};
110
111#include "pStatMonitor.I"
112
113#endif
PStatClientData
The data associated with a particular client, but not with any one particular frame or thread: the li...
Definition pStatClientData.h:36
PStatCollectorDef
Defines the details about the Collectors: the name, the suggested color, etc.
Definition pStatCollectorDef.h:29
PStatMonitor::lost_connection
virtual void lost_connection()
Called whenever the connection to the client has been lost.
Definition pStatMonitor.cxx:255
PStatMonitor::got_hello
virtual void got_hello()
Called when the "hello" message has been received from the client.
Definition pStatMonitor.cxx:202
PStatMonitor::get_client_progname
std::string get_client_progname() const
Returns the program name of the client we're connected to, if known.
Definition pStatMonitor.I:69
PStatMonitor::is_client_known
bool is_client_known() const
Returns true if we've yet received the "hello" message from the client indicating its name,...
Definition pStatMonitor.I:47
PStatMonitor::idle
virtual void idle()
If has_idle() returns true, this will be called periodically to allow the monitor to update its displ...
Definition pStatMonitor.cxx:263
PStatMonitor::get_level_view
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...
Definition pStatMonitor.cxx:168
PStatMonitor::get_client_hostname
std::string get_client_hostname() const
Returns the hostname of the client we're connected to, if known.
Definition pStatMonitor.I:58
PStatMonitor::set_client_data
void set_client_data(PStatClientData *client_data)
Called by the PStatServer at setup time to set the new data pointer for the first time.
Definition pStatMonitor.cxx:70
PStatMonitor::new_data
virtual void new_data(int thread_index, int frame_number)
Called as each frame's data is made available.
Definition pStatMonitor.cxx:246
PStatMonitor::initialized
virtual void initialized()
Called after the monitor has been fully set up.
Definition pStatMonitor.cxx:194
PStatMonitor::get_collector_name
std::string get_collector_name(int collector_index)
Returns the name of the indicated collector, if it is known.
Definition pStatMonitor.I:34
PStatMonitor::user_guide_bars_changed
virtual void user_guide_bars_changed()
Called when the user guide bars have been changed.
Definition pStatMonitor.cxx:292
PStatMonitor::has_idle
virtual bool has_idle()
Should be redefined to return true if you want to redefine idle() and expect it to be called.
Definition pStatMonitor.cxx:271
PStatMonitor::close
void close()
Closes the client connection if it is active.
Definition pStatMonitor.cxx:91
PStatMonitor::new_collector
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
Definition pStatMonitor.cxx:224
PStatMonitor::got_bad_version
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.
Definition pStatMonitor.cxx:213
PStatMonitor::hello_from
void hello_from(const std::string &hostname, const std::string &progname)
Called shortly after startup time with the greeting from the client.
Definition pStatMonitor.cxx:41
PStatMonitor::is_alive
bool is_alive() const
Returns true if the client is alive and connected, false otherwise.
Definition pStatMonitor.cxx:79
PStatMonitor::bad_version
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.
Definition pStatMonitor.cxx:55
PStatMonitor::new_thread
virtual void new_thread(int thread_index)
Called whenever a new Thread definition is received from the client.
Definition pStatMonitor.cxx:235
PStatMonitor::get_client_data
const PStatClientData * get_client_data() const
Returns the client data associated with this monitor.
Definition pStatMonitor.I:26
PStatMonitor::is_thread_safe
virtual bool is_thread_safe()
Should be redefined to return true if this monitor class can handle running in a sub-thread.
Definition pStatMonitor.cxx:284
PStatMonitor::get_view
PStatView & get_view(int thread_index)
Returns a view on the given thread index.
Definition pStatMonitor.cxx:152
PStatMonitor::get_server
PStatServer * get_server()
Returns the server that owns this monitor.
Definition pStatMonitor.I:18
PStatMonitor::get_collector_color
const LRGBColor & get_collector_color(int collector_index)
Returns the color associated with the indicated collector.
Definition pStatMonitor.cxx:104
PStatServer
The overall manager of the network connections.
Definition pStatServer.h:36
PStatView
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
Definition pStatView.h:31
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatClientData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatMonitor.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatView.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.