Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

GtkStatsMonitor Class Reference

This class represents a connection to a PStatsClient and manages the data exchange with the client. More...

#include "gtkStatsMonitor.h"

Inheritance diagram for GtkStatsMonitor:
PStatMonitor ReferenceCount MemoryBase

List of all members.

Classes

class  MenuDef

Public Member Functions

 GtkStatsMonitor (GtkStatsServer *server)
const MenuDefadd_menu (const MenuDef &menu_def)
 Adds a new MenuDef to the monitor, or returns an existing one if there is already one just like it.
void bad_version (const string &hostname, const 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 close ()
 Closes the client connection if it is active.
const PStatClientDataget_client_data () const
 Returns the client data associated with this monitor.
string get_client_hostname () const
 Returns the hostname of the client we're connected to, if known.
string get_client_progname () const
 Returns the program name of the client we're connected to, if known.
const RGBColorfget_collector_color (int collector_index)
 Returns the color associated with the indicated collector.
string get_collector_name (int collector_index)
 Returns the name of the indicated collector, if it is known.
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.
virtual string get_monitor_name ()
 Should be redefined to return a descriptive name for the type of PStatsMonitor this is.
int get_ref_count () const
 Returns the current reference count.
PStatServerget_server ()
 Returns the server that owns this monitor.
PStatViewget_view (int thread_index)
 Returns a view on the given thread index.
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object.
GtkWidget * get_window () const
 Returns the window handle to the monitor's window.
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.
virtual void got_hello ()
 Called when the "hello" message has been received from the client.
virtual bool has_idle ()
 Should be redefined to return true if you want to redefine idle() and expect it to be called.
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
void hello_from (const string &hostname, const string &progname)
 Called shortly after startup time with the greeting from the client.
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.
virtual void initialized ()
 Called after the monitor has been fully set up.
bool is_alive () const
 Returns true if the client is alive and connected, false otherwise.
bool is_client_known () const
 Returns true if we've yet received the "hello" message from the client indicating its name, etc.
virtual bool is_thread_safe ()
 Should be redefined to return true if this monitor class can handle running in a sub-thread.
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
virtual void lost_connection ()
 Called whenever the connection to the client has been lost.
virtual void new_collector (int collector_index)
 Called whenever a new Collector definition is received from the client.
virtual void new_data (int thread_index, int frame_number)
 Called as each frame's data is made available.
virtual void new_thread (int thread_index)
 Called whenever a new Thread definition is received from the client.
void open_piano_roll (int thread_index)
 Opens a new piano roll showing the indicated data.
void open_strip_chart (int thread_index, int collector_index, bool show_level)
 Opens a new strip chart showing the indicated data.
void operator delete (void *ptr, void *)
void operator delete (void *ptr)
void operator delete[] (void *, void *)
void operator delete[] (void *ptr)
void * operator new (size_t size, void *ptr)
void * operator new (size_t size)
void * operator new[] (size_t size)
void * operator new[] (size_t size, void *ptr)
void ref () const
 Explicitly increments the reference count.
void set_client_data (PStatClientData *client_data)
 Called by the PStatServer at setup time to set the new data pointer for the first time.
void set_pause (bool pause)
 Called when the user selects a pause on or pause off option from the menu.
void set_scroll_speed (float scroll_speed)
 Called when the user selects a new scroll speed from the monitor pulldown menu, this should adjust the speeds for all graphs to the indicated value.
void set_time_units (int unit_mask)
 Called when the user selects a new time units from the monitor pulldown menu, this should adjust the units for all graphs to the indicated mask if it is a time-based graph.
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
virtual bool unref () const
 Explicitly decrements the reference count.
virtual void user_guide_bars_changed ()
 Called when the user guide bars have been changed.
void weak_ref (WeakPointerToVoid *ptv)
 Adds the indicated PointerToVoid as a weak reference to this object.
void weak_unref (WeakPointerToVoid *ptv)
 Removes the indicated PointerToVoid as a weak reference to this object.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Member Functions

bool do_test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.
bool do_test_ref_count_nonzero () const
 Returns true if the reference count is nonzero, false otherwise.

Protected Attributes

PStatServer_server

Friends

class GtkStatsGraph

Detailed Description

This class represents a connection to a PStatsClient and manages the data exchange with the client.

Definition at line 37 of file gtkStatsMonitor.h.


Member Function Documentation

const GtkStatsMonitor::MenuDef * GtkStatsMonitor::add_menu ( const MenuDef menu_def)

Adds a new MenuDef to the monitor, or returns an existing one if there is already one just like it.

Definition at line 328 of file gtkStatsMonitor.cxx.

Referenced by GtkStatsChartMenu::do_update().

void PStatMonitor::bad_version ( const string &  hostname,
const string &  progname,
int  client_major,
int  client_minor,
int  server_major,
int  server_minor 
) [inherited]

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 64 of file pStatMonitor.cxx.

References PStatMonitor::got_bad_version().

void PStatMonitor::close ( ) [inherited]

Closes the client connection if it is active.

Definition at line 107 of file pStatMonitor.cxx.

bool ReferenceCount::do_test_ref_count_integrity ( ) const [protected, inherited]

Does some easy checks to make sure that the reference count isn't completely bogus.

Returns true if ok, false otherwise.

Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.

Definition at line 29 of file referenceCount.cxx.

Referenced by ReferenceCount::do_test_ref_count_nonzero(), and ReferenceCount::test_ref_count_integrity().

bool ReferenceCount::do_test_ref_count_nonzero ( ) const [protected, inherited]

Returns true if the reference count is nonzero, false otherwise.

Definition at line 56 of file referenceCount.cxx.

References ReferenceCount::do_test_ref_count_integrity().

Referenced by ReferenceCount::test_ref_count_nonzero().

const PStatClientData * PStatMonitor::get_client_data ( ) const [inline, inherited]
string PStatMonitor::get_client_hostname ( ) const [inline, inherited]

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 72 of file pStatMonitor.I.

Referenced by WinStatsMonitor::got_bad_version(), TextMonitor::got_bad_version(), got_bad_version(), TextMonitor::got_hello(), WinStatsMonitor::lost_connection(), and lost_connection().

string PStatMonitor::get_client_progname ( ) const [inline, inherited]

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 86 of file pStatMonitor.I.

Referenced by WinStatsMonitor::got_bad_version(), TextMonitor::got_bad_version(), got_bad_version(), and TextMonitor::got_hello().

const RGBColorf & PStatMonitor::get_collector_color ( int  collector_index) [inherited]

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 123 of file pStatMonitor.cxx.

References LVecBase3f::zero().

Referenced by WinStatsGraph::get_collector_brush(), and GtkStatsGraph::get_collector_gc().

string PStatMonitor::get_collector_name ( int  collector_index) [inline, inherited]

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

Definition at line 43 of file pStatMonitor.I.

PStatView & PStatMonitor::get_level_view ( int  collector_index,
int  thread_index 
) [inherited]

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 193 of file pStatMonitor.cxx.

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

string GtkStatsMonitor::get_monitor_name ( ) [virtual]

Should be redefined to return a descriptive name for the type of PStatsMonitor this is.

Implements PStatMonitor.

Definition at line 78 of file gtkStatsMonitor.cxx.

int ReferenceCount::get_ref_count ( ) const [inline, inherited]
PStatServer * PStatMonitor::get_server ( ) [inline, inherited]

Returns the server that owns this monitor.

Reimplemented in TextMonitor.

Definition at line 22 of file pStatMonitor.I.

PStatView & PStatMonitor::get_view ( int  thread_index) [inherited]

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 174 of file pStatMonitor.cxx.

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

WeakReferenceList * ReferenceCount::get_weak_list ( ) const [inline, inherited]

Returns the WeakReferenceList associated with this ReferenceCount object.

If there has never been a WeakReferenceList associated with this object, creates one now.

Definition at line 307 of file referenceCount.I.

Referenced by ReferenceCount::weak_ref().

GtkWidget * GtkStatsMonitor::get_window ( ) const

Returns the window handle to the monitor's window.

Definition at line 286 of file gtkStatsMonitor.cxx.

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

Definition at line 122 of file gtkStatsMonitor.cxx.

References PStatMonitor::get_client_hostname(), and PStatMonitor::get_client_progname().

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

Definition at line 105 of file gtkStatsMonitor.cxx.

References open_strip_chart().

bool GtkStatsMonitor::has_idle ( ) [virtual]

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

Reimplemented from PStatMonitor.

Definition at line 262 of file gtkStatsMonitor.cxx.

bool ReferenceCount::has_weak_list ( ) const [inline, inherited]

Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.

In general, this will be true if there was ever a WeakPointerTo created for this object (even if there is not any for it now).

Definition at line 294 of file referenceCount.I.

Referenced by ReferenceCount::weak_unref().

void PStatMonitor::hello_from ( const string &  hostname,
const string &  progname 
) [inherited]

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

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

Definition at line 47 of file pStatMonitor.cxx.

References PStatMonitor::got_hello().

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

Definition at line 237 of file gtkStatsMonitor.cxx.

References PStatMonitor::get_client_data(), PStatThreadData::get_frame_rate(), and PStatClientData::get_thread_data().

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

Definition at line 94 of file gtkStatsMonitor.cxx.

bool PStatMonitor::is_alive ( ) const [inherited]

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

Definition at line 93 of file pStatMonitor.cxx.

bool PStatMonitor::is_client_known ( ) const [inline, inherited]

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

Definition at line 58 of file pStatMonitor.I.

bool PStatMonitor::is_thread_safe ( ) [virtual, inherited]

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 343 of file pStatMonitor.cxx.

void ReferenceCount::local_object ( ) [inline, inherited]

This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.

This allows the object to be passed to functions that will increment and decrement the object's reference count temporarily, and it will prevent the object from being deleted (inappropriately), when the reference count returns to zero. It actually achieves this by setting a large positive value in the reference count field.

Definition at line 276 of file referenceCount.I.

Referenced by PGTop::cull_callback(), BoundingSphere::extend_by_hexahedron(), AsyncTaskManager::find_task(), AsyncTaskManager::find_tasks(), and AsyncTaskManager::find_tasks_matching().

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

Definition at line 223 of file gtkStatsMonitor.cxx.

References PStatMonitor::get_client_hostname().

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

Definition at line 161 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::new_collector().

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

Reimplemented from PStatMonitor.

Definition at line 205 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::new_data().

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

Definition at line 187 of file gtkStatsMonitor.cxx.

References GtkStatsChartMenu::add_to_menu_bar().

void GtkStatsMonitor::open_piano_roll ( int  thread_index)

Opens a new piano roll showing the indicated data.

Definition at line 312 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::set_pause(), GtkStatsGraph::set_scroll_speed(), and GtkStatsPianoRoll::set_time_units().

void GtkStatsMonitor::open_strip_chart ( int  thread_index,
int  collector_index,
bool  show_level 
)

Opens a new strip chart showing the indicated data.

Definition at line 296 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::set_pause(), GtkStatsStripChart::set_scroll_speed(), and GtkStatsStripChart::set_time_units().

Referenced by GtkStatsPianoRoll::clicked_label(), and got_hello().

void ReferenceCount::ref ( ) const [inline, inherited]

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

Definition at line 179 of file referenceCount.I.

References ReferenceCount::test_ref_count_integrity().

Referenced by CachedTypedWritableReferenceCount::cache_ref(), TypedWritable::decode_raw_from_bam_stream(), NodeCachedReferenceCount::node_ref(), NodeReferenceCount::node_ref(), BamCacheRecord::set_data(), CullableObject::set_draw_callback(), and ModelRoot::set_reference().

void PStatMonitor::set_client_data ( PStatClientData client_data) [inherited]

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

Definition at line 81 of file pStatMonitor.cxx.

References PStatMonitor::initialized().

void GtkStatsMonitor::set_pause ( bool  pause)

Called when the user selects a pause on or pause off option from the menu.

Definition at line 385 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::set_pause().

void GtkStatsMonitor::set_scroll_speed ( float  scroll_speed)

Called when the user selects a new scroll speed from the monitor pulldown menu, this should adjust the speeds for all graphs to the indicated value.

Definition at line 367 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::set_scroll_speed().

void GtkStatsMonitor::set_time_units ( int  unit_mask)

Called when the user selects a new time units from the monitor pulldown menu, this should adjust the units for all graphs to the indicated mask if it is a time-based graph.

Definition at line 348 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::set_time_units().

bool ReferenceCount::test_ref_count_integrity ( ) const [inline, inherited]
bool ReferenceCount::test_ref_count_nonzero ( ) const [inline, inherited]

Does some easy checks to make sure that the reference count isn't zero, or completely bogus.

Returns true if ok, false otherwise.

Definition at line 252 of file referenceCount.I.

References ReferenceCount::do_test_ref_count_nonzero().

Referenced by CopyOnWritePointer::test_ref_count_nonzero().

bool ReferenceCount::unref ( ) const [inline, virtual, inherited]

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is true if the new reference count is nonzero, false if it is zero.

Reimplemented in GeomVertexArrayFormat, GeomVertexFormat, InternalName, RenderAttrib, RenderEffects, RenderState, and TransformState.

Definition at line 214 of file referenceCount.I.

References ReferenceCount::test_ref_count_integrity().

Referenced by CachedTypedWritableReferenceCount::cache_unref(), TypedWritable::decode_raw_from_bam_stream(), RenderEffect::finalize(), NodeCachedReferenceCount::node_unref(), NodeReferenceCount::node_unref(), TransformState::unref(), RenderState::unref(), RenderEffects::unref(), RenderAttrib::unref(), InternalName::unref(), GeomVertexFormat::unref(), and GeomVertexArrayFormat::unref().

void GtkStatsMonitor::user_guide_bars_changed ( ) [virtual]

Called when the user guide bars have been changed.

Reimplemented from PStatMonitor.

Definition at line 272 of file gtkStatsMonitor.cxx.

References GtkStatsGraph::user_guide_bars_changed().

void ReferenceCount::weak_ref ( WeakPointerToVoid ptv) [inline, inherited]

Adds the indicated PointerToVoid as a weak reference to this object.

Definition at line 321 of file referenceCount.I.

References WeakReferenceList::add_reference(), and ReferenceCount::get_weak_list().

void ReferenceCount::weak_unref ( WeakPointerToVoid ptv) [inline, inherited]

Removes the indicated PointerToVoid as a weak reference to this object.

It must have previously been added via a call to weak_ref().

Definition at line 334 of file referenceCount.I.

References WeakReferenceList::clear_reference(), and ReferenceCount::has_weak_list().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations