Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes

TextStats Class Reference

A simple, scrolling-text stats server. More...

#include "textStats.h"

Inheritance diagram for TextStats:
ProgramBase PStatServer ConnectionManager

List of all members.

Public Types

typedef pdeque< string > Args

Public Member Functions

void add_reader (Connection *connection, PStatReader *reader)
 Adds the newly-created PStatReader to the list of currently active readers.
int add_user_guide_bar (float height)
 Creates a new user guide bar and returns its index number.
bool close_connection (const PT(Connection)&connection)
 Terminates a UDP or TCP socket previously opened.
int find_user_guide_bar (float from_height, float to_height) const
 Returns the index number of the first user guide bar found whose height is within the indicated range, or -1 if no user guide bars fall within the range.
string get_exec_command () const
 Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into the comments of output files.
int get_num_user_guide_bars () const
 Returns the current number of user-defined guide bars.
int get_udp_port ()
 Returns a new port number that will probably be free to use as a UDP port.
float get_user_guide_bar_height (int n) const
 Returns the height of the nth user-defined guide bar.
virtual bool is_thread_safe ()
 This should be redefined to return true in derived classes that want to deal with multithreaded readers and such.
bool listen (int port=-1)
 Establishes a port number that the manager will listen on for TCP connections.
void main_loop (bool *interrupt_flag=NULL)
 An alternative to repeatedly calling poll(), this function yields control of the program to the PStatServer.
virtual PStatMonitormake_monitor ()
void move_user_guide_bar (int n, float height)
 Adjusts the height of the nth user-defined guide bar.
virtual void parse_command_line (int argc, char *argv[])
 Dispatches on each of the options on the command line, and passes the remaining parameters to handle_args().
void poll ()
 Checks for any network activity and handles it, if appropriate, and then returns.
 PT (Connection) open_TCP_server_rendezvous(const string &hostname
 PT (Connection) open_UDP_connection(int port=0)
void release_udp_port (int port)
 Indicates that the given UDP port is once again free for use.
void remove_reader (Connection *connection, PStatReader *reader)
 Removes the indicated reader.
void remove_user_guide_bar (int n)
 Removes the user guide bar with the indicated index number.
void run ()
void show_description ()
 Writes the program description to stderr.
void show_options ()
 Describes each of the available options to stderr.
void show_text (const string &prefix, int indent_width, string text)
 Formats the indicated text and its prefix for output to stderr with the known _terminal_width.
void show_text (const string &text)
 Formats the indicated text to stderr with the known _terminal_width.
void show_usage ()
 Writes the usage line(s) to stderr.

Static Public Member Functions

static string get_host_name ()
 Returns the name of this particular machine on the network, if available, or the empty string if the hostname cannot be determined.

Public Attributes

Args _program_args
Filename _program_name
int int backlog
int backlog
int port
int timeout_ms
int int timeout_ms

Protected Types

typedef phash_set< PT(Connection) > Connections
typedef bool(* OptionDispatchFunction )(const string &opt, const string &parm, void *data)
typedef bool(* OptionDispatchMethod )(ProgramBase *self, const string &opt, const string &parm, void *data)
typedef phash_set
< ConnectionWriter
*, pointer_hash
Writers

Protected Member Functions

void add_option (const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchFunction option_function, bool *bool_var=(bool *) NULL, void *option_data=(void *) NULL)
 Adds (or redefines) a command line option.
void add_option (const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchMethod option_method, bool *bool_var=(bool *) NULL, void *option_data=(void *) NULL)
void add_path_replace_options ()
 Adds -pr etc.
void add_path_store_options ()
 Adds -ps etc.
void add_reader (ConnectionReader *reader)
 This internal function is called by ConnectionReader when it is constructed.
void add_runline (const string &runline)
 Adds an additional line to the list of lines that will be displayed to describe briefly how the program is to be run.
void add_writer (ConnectionWriter *writer)
 This internal function is called by ConnectionWriter when it is constructed.
void clear_options ()
 Removes all of the options that were previously added, presumably before adding some new ones.
void clear_runlines ()
 Removes all of the runlines that were previously added, presumably before adding some new ones.
virtual void connection_reset (const PT(Connection)&connection, bool okflag)
 Called when a lost connection is detected by the net code, this should pass the word on to the interested parties and clean up gracefully.
virtual void flush_read_connection (Connection *connection)
 An internal function called by ConnectionWriter only when a write failure has occurred.
virtual bool handle_args (Args &args)
 Does something with the additional arguments on the command line (after all the -options have been parsed).
void new_connection (const PT(Connection)&connection)
 This internal function is called whenever a new connection is established.
virtual bool post_command_line ()
 This is called after the command line has been completely processed, and it gives the program a chance to do some last-minute processing and validation of the options and arguments.
 PT (PathReplace) _path_replace
bool redescribe_option (const string &option, const string &description)
 Changes the description associated with a previously-defined option.
bool remove_option (const string &option)
 Removes a previously-defined option.
void remove_reader (ConnectionReader *reader)
 This internal function is called by ConnectionReader when it is destructed.
void remove_writer (ConnectionWriter *writer)
 This internal function is called by ConnectionWriter when it is destructed.
void set_program_description (const string &description)
 Sets the description of the program that will be reported by show_usage().

Static Protected Member Functions

static bool dispatch_color (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a color, as l or l,a or r,g,b or r,g,b,a.
static bool dispatch_coordinate_system (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a coordinate system string.
static bool dispatch_count (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes no parameters, but whose presence on the command line increments an integer counter for each time it appears.
static bool dispatch_double (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a double.
static bool dispatch_double_pair (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a pair of double parameters.
static bool dispatch_double_quad (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a quad of double parameters.
static bool dispatch_double_triple (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a triple of double parameters.
static bool dispatch_false (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'false' value.
static bool dispatch_filename (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a filename.
static bool dispatch_image_type (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to indicate an image file type, like rgb, bmp, jpg, etc.
static bool dispatch_int (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as an integer.
static bool dispatch_int_pair (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a pair of integer parameters.
static bool dispatch_none (const string &opt, const string &arg, void *)
 Standard dispatch function for an option that takes no parameters, and does nothing special.
static bool dispatch_path_replace (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single component of a path replace request.
static bool dispatch_path_store (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a path store string.
static bool dispatch_search_path (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single directory name to add to a search path.
static bool dispatch_string (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a string.
static bool dispatch_true (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'true' value.
static bool dispatch_units (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a unit of distance measurement.
static bool dispatch_vector_string (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a string.
static bool dispatch_vector_string_comma (const string &opt, const string &arg, void *var)
 Similar to dispatch_vector_string, but a comma is allowed to separate multiple tokens in one argument, without having to repeat the argument for each token.
static void format_text (ostream &out, bool &last_newline, const string &prefix, int indent_width, const string &text, int line_width)
 Word-wraps the indicated text to the indicated output stream.
static bool handle_help_option (const string &opt, const string &arg, void *)
 Called when the user enters '-h', this describes how to use the program and then exits.

Protected Attributes

Connections _connections
bool _got_path_directory
bool _got_path_store
LightMutex _set_mutex
Writers _writers

Detailed Description

A simple, scrolling-text stats server.

Guaranteed to compile on every platform.

Definition at line 31 of file textStats.h.


Member Function Documentation

void ProgramBase::add_option ( const string &  option,
const string &  parm_name,
int  index_group,
const string &  description,
OptionDispatchFunction  option_function,
bool *  bool_var = (bool *)NULL,
void *  option_data = (void *)NULL 
) [protected, inherited]

Adds (or redefines) a command line option.

This is another variant on add_option(), above, except that it receives a pointer to a "method", which is really just another static (or global) function, whose first parameter is a ProgramBase *.

When parse_command_line() is executed it will look for these options (followed by a hyphen) on the command line; when a particular option is found it will call the indicated option_function, supplying the provided option_data. This allows the user to define a function that does some special behavior for any given option, or to use any of a number of generic pre-defined functions to fill in data for each option.

Each option may or may not take a parameter. If parm_name is nonempty, it is assumed that the option does take a parameter (and parm_name contains the name that will be printed by show_options()). This parameter will be supplied as the second parameter to the dispatch function. If parm_name is empty, it is assumed that the option does not take a parameter. There is no provision for optional parameters.

The options are listed first in order by their index_group number, and then in the order that add_option() was called. This provides a mechanism for listing the options defined in derived classes before those of the base classes.

We can't easily add a variant that accepts a real method, because the C++ syntax for methods requires us to know exactly what class object the method is defined for, and we want to support adding pointers for methods that are defined in other classes. So we have this hacky thing, which requires the "method" to be declared static, and receive its this pointer explicitly, as the first argument.

Definition at line 535 of file programBase.cxx.

Referenced by SomethingToEgg::add_animation_options(), EggReader::add_delod_options(), SomethingToEgg::add_merge_externals_options(), EggBase::add_normals_options(), ProgramBase::add_path_replace_options(), ProgramBase::add_path_store_options(), EggReader::add_texture_options(), EggBase::add_transform_options(), SomethingToEgg::add_units_options(), EggToSomething::add_units_options(), EggWriter::EggWriter(), ImageWriter::ImageWriter(), and SomethingToEgg::SomethingToEgg().

void ProgramBase::add_path_replace_options ( ) [protected, inherited]

Adds -pr etc.

as valid options for this program. These are appropriate for a model converter or model reader type program, and specify how to locate possibly-invalid pathnames in the source model file.

Definition at line 642 of file programBase.cxx.

References ProgramBase::add_option(), ProgramBase::dispatch_path_replace(), and ProgramBase::dispatch_search_path().

void ProgramBase::add_path_store_options ( ) [protected, inherited]

Adds -ps etc.

as valid options for this program. These are appropriate for a model converter type program, and specify how to represent filenames in the output file.

Definition at line 683 of file programBase.cxx.

References ProgramBase::add_option(), ProgramBase::dispatch_filename(), and ProgramBase::dispatch_path_store().

void PStatServer::add_reader ( Connection connection,
PStatReader reader 
) [inherited]

Adds the newly-created PStatReader to the list of currently active readers.

Definition at line 156 of file pStatServer.cxx.

Referenced by PStatListener::connection_opened().

void ConnectionManager::add_reader ( ConnectionReader reader) [protected, inherited]

This internal function is called by ConnectionReader when it is constructed.

Definition at line 437 of file connectionManager.cxx.

Referenced by ConnectionReader::ConnectionReader().

void ProgramBase::add_runline ( const string &  runline) [protected, inherited]

Adds an additional line to the list of lines that will be displayed to describe briefly how the program is to be run.

Each line should be something like "[opts] arg1 arg2", that is, it does *not* include the name of the program, but it includes everything that should be printed after the name of the program.

Normally there is only one runline for a given program, but it is possible to define more than one.

Definition at line 487 of file programBase.cxx.

Referenced by EggToSomething::EggToSomething(), EggWriter::EggWriter(), ImageWriter::ImageWriter(), and SomethingToEgg::SomethingToEgg().

int PStatServer::add_user_guide_bar ( float  height) [inherited]

Creates a new user guide bar and returns its index number.

Definition at line 247 of file pStatServer.cxx.

void ConnectionManager::add_writer ( ConnectionWriter writer) [protected, inherited]

This internal function is called by ConnectionWriter when it is constructed.

Definition at line 461 of file connectionManager.cxx.

Referenced by ConnectionWriter::ConnectionWriter().

void ProgramBase::clear_options ( ) [protected, inherited]

Removes all of the options that were previously added, presumably before adding some new ones.

Normally you wouldn't want to do this unless you want to completely replace all of the options defined by base classes.

Definition at line 501 of file programBase.cxx.

void ProgramBase::clear_runlines ( ) [protected, inherited]

Removes all of the runlines that were previously added, presumably before adding some new ones.

Definition at line 469 of file programBase.cxx.

Referenced by EggToSomething::EggToSomething(), EggWriter::EggWriter(), ImageWriter::ImageWriter(), and SomethingToEgg::SomethingToEgg().

bool ConnectionManager::close_connection ( const PT(Connection)&  connection) [inherited]

Terminates a UDP or TCP socket previously opened.

This also removes it from any associated ConnectionReader or ConnectionListeners.

The socket itself may not be immediately closed--it will not be closed until all outstanding pointers to it are cleared, including any pointers remaining in NetDatagrams recently received from the socket.

The return value is true if the connection was marked to be closed, or false if close_connection() had already been called (or the connection did not belong to this ConnectionManager). In neither case can you infer anything about whether the connection has actually* been closed yet based on the return value.

Definition at line 300 of file connectionManager.cxx.

References Socket_IP::Close(), Connection::flush(), and Connection::get_socket().

Referenced by PStatServer::connection_reset(), ConnectionManager::connection_reset(), PStatReader::lost_connection(), and MayaToEggServer::poll().

void PStatServer::connection_reset ( const PT(Connection)&  connection,
bool  okflag 
) [protected, virtual, inherited]

Called when a lost connection is detected by the net code, this should pass the word on to the interested parties and clean up gracefully.

Reimplemented from ConnectionManager.

Definition at line 332 of file pStatServer.cxx.

References ConnectionManager::close_connection().

bool ProgramBase::dispatch_color ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes a color, as l or l,a or r,g,b or r,g,b,a.

The data pointer is to an array of four floats, e.g. a Colorf.

Definition at line 953 of file programBase.cxx.

bool ProgramBase::dispatch_coordinate_system ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a coordinate system string.

The data pointer is to a CoordinateSystem variable.

Definition at line 1114 of file programBase.cxx.

bool ProgramBase::dispatch_count ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes no parameters, but whose presence on the command line increments an integer counter for each time it appears.

-v is often an option that works this way. The data pointer is to an int counter variable.

Definition at line 775 of file programBase.cxx.

bool ProgramBase::dispatch_double ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a double.

The data pointer is to an double variable.

Definition at line 840 of file programBase.cxx.

Referenced by SomethingToEgg::add_animation_options(), and EggReader::add_delod_options().

bool ProgramBase::dispatch_double_pair ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes a pair of double parameters.

The data pointer is to an array of two doubles.

Definition at line 860 of file programBase.cxx.

bool ProgramBase::dispatch_double_quad ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes a quad of double parameters.

The data pointer is to an array of four doubles.

Definition at line 921 of file programBase.cxx.

bool ProgramBase::dispatch_double_triple ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes a triple of double parameters.

The data pointer is to an array of three doubles.

Definition at line 890 of file programBase.cxx.

bool ProgramBase::dispatch_false ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'false' value.

This is another way to handle a boolean flag. See also dispatch_none() and dispatch_true().

The data pointer is to a bool variable.

Definition at line 759 of file programBase.cxx.

bool ProgramBase::dispatch_filename ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a filename.

The data pointer is to a Filename variable.

Definition at line 1070 of file programBase.cxx.

References Filename::from_os_specific().

Referenced by ProgramBase::add_path_store_options(), EggReader::add_texture_options(), EggWriter::EggWriter(), and ImageWriter::ImageWriter().

bool ProgramBase::dispatch_image_type ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to indicate an image file type, like rgb, bmp, jpg, etc.

The data pointer is to a PNMFileType pointer.

Definition at line 1159 of file programBase.cxx.

References PNMFileTypeRegistry::get_global_ptr(), PNMFileTypeRegistry::get_type_from_extension(), and PNMFileTypeRegistry::write().

Referenced by EggReader::add_texture_options().

bool ProgramBase::dispatch_int ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as an integer.

The data pointer is to an int variable.

Definition at line 790 of file programBase.cxx.

bool ProgramBase::dispatch_int_pair ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes a pair of integer parameters.

The data pointer is to an array of two integers.

Definition at line 810 of file programBase.cxx.

bool ProgramBase::dispatch_none ( const string &  opt,
const string &  arg,
void *   
) [static, protected, inherited]

Standard dispatch function for an option that takes no parameters, and does nothing special.

Typically this would be used for a boolean flag, whose presence means something and whose absence means something else. Use the bool_var parameter to add_option() to determine whether the option appears on the command line or not.

Definition at line 725 of file programBase.cxx.

Referenced by SomethingToEgg::add_merge_externals_options(), EggBase::add_normals_options(), and SomethingToEgg::SomethingToEgg().

bool ProgramBase::dispatch_path_replace ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single component of a path replace request.

The data pointer is to a PathReplace variable.

Definition at line 1185 of file programBase.cxx.

References PathReplace::add_pattern().

Referenced by ProgramBase::add_path_replace_options().

bool ProgramBase::dispatch_path_store ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a path store string.

The data pointer is to a PathStore variable.

Definition at line 1207 of file programBase.cxx.

Referenced by ProgramBase::add_path_store_options().

bool ProgramBase::dispatch_search_path ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single directory name to add to a search path.

The data pointer is to a DSearchPath variable. This kind of option may appear multiple times on the command line; each time, the new directory is appended.

Definition at line 1093 of file programBase.cxx.

References DSearchPath::append_directory(), and Filename::from_os_specific().

Referenced by ProgramBase::add_path_replace_options().

bool ProgramBase::dispatch_string ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a string.

The data pointer is to a string variable.

Definition at line 1011 of file programBase.cxx.

Referenced by SomethingToEgg::add_animation_options(), and EggReader::add_texture_options().

bool ProgramBase::dispatch_true ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'true' value.

This is another way to handle a boolean flag. See also dispatch_none() and dispatch_false().

The data pointer is to a bool variable.

Definition at line 741 of file programBase.cxx.

bool ProgramBase::dispatch_units ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a unit of distance measurement.

The data pointer is to a DistanceUnit variable.

Definition at line 1137 of file programBase.cxx.

Referenced by SomethingToEgg::add_units_options(), and EggToSomething::add_units_options().

bool ProgramBase::dispatch_vector_string ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a string.

This is different from dispatch_string in that the parameter may be repeated multiple times, and each time the string value is appended to a vector.

The data pointer is to a vector_string variable.

Definition at line 1031 of file programBase.cxx.

Referenced by EggBase::add_normals_options().

bool ProgramBase::dispatch_vector_string_comma ( const string &  opt,
const string &  arg,
void *  var 
) [static, protected, inherited]

Similar to dispatch_vector_string, but a comma is allowed to separate multiple tokens in one argument, without having to repeat the argument for each token.

The data pointer is to a vector_string variable.

Definition at line 1048 of file programBase.cxx.

int PStatServer::find_user_guide_bar ( float  from_height,
float  to_height 
) const [inherited]

Returns the index number of the first user guide bar found whose height is within the indicated range, or -1 if no user guide bars fall within the range.

Definition at line 277 of file pStatServer.cxx.

void ConnectionManager::flush_read_connection ( Connection connection) [protected, virtual, inherited]

An internal function called by ConnectionWriter only when a write failure has occurred.

This method ensures that all of the read data has been flushed from the pipe before the connection is fully removed.

Definition at line 376 of file connectionManager.cxx.

References Socket_IP::Close(), and Connection::get_socket().

void ProgramBase::format_text ( ostream &  out,
bool &  last_newline,
const string &  prefix,
int  indent_width,
const string &  text,
int  line_width 
) [static, protected, inherited]

Word-wraps the indicated text to the indicated output stream.

The first line is prefixed with the indicated prefix, then tabbed over to indent_width where the text actually begins. A newline is inserted at or before column line_width. Each subsequent line begins with indent_width spaces.

An embedded newline character ('
') forces a line break, while an embedded carriage-return character (''), or two or more consecutive newlines, marks a paragraph break, which is usually printed as a blank line. Redundant newline and carriage-return characters are generally ignored.

The flag last_newline should be initialized to false for the first call to format_text, and then preserved for future calls; it tracks the state of trailing newline characters between calls so we can correctly identify doubled newlines.

Definition at line 1263 of file programBase.cxx.

Referenced by ProgramBase::show_text().

string ProgramBase::get_exec_command ( ) const [inherited]

Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into the comments of output files.

Definition at line 367 of file programBase.cxx.

References Filename::get_basename_wo_extension().

Referenced by EggBase::append_command_comment().

string ConnectionManager::get_host_name ( ) [static, inherited]

Returns the name of this particular machine on the network, if available, or the empty string if the hostname cannot be determined.

Definition at line 343 of file connectionManager.cxx.

int PStatServer::get_num_user_guide_bars ( ) const [inherited]

Returns the current number of user-defined guide bars.

Definition at line 213 of file pStatServer.cxx.

int PStatServer::get_udp_port ( ) [inherited]

Returns a new port number that will probably be free to use as a UDP port.

The caller should be prepared to accept the possibility that it will be already in use by another process, however.

Definition at line 186 of file pStatServer.cxx.

Referenced by PStatReader::set_tcp_connection().

float PStatServer::get_user_guide_bar_height ( int  n) const [inherited]

Returns the height of the nth user-defined guide bar.

Definition at line 223 of file pStatServer.cxx.

bool ProgramBase::handle_args ( ProgramBase::Args &  args) [protected, virtual, inherited]

Does something with the additional arguments on the command line (after all the -options have been parsed).

Returns true if the arguments are good, false otherwise.

Reimplemented in BamInfo, EggToBam, CVSCopy, DXFPoints, EggMakeFont, EggOptchar, EggPalettize, EggQtess, EggFilter, EggMultiFilter, EggReader, EggToSomething, EggWriter, SomethingToEgg, EggTextureCards, FltInfo, FltTrans, ImageFilter, ImageReader, ImageWriter, ImageInfo, ImageTransformColors, LwoScan, BinToC, VRMLTrans, and XFileTrans.

Definition at line 419 of file programBase.cxx.

Referenced by ProgramBase::parse_command_line().

bool ProgramBase::handle_help_option ( const string &  opt,
const string &  arg,
void *  data 
) [static, protected, inherited]

Called when the user enters '-h', this describes how to use the program and then exits.

Definition at line 1228 of file programBase.cxx.

References ProgramBase::show_description(), ProgramBase::show_options(), and ProgramBase::show_usage().

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

This should be redefined to return true in derived classes that want to deal with multithreaded readers and such.

If this returns true, the manager will create the listener in its own thread, and thus the PStatReader constructors at least will run in a different thread.

This is not related to the question of whether the reader can handle multiple different PStatThreadDatas; it's strictly a question of whether the readers themselves can run in a separate thread.

Definition at line 320 of file pStatServer.cxx.

bool PStatServer::listen ( int  port = -1) [inherited]

Establishes a port number that the manager will listen on for TCP connections.

This may be called more than once to listen simulataneously on multiple connections, as if that were at all useful.

The default parameter, -1, indicates the use of whatever port number has been indicated in the Config file.

This function returns true if the port was successfully opened, or false if it could not open the port.

Definition at line 59 of file pStatServer.cxx.

References ConnectionReader::add_connection().

void PStatServer::main_loop ( bool *  interrupt_flag = NULL) [inherited]

An alternative to repeatedly calling poll(), this function yields control of the program to the PStatServer.

It does not return until the program is done.

If interrupt_flag is non-NULL, it is the address of a bool variable that is initially false, and may be asynchronously set true to indicate the loop should terminate.

Definition at line 142 of file pStatServer.cxx.

References PStatServer::poll(), and Thread::sleep().

void PStatServer::move_user_guide_bar ( int  n,
float  height 
) [inherited]

Adjusts the height of the nth user-defined guide bar.

Definition at line 234 of file pStatServer.cxx.

void ConnectionManager::new_connection ( const PT(Connection)&  connection) [protected, inherited]

This internal function is called whenever a new connection is established.

It allows the ConnectionManager to save all of the pointers to open connections so they can't be inadvertently deleted until close_connection() is called.

Definition at line 362 of file connectionManager.cxx.

Referenced by ConnectionListener::process_incoming_data().

void ProgramBase::parse_command_line ( int  argc,
char *  argv[] 
) [virtual, inherited]

Dispatches on each of the options on the command line, and passes the remaining parameters to handle_args().

If an error on the command line is detected, will automatically call show_usage() and exit(1).

Definition at line 208 of file programBase.cxx.

References Filename::from_os_specific(), ProgramBase::handle_args(), ProgramBase::post_command_line(), and ProgramBase::show_usage().

Referenced by MayaToEggServer::poll().

void PStatServer::poll ( ) [inherited]

Checks for any network activity and handles it, if appropriate, and then returns.

This must be called periodically unless is_thread_safe() is redefined to return true on this class and also on all PStatMonitors in use.

Alternatively, a program may call main_loop() and yield control of the program entirely to the PStatServer.

Definition at line 96 of file pStatServer.cxx.

References PStatReader::idle(), PStatReader::lost_connection(), and ConnectionReader::poll().

Referenced by PStatServer::main_loop().

bool ProgramBase::post_command_line ( ) [protected, virtual, inherited]

This is called after the command line has been completely processed, and it gives the program a chance to do some last-minute processing and validation of the options and arguments.

It should return true if everything is fine, false if there is an error.

Reimplemented in CVSCopy, EggFilter, EggMultiFilter, EggReader, EggSingleBase, EggWriter, SomethingToEgg, EggCharacterFilter, EggCrop, and ImageBase.

Definition at line 444 of file programBase.cxx.

Referenced by ProgramBase::parse_command_line().

bool ProgramBase::redescribe_option ( const string &  option,
const string &  description 
) [protected, inherited]

Changes the description associated with a previously-defined option.

Returns true if the option was changed, false if it hadn't been defined.

Definition at line 607 of file programBase.cxx.

Referenced by EggToSomething::EggToSomething(), EggWriter::EggWriter(), and SomethingToEgg::SomethingToEgg().

void PStatServer::release_udp_port ( int  port) [inherited]

Indicates that the given UDP port is once again free for use.

Definition at line 202 of file pStatServer.cxx.

bool ProgramBase::remove_option ( const string &  option) [protected, inherited]

Removes a previously-defined option.

Returns true if the option was removed, false if it hadn't existed.

Definition at line 623 of file programBase.cxx.

Referenced by SomethingToEgg::SomethingToEgg().

void PStatServer::remove_reader ( Connection connection,
PStatReader reader 
) [inherited]

Removes the indicated reader.

Definition at line 166 of file pStatServer.cxx.

Referenced by PStatReader::close().

void ConnectionManager::remove_reader ( ConnectionReader reader) [protected, inherited]

This internal function is called by ConnectionReader when it is destructed.

Definition at line 449 of file connectionManager.cxx.

void PStatServer::remove_user_guide_bar ( int  n) [inherited]

Removes the user guide bar with the indicated index number.

All subsequent index numbers are adjusted down one.

Definition at line 263 of file pStatServer.cxx.

void ConnectionManager::remove_writer ( ConnectionWriter writer) [protected, inherited]

This internal function is called by ConnectionWriter when it is destructed.

Definition at line 473 of file connectionManager.cxx.

void ProgramBase::set_program_description ( const string &  description) [protected, inherited]

Sets the description of the program that will be reported by show_usage().

The description should be one long string of text. Embedded newline characters are interpreted as paragraph breaks and printed as blank lines.

Definition at line 458 of file programBase.cxx.

void ProgramBase::show_description ( ) [inherited]

Writes the program description to stderr.

Definition at line 137 of file programBase.cxx.

Referenced by ProgramBase::handle_help_option().

void ProgramBase::show_options ( ) [inherited]

Describes each of the available options to stderr.

Definition at line 164 of file programBase.cxx.

References ProgramBase::show_text().

Referenced by ProgramBase::handle_help_option().

void ProgramBase::show_text ( const string &  text) [inline, inherited]

Formats the indicated text to stderr with the known _terminal_width.

Definition at line 23 of file programBase.I.

Referenced by ProgramBase::show_options(), and ProgramBase::show_usage().

void ProgramBase::show_text ( const string &  prefix,
int  indent_width,
string  text 
) [inherited]

Formats the indicated text and its prefix for output to stderr with the known _terminal_width.

Definition at line 188 of file programBase.cxx.

References ProgramBase::format_text().

void ProgramBase::show_usage ( ) [inherited]

Writes the usage line(s) to stderr.

Definition at line 147 of file programBase.cxx.

References Filename::get_basename_wo_extension(), and ProgramBase::show_text().

Referenced by ProgramBase::handle_help_option(), and ProgramBase::parse_command_line().


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