RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Connection类 参考abstract

Generic connection class not specific to the transport mechanism. 更多...

#include <vrpn_Connection.h>

+ 类 vrpn_Connection 继承关系图:
+ vrpn_Connection 的协作图:

Public 成员函数

virtual vrpn_bool doing_okay (void) const
 Returns vrpn_true if the connection is okay, vrpn_false if not
 
virtual vrpn_bool connected (void) const
 
void get_log_names (char **local_in_logname, char **local_out_logname, char **remote_in_logname, char **remote_out_logname)
 
virtual int mainloop (const struct timeval *timeout=NULL)=0
 
virtual vrpn_int32 register_sender (const char *name)
 
virtual vrpn_int32 register_message_type (const char *name)
 
virtual int register_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
 
virtual int unregister_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
 
virtual int pack_message (vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)
 
virtual int send_pending_reports (void)=0
 
virtual int time_since_connection_open (struct timeval *elapsed_time)
 
virtual timeval get_time ()
 
virtual const char * sender_name (vrpn_int32 sender)
 
virtual const char * message_type_name (vrpn_int32 type)
 
virtual int register_log_filter (vrpn_LOGFILTER filter, void *userdata)
 Sets up a filter function for logging. Any user message to be logged is first passed to this function, and will only be logged if the function returns zero (XXX). NOTE: this only affects local logging - remote logging is unfiltered! Only user messages are filtered; all system messages are logged. Returns nonzero on failure.
 
virtual int save_log_so_far ()
 Save any messages on any endpoints which have been logged so far.
 
virtual vrpn_File_Connectionget_File_Connection (void)
 
void Jane_stop_this_crazy_thing (vrpn_uint32 stop_looking_after)
 
vrpn_uint32 get_Jane_value (void)
 
void addReference ()
 Counting references to this connection.
 
void removeReference ()
 
void setAutoDeleteStatus (bool setvalue)
 

Public 属性

vrpn_TypeDispatcher * d_dispatcher
 

Protected 成员函数

 vrpn_Connection (const char *local_in_logfile_name, const char *local_out_logfile_name, vrpn_EndpointAllocator epa=allocateEndpoint)
 
 vrpn_Connection (const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name, vrpn_EndpointAllocator epa=allocateEndpoint)
 
int delete_endpoint (vrpn_Endpoint *endpoint)
 
int compact_endpoints (void)
 
virtual int pack_sender_description (vrpn_int32 which)
 Send the sender description to ALL endpoints.
 
virtual int pack_type_description (vrpn_int32 which)
 Send the type description to ALL endpoints.
 
virtual int do_callbacks_for (vrpn_int32 type, vrpn_int32 sender, struct timeval time, vrpn_uint32 len, const char *buffer)
 
int message_type_is_registered (const char *) const
 Returns message type ID, or -1 if unregistered
 
int doSystemCallbacksFor (vrpn_HANDLERPARAM, void *)
 
virtual void updateEndpoints (void)
 

静态 Protected 成员函数

static vrpn_Endpoint_IPallocateEndpoint (vrpn_Connection *, vrpn_int32 *connectedEC)
 
static int VRPN_CALLBACK handle_log_message (void *userdata, vrpn_HANDLERPARAM p)
 Routines that handle system messages
 
static int VRPN_CALLBACK handle_disconnect_message (void *userdata, vrpn_HANDLERPARAM p)
 

Protected 属性

vrpn_uint32 d_stop_processing_messages_after
 
int connectionStatus
 Status of the connection
 
vrpn::BoundEndpointAllocator d_boundEndpointAllocator
 
vrpn::EndpointContainer d_endpoints
 
vrpn_int32 d_numConnectedEndpoints
 
timeval start_time
 Timekeeping - TCH 30 June 98
 
int d_serverLogCount
 
vrpn_int32 d_serverLogMode
 
char * d_serverLogName
 
vrpn_bool d_updateEndpoint
 

详细描述

Generic connection class not specific to the transport mechanism.

It abstracts all of the common functions. Specific implementations for IP, MPI, and other transport mechanisms follow.

构造及析构函数说明

◆ vrpn_Connection() [1/2]

vrpn_Connection ( const char * local_in_logfile_name,
const char * local_out_logfile_name,
vrpn_EndpointAllocator epa = allocateEndpoint )
protected

Constructor for server connection. This cannot be called directly any more because vrpn_Connection is an abstract base class. Call vrpn_create_server_connection() to make a server of arbitrary type based on a name.

◆ vrpn_Connection() [2/2]

vrpn_Connection ( const char * local_in_logfile_name,
const char * local_out_logfile_name,
const char * remote_in_logfile_name,
const char * remote_out_logfile_name,
vrpn_EndpointAllocator epa = allocateEndpoint )
protected

Constructor for client connection. This cannot be called directly because vrpn_Connection is an abstract base class. Call vrpn_get_connection_by_name() to create a client connection.

成员函数说明

◆ addReference()

void addReference ( )

Counting references to this connection.

+ 这是这个函数的调用关系图:

◆ allocateEndpoint()

static vrpn_Endpoint_IP * allocateEndpoint ( vrpn_Connection * ,
vrpn_int32 * connectedEC )
staticprotected

Redefining this and passing it to constructors allows a subclass to use a different subclass of Endpoint. It should do NOTHING but return an endpoint of the appropriate class; it may not access subclass data, since it'll be called from a constructor

◆ connected()

virtual vrpn_bool connected ( void ) const
virtual

Returns vrpn_true if the connection has been established, vrpn_false if not (For a networkless connection, this is equivalent to doing_okay()).

vrpn_Connection_Loopback 重载.

◆ doing_okay()

virtual vrpn_bool doing_okay ( void ) const
virtual

Returns vrpn_true if the connection is okay, vrpn_false if not

vrpn_Connection_Loopback 重载.

◆ get_File_Connection()

virtual vrpn_File_Connection * get_File_Connection ( void )
virtual

vrpn_File_Connection implements this as "return this" so it can be used to detect a File_Connection and get the pointer for it

vrpn_File_Connection 重载.

◆ get_log_names()

void get_log_names ( char ** local_in_logname,
char ** local_out_logname,
char ** remote_in_logname,
char ** remote_out_logname )

This function returns the logfile names of this connection in the parameters. It will allocate memory for the name of each log file in use. If no logging of a particular type is happening, then *(X_Y_logname) will be set to NULL. IMPORTANT: code calling this function is responsible for freeing the memory allocated for these strings.

◆ get_time()

virtual timeval get_time ( )
virtual

returns the current time in the connection (since the epoch – UTC time).

vrpn_File_Connection 重载.

◆ handle_log_message()

static int VRPN_CALLBACK handle_log_message ( void * userdata,
vrpn_HANDLERPARAM p )
staticprotected

Routines that handle system messages

◆ Jane_stop_this_crazy_thing()

void Jane_stop_this_crazy_thing ( vrpn_uint32 stop_looking_after)
inline

This function should be seldom used. It is here for the case of the vrpn_Imager, whose servers do not follow "The VRPN Way" because they try to jam more data into the network than there is bandwidth to support it. As a result, a client may call mainloop() on the connection and have it never return – there is always more data in the network to read, so we never hand control back to the main program. The reason for the name comes from an old U.S. cartoon called "The Jetsons". In it, George Jetson is running on a treadmill when it goes out of control and starts spinning so fast that he can't even run fast enough to reach the controls and turn it off. He cries out to his wife, "Jane! Stop this crazy thing!" The parameter specifies a trigger: if more than the specified number of messages come in on a given input channel during one mainloop() call, the connection should stop looking for more messages. NOTE: this does not guarantee that only this many messages will be received, only that the connection will stop looking for new ones on a given channel once that many have been received (for example, UDP channels will parse all the rest of the messages in a packet before stopping). A value of 0 turns off the limit, and will cause all incoming messages to be handled before returning.

◆ mainloop()

virtual int mainloop ( const struct timeval * timeout = NULL)
pure virtual

Call each time through program main loop to handle receiving any incoming messages and sending any packed messages. Returns -1 when connection dropped due to error, 0 otherwise. (only returns -1 once per connection drop). Optional argument is TOTAL time to block on select() calls; there may be multiple calls to select() per call to mainloop(), and this timeout will be divided evenly between them.

vrpn_Connection_IP , 以及 vrpn_Connection_Loopback 内被实现.

◆ message_type_is_registered()

int message_type_is_registered ( const char * ) const
protected

Returns message type ID, or -1 if unregistered

◆ pack_message()

virtual int pack_message ( vrpn_uint32 len,
struct timeval time,
vrpn_int32 type,
vrpn_int32 sender,
const char * buffer,
vrpn_uint32 class_of_service )
virtual

Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if you want low-latency (UDP) send.

◆ pack_sender_description()

virtual int pack_sender_description ( vrpn_int32 which)
protectedvirtual

Send the sender description to ALL endpoints.

◆ pack_type_description()

virtual int pack_type_description ( vrpn_int32 which)
protectedvirtual

Send the type description to ALL endpoints.

◆ register_handler()

virtual int register_handler ( vrpn_int32 type,
vrpn_MESSAGEHANDLER handler,
void * userdata,
vrpn_int32 sender = vrpn_ANY_SENDER )
virtual

Set up (or remove) a handler for a message of a given type. Optionally, specify which sender to handle messages from. Handlers will be called during mainloop(). Your handler should return 0 or a communication error is assumed and the connection will be shut down.

◆ register_log_filter()

virtual int register_log_filter ( vrpn_LOGFILTER filter,
void * userdata )
virtual

Sets up a filter function for logging. Any user message to be logged is first passed to this function, and will only be logged if the function returns zero (XXX). NOTE: this only affects local logging - remote logging is unfiltered! Only user messages are filtered; all system messages are logged. Returns nonzero on failure.

◆ register_sender()

virtual vrpn_int32 register_sender ( const char * name)
virtual

Get a token to use for the string name of the sender or type. Remember to check for -1 meaning failure.

◆ save_log_so_far()

virtual int save_log_so_far ( )
virtual

Save any messages on any endpoints which have been logged so far.

◆ send_pending_reports()

virtual int send_pending_reports ( void )
pure virtual

send pending report, clear the buffer. This function was protected, now is public, so we can use it to send out intermediate results without calling mainloop

vrpn_Connection_IP, vrpn_Connection_Loopback , 以及 vrpn_File_Connection 内被实现.

◆ sender_name()

virtual const char * sender_name ( vrpn_int32 sender)
virtual

Returns the name of the specified sender/type, or NULL if the parameter is invalid. Only works for user messages (type >= 0).

◆ setAutoDeleteStatus()

void setAutoDeleteStatus ( bool setvalue)
inline

Specify whether this connection should be deleted automatically when it is no longer need (reference count reaches zero). For connections created by the VRPN code (as is done in get_connection_by_name) these should be auto-deleted. Connections created by user code should not be auto-deleted; that is up to the user to decide when finished. By default, the constructor sets this to FALSE. VRPN code (or user code) can set this to TRUE if it wants the connection to be deleted automatically when the last service on it is deleted

◆ time_since_connection_open()

virtual int time_since_connection_open ( struct timeval * elapsed_time)
virtual

Returns the time since the connection opened. Some subclasses may redefine time.

vrpn_File_Connection 重载.

◆ updateEndpoints()

virtual void updateEndpoints ( void )
protectedvirtual

This function will be called on the mainloop() iteration after *d_endpointAllocator is called, which lets subclasses do initialization. (They can't do so during allocateEndpoint because it's called during the Connection constructor when their constructors haven't executed yet.)

类成员变量说明

◆ connectionStatus

int connectionStatus
protected

Status of the connection

◆ d_boundEndpointAllocator

vrpn::BoundEndpointAllocator d_boundEndpointAllocator
protected

Function object wrapping an endpoint allocator and binding its arguments.

◆ d_dispatcher

vrpn_TypeDispatcher* d_dispatcher

Derived classes need access to d_dispatcher in their allocateEndpoint() routine. Several compilers won't give it to them, even if they do inherit publicly. Until we figure that out, d_dispatcher needs to be public.

◆ d_endpoints

vrpn::EndpointContainer d_endpoints
protected

Sockets used to talk to remote Connection(s) and other information needed on a per-connection basis

◆ d_numConnectedEndpoints

vrpn_int32 d_numConnectedEndpoints
protected

We need to track the number of connected endpoints separately to properly send out got-first-connection/dropped-last-connection messages. This value is managed by the Endpoints, but we need exactly one copy per Connection, so it's on the Connection.

◆ d_serverLogCount

int d_serverLogCount
protected

Server logging w. multiconnection - TCH July 00 Use one "hidden" endpoint for outgoing logs (?), standard per-endpoint logs with augmented names for incoming. To make a hidden endpoint we create d_endpoints[0] and increment the d_numEndpoints, but DON'T pass it d_numConnectedEndpoints (although it should be safe to do so, since it should never truly become connected, but we might have to "fake" it to get it to log correctly).

◆ d_stop_processing_messages_after

vrpn_uint32 d_stop_processing_messages_after
protected

If this value is greater than zero, the connection should stop looking for new messages on a given endpoint after this many are found.

◆ start_time

timeval start_time
protected

Timekeeping - TCH 30 June 98


该类的文档由以下文件生成: