Panda3D
Public Member Functions | List of all members
PStatMonitor Class Referenceabstract

This is an abstract class that presents the interface to any number of different front-ends for the stats monitor. More...

#include "pStatMonitor.h"

Inheritance diagram for PStatMonitor:
ReferenceCount MemoryBase TextMonitor WinStatsMonitor

Public Member Functions

 PStatMonitor (PStatServer *server)
 
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. More...
 
void close ()
 Closes the client connection if it is active. More...
 
const PStatClientDataget_client_data () const
 Returns the client data associated with this monitor. More...
 
std::string get_client_hostname () const
 Returns the hostname of the client we're connected to, if known. More...
 
std::string get_client_progname () const
 Returns the program name of the client we're connected to, if known. More...
 
const LRGBColor & get_collector_color (int collector_index)
 Returns the color associated with the indicated collector. More...
 
std::string get_collector_name (int collector_index)
 Returns the name of the indicated collector, if it is known. More...
 
PStatViewget_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 thread. More...
 
virtual std::string get_monitor_name ()=0
 
PStatServerget_server ()
 Returns the server that owns this monitor. More...
 
PStatViewget_view (int thread_index)
 Returns a view on the given thread index. More...
 
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. More...
 
virtual void got_hello ()
 Called when the "hello" message has been received from the client. More...
 
virtual bool has_idle ()
 Should be redefined to return true if you want to redefine idle() and expect it to be called. More...
 
void hello_from (const std::string &hostname, const std::string &progname)
 Called shortly after startup time with the greeting from the client. More...
 
virtual void idle ()
 If has_idle() returns true, this will be called periodically to allow the monitor to update its display or whatever it needs to do. More...
 
virtual void initialized ()
 Called after the monitor has been fully set up. More...
 
bool is_alive () const
 Returns true if the client is alive and connected, false otherwise. More...
 
bool is_client_known () const
 Returns true if we've yet received the "hello" message from the client indicating its name, etc. More...
 
virtual bool is_thread_safe ()
 Should be redefined to return true if this monitor class can handle running in a sub-thread. More...
 
virtual void lost_connection ()
 Called whenever the connection to the client has been lost. More...
 
virtual void new_collector (int collector_index)
 Called whenever a new Collector definition is received from the client. More...
 
virtual void new_data (int thread_index, int frame_number)
 Called as each frame's data is made available. More...
 
virtual void new_thread (int thread_index)
 Called whenever a new Thread definition is received from the client. More...
 
void set_client_data (PStatClientData *client_data)
 Called by the PStatServer at setup time to set the new data pointer for the first time. More...
 
virtual void user_guide_bars_changed ()
 Called when the user guide bars have been changed. More...
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Detailed Description

This is an abstract class that presents the interface to any number of different front-ends for the stats monitor.

One of these will be created by the PStatMonitor as each client is connected; this class is responsible for opening up a new strip-chart graph or whatever is appropriate. It defines a number of empty virtual functions that will be called as new data becomes available.

Definition at line 39 of file pStatMonitor.h.

Member Function Documentation

◆ bad_version()

void PStatMonitor::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.

In this case, the client seems to have an incompatible version and will be automatically disconnected; the server should issue a message to that effect.

Definition at line 55 of file pStatMonitor.cxx.

References got_bad_version().

◆ close()

void PStatMonitor::close ( )

Closes the client connection if it is active.

Definition at line 91 of file pStatMonitor.cxx.

◆ get_client_data()

const PStatClientData * PStatMonitor::get_client_data ( ) const
inline

Returns the client data associated with this monitor.

Definition at line 26 of file pStatMonitor.I.

Referenced by WinStatsChartMenu::add_to_menu_bar(), WinStatsStripChart::clicked_label(), WinStatsMonitor::idle(), TextMonitor::new_data(), and PStatStripChart::update().

◆ get_client_hostname()

std::string PStatMonitor::get_client_hostname ( ) const
inline

Returns the hostname of the client we're connected to, if known.

This may not be known immediately at creation time, but should be learned shortly thereafter when we receive the client's "hello" message. See is_client_known().

Definition at line 58 of file pStatMonitor.I.

Referenced by WinStatsMonitor::got_bad_version().

◆ get_client_progname()

std::string PStatMonitor::get_client_progname ( ) const
inline

Returns the program name of the client we're connected to, if known.

This may not be known immediately at creation time, but should be learned shortly thereafter when we receive the client's "hello" message. See is_client_known().

Definition at line 69 of file pStatMonitor.I.

Referenced by WinStatsMonitor::got_bad_version().

◆ get_collector_color()

const LRGBColor & PStatMonitor::get_collector_color ( int  collector_index)

Returns the color associated with the indicated collector.

If the collector has no associated color, or is unknown, a new color will be made up on the spot and associated with this collector for the rest of the session.

Definition at line 104 of file pStatMonitor.cxx.

◆ get_collector_name()

std::string PStatMonitor::get_collector_name ( int  collector_index)
inline

Returns the name of the indicated collector, if it is known.

Definition at line 34 of file pStatMonitor.I.

◆ get_level_view()

PStatView & PStatMonitor::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 thread.

If there is no such view already for the indicated thread, this will create one.

Definition at line 168 of file pStatMonitor.cxx.

◆ get_server()

PStatServer * PStatMonitor::get_server ( )
inline

Returns the server that owns this monitor.

Definition at line 18 of file pStatMonitor.I.

Referenced by TextMonitor::get_server().

◆ get_view()

PStatView & PStatMonitor::get_view ( int  thread_index)

Returns a view on the given thread index.

If there is no such view already for the indicated thread, this will create one. This view can be used to examine the accumulated data for the given thread.

Definition at line 152 of file pStatMonitor.cxx.

Referenced by WinStatsChartMenu::check_update(), WinStatsChartMenu::do_update(), and TextMonitor::new_data().

◆ got_bad_version()

void PStatMonitor::got_bad_version ( int  client_major,
int  client_minor,
int  server_major,
int  server_minor 
)
virtual

Like got_hello(), this is called when the "hello" message has been received from the client.

At this time, the client's hostname and program name will be known. However, the client appears to be an incompatible version and the connection will be terminated; the monitor should issue a message to that effect.

Reimplemented in WinStatsMonitor, and TextMonitor.

Definition at line 213 of file pStatMonitor.cxx.

Referenced by bad_version().

◆ got_hello()

void PStatMonitor::got_hello ( )
virtual

Called when the "hello" message has been received from the client.

At this time, the client's hostname and program name will be known.

Reimplemented in WinStatsMonitor, and TextMonitor.

Definition at line 202 of file pStatMonitor.cxx.

Referenced by hello_from().

◆ has_idle()

bool PStatMonitor::has_idle ( )
virtual

Should be redefined to return true if you want to redefine idle() and expect it to be called.

Reimplemented in WinStatsMonitor.

Definition at line 271 of file pStatMonitor.cxx.

◆ hello_from()

void PStatMonitor::hello_from ( const std::string &  hostname,
const std::string &  progname 
)

Called shortly after startup time with the greeting from the client.

This indicates the client's reported hostname and program name.

Definition at line 41 of file pStatMonitor.cxx.

References got_hello().

◆ idle()

void PStatMonitor::idle ( )
virtual

If has_idle() returns true, this will be called periodically to allow the monitor to update its display or whatever it needs to do.

Reimplemented in WinStatsMonitor.

Definition at line 263 of file pStatMonitor.cxx.

◆ initialized()

void PStatMonitor::initialized ( )
virtual

Called after the monitor has been fully set up.

At this time, it will have a valid _client_data pointer, and things like is_alive() and close() will be meaningful. However, we may not yet know who we're connected to (is_client_known() may return false), and we may not know anything about the threads or collectors we're about to get data on.

Reimplemented in WinStatsMonitor.

Definition at line 194 of file pStatMonitor.cxx.

Referenced by set_client_data().

◆ is_alive()

bool PStatMonitor::is_alive ( ) const

Returns true if the client is alive and connected, false otherwise.

Definition at line 79 of file pStatMonitor.cxx.

◆ is_client_known()

bool PStatMonitor::is_client_known ( ) const
inline

Returns true if we've yet received the "hello" message from the client indicating its name, etc.

Definition at line 47 of file pStatMonitor.I.

◆ is_thread_safe()

bool PStatMonitor::is_thread_safe ( )
virtual

Should be redefined to return true if this monitor class can handle running in a sub-thread.

This is not related to the question of whether it can handle multiple different PStatThreadDatas; this is strictly a question of whether or not the monitor itself wants to run in a sub-thread.

Reimplemented in TextMonitor.

Definition at line 284 of file pStatMonitor.cxx.

◆ lost_connection()

void PStatMonitor::lost_connection ( )
virtual

Called whenever the connection to the client has been lost.

This is a permanent state change. The monitor should update its display to represent this, and may choose to close down automatically.

Reimplemented in WinStatsMonitor, and TextMonitor.

Definition at line 255 of file pStatMonitor.cxx.

◆ new_collector()

void PStatMonitor::new_collector ( int  collector_index)
virtual

Called whenever a new Collector definition is received from the client.

Generally, the client will send all of its collectors over shortly after connecting, but there's no guarantee that they will all be received before the first frames are received. The monitor should be prepared to accept new Collector definitions midstream.

Reimplemented in WinStatsMonitor.

Definition at line 224 of file pStatMonitor.cxx.

◆ new_data()

void PStatMonitor::new_data ( int  thread_index,
int  frame_number 
)
virtual

Called as each frame's data is made available.

There is no guarantee the frames will arrive in order, or that all of them will arrive at all. The monitor should be prepared to accept frames received out-of-order or missing. The use of the PStatFrameData / PStatView objects to report the data will facilitate this.

Reimplemented in WinStatsMonitor, and TextMonitor.

Definition at line 246 of file pStatMonitor.cxx.

◆ new_thread()

void PStatMonitor::new_thread ( int  thread_index)
virtual

Called whenever a new Thread definition is received from the client.

Generally, the client will send all of its threads over shortly after connecting, but there's no guarantee that they will all be received before the first frames are received. The monitor should be prepared to accept new Thread definitions midstream.

Reimplemented in WinStatsMonitor.

Definition at line 235 of file pStatMonitor.cxx.

◆ set_client_data()

void PStatMonitor::set_client_data ( PStatClientData client_data)

Called by the PStatServer at setup time to set the new data pointer for the first time.

Definition at line 70 of file pStatMonitor.cxx.

References initialized().

◆ user_guide_bars_changed()

void PStatMonitor::user_guide_bars_changed ( )
virtual

Called when the user guide bars have been changed.

Reimplemented in WinStatsMonitor.

Definition at line 292 of file pStatMonitor.cxx.


The documentation for this class was generated from the following files: