vrpn  07.33
Virtual Reality Peripheral Network
vrpn_File_Connection Class Reference

#include <vrpn_FileConnection.h>

Inheritance diagram for vrpn_File_Connection:
Collaboration diagram for vrpn_File_Connection:

Classes

class  FileTime_Accumulator
 
class  vrpn_FileBookmark
 

Public Member Functions

 vrpn_File_Connection (const char *station_name, const char *local_in_logfile_name=NULL, const char *local_out_logfile_name=NULL)
 
virtual ~vrpn_File_Connection (void)
 
virtual int mainloop (const timeval *timeout=NULL)
 
virtual int time_since_connection_open (timeval *elapsed_time)
 Returns the time since the connection opened. Some subclasses may redefine time. More...
 
virtual timeval get_time ()
 returns the current time in the connection (since the epoch – UTC time). More...
 
virtual vrpn_File_Connectionget_File_Connection (void)
 vrpn_File_Connection implements this as "return this" so it can be used to detect a File_Connection and get the pointer for it More...
 
virtual int send_pending_reports (void)
 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 More...
 
void set_replay_rate (vrpn_float32 rate)
 
vrpn_float32 get_replay_rate ()
 
int reset (void)
 
int eof ()
 
int play_to_time (vrpn_float64 end_time)
 
int play_to_time (timeval end_time)
 
int play_to_filetime (const timeval end_filetime)
 
int playone ()
 
int playone_to_filetime (timeval end_filetime)
 
timeval get_length ()
 
double get_length_secs ()
 
timeval get_lowest_user_timestamp ()
 
timeval get_highest_user_timestamp ()
 
const char * get_filename ()
 
int jump_to_time (vrpn_float64 newtime)
 
int jump_to_time (timeval newtime)
 
int jump_to_filetime (timeval absolute_time)
 
void limit_messages_played_back (vrpn_uint32 max_playback)
 
- Public Member Functions inherited from vrpn_Connection
virtual ~vrpn_Connection (void)
 
virtual vrpn_bool doing_okay (void) const
 Returns vrpn_true if the connection is okay, vrpn_false if not. More...
 
virtual vrpn_bool connected (void) const
 Returns vrpn_true if the connection has been established, vrpn_false if not (For a networkless connection, this is equivalent to doing_okay()). More...
 
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. More...
 
virtual int mainloop (const struct timeval *timeout=NULL)=0
 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. More...
 
virtual vrpn_int32 register_sender (const char *name)
 Get a token to use for the string name of the sender or type. Remember to check for -1 meaning failure. More...
 
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)
 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. More...
 
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)
 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. More...
 
virtual const char * sender_name (vrpn_int32 sender)
 Returns the name of the specified sender/type, or NULL if the parameter is invalid. Only works for user messages (type >= 0). More...
 
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. More...
 
virtual int save_log_so_far ()
 Save any messages on any endpoints which have been logged so far. More...
 
void Jane_stop_this_crazy_thing (vrpn_uint32 stop_looking_after)
 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. More...
 
vrpn_uint32 get_Jane_value (void)
 
void addReference ()
 Counting references to this connection. More...
 
void removeReference ()
 
void setAutoDeleteStatus (bool setvalue)
 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. More...
 

Protected Member Functions

void find_superlative_user_times ()
 
bool store_stream_bookmark ()
 
bool return_to_bookmark ()
 
void play_to_user_message ()
 
int need_to_play (timeval filetime)
 
virtual int read_cookie (void)
 
virtual int read_entry (void)
 
virtual int advance_currentLogEntry (void)
 
virtual int close_file (void)
 
- Protected Member Functions inherited from vrpn_Connection
 vrpn_Connection (const char *local_in_logfile_name, const char *local_out_logfile_name, vrpn_Endpoint_IP *(*epa)(vrpn_Connection *, vrpn_int32 *)=allocateEndpoint)
 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. More...
 
 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_Endpoint_IP *(*epa)(vrpn_Connection *, vrpn_int32 *)=allocateEndpoint)
 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. More...
 
virtual void init (void)
 Base initialization for all constructors. More...
 
int delete_endpoint (int whichEndpoint)
 Deletes the endpoint and NULLs the entry in the list of open endpoints. More...
 
int compact_endpoints (void)
 Makes sure the endpoint array is set up cleanly for the next pass through. More...
 
virtual int pack_sender_description (vrpn_int32 which)
 Send the sender description to ALL endpoints. More...
 
virtual int pack_type_description (vrpn_int32 which)
 Send the type description to ALL endpoints. More...
 
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. More...
 
int doSystemCallbacksFor (vrpn_HANDLERPARAM, void *)
 
virtual void updateEndpoints (void)
 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.) More...
 

Static Protected Member Functions

static int VRPN_CALLBACK handle_set_replay_rate (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_reset (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_play_to_time (void *, vrpn_HANDLERPARAM)
 
- Static Protected Member Functions inherited from vrpn_Connection
static vrpn_Endpoint_IPallocateEndpoint (vrpn_Connection *, vrpn_int32 *connectedEC)
 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. More...
 
static int VRPN_CALLBACK handle_log_message (void *userdata, vrpn_HANDLERPARAM p)
 Routines that handle system messages. More...
 
static int VRPN_CALLBACK handle_disconnect_message (void *userdata, vrpn_HANDLERPARAM p)
 

Protected Attributes

vrpn_int32 d_controllerId
 
vrpn_int32 d_set_replay_rate_type
 
vrpn_int32 d_reset_type
 
vrpn_int32 d_play_to_time_type
 
timeval d_last_told
 
timeval d_time
 
timeval d_start_time
 
timeval d_earliest_user_time
 
vrpn_bool d_earliest_user_time_valid
 
timeval d_highest_user_time
 
vrpn_bool d_highest_user_time_valid
 
vrpn_FileBookmark d_bookmark
 
timeval d_last_time
 
FileTime_Accumulator d_filetime_accum
 
char * d_fileName
 
FILE * d_file
 
vrpn_LOGLISTd_logHead
 
vrpn_LOGLISTd_logTail
 
vrpn_LOGLISTd_currentLogEntry
 
vrpn_LOGLISTd_startEntry
 
bool d_preload
 
bool d_accumulate
 
- Protected Attributes inherited from vrpn_Connection
vrpn_uint32 d_stop_processing_messages_after
 If this value is greater than zero, the connection should stop looking for new messages on a given endpoint after this many are found. More...
 
int connectionStatus
 Status of the connection. More...
 
vrpn_Endpoint_IPd_endpoints [vrpn_MAX_ENDPOINTS]
 Sockets used to talk to remote Connection(s) and other information needed on a per-connection basis. More...
 
vrpn_int32 d_numEndpoints
 
vrpn_int32 d_numConnectedEndpoints
 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. More...
 
timeval start_time
 Timekeeping - TCH 30 June 98. More...
 
int d_serverLogCount
 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). More...
 
vrpn_int32 d_serverLogMode
 
char * d_serverLogName
 
vrpn_Endpoint_IP *(* d_endpointAllocator )(vrpn_Connection *, vrpn_int32 *)
 
vrpn_bool d_updateEndpoint
 

Additional Inherited Members

- Public Attributes inherited from vrpn_Connection
vrpn_TypeDispatcherd_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. More...
 

Detailed Description

Definition at line 73 of file vrpn_FileConnection.h.

Constructor & Destructor Documentation

◆ vrpn_File_Connection()

◆ ~vrpn_File_Connection()

vrpn_File_Connection::~vrpn_File_Connection ( void  )
virtual

Member Function Documentation

◆ advance_currentLogEntry()

int vrpn_File_Connection::advance_currentLogEntry ( void  )
protectedvirtual

Definition at line 722 of file vrpn_FileConnection.C.

References d_currentLogEntry, d_logTail, d_preload, vrpn_LOGLIST::next, and read_entry().

Referenced by find_superlative_user_times(), jump_to_time(), and playone_to_filetime().

Here is the call graph for this function:

◆ close_file()

int vrpn_File_Connection::close_file ( void  )
protectedvirtual

Definition at line 1165 of file vrpn_FileConnection.C.

References d_file.

Referenced by ~vrpn_File_Connection().

◆ eof()

int vrpn_File_Connection::eof ( )

Definition at line 614 of file vrpn_FileConnection.C.

References d_currentLogEntry, d_logTail, and read_entry().

Here is the call graph for this function:

◆ find_superlative_user_times()

◆ get_File_Connection()

vrpn_File_Connection * 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

Reimplemented from vrpn_Connection.

Definition at line 1006 of file vrpn_FileConnection.C.

◆ get_filename()

const char * vrpn_File_Connection::get_filename ( )

Definition at line 985 of file vrpn_FileConnection.C.

References d_fileName.

◆ get_highest_user_timestamp()

timeval vrpn_File_Connection::get_highest_user_timestamp ( )

Definition at line 768 of file vrpn_FileConnection.C.

References d_highest_user_time, d_highest_user_time_valid, and find_superlative_user_times().

Referenced by get_length().

Here is the call graph for this function:

◆ get_length()

timeval vrpn_File_Connection::get_length ( )

◆ get_length_secs()

double vrpn_File_Connection::get_length_secs ( )

Definition at line 743 of file vrpn_FileConnection.C.

References get_length(), and vrpn_TimevalMsecs().

Here is the call graph for this function:

◆ get_lowest_user_timestamp()

timeval vrpn_File_Connection::get_lowest_user_timestamp ( )

Definition at line 762 of file vrpn_FileConnection.C.

References d_earliest_user_time, d_earliest_user_time_valid, and find_superlative_user_times().

Referenced by get_length().

Here is the call graph for this function:

◆ get_replay_rate()

vrpn_float32 vrpn_File_Connection::get_replay_rate ( )
inline

Definition at line 109 of file vrpn_FileConnection.h.

◆ get_time()

virtual timeval vrpn_File_Connection::get_time ( )
inlinevirtual

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

Reimplemented from vrpn_Connection.

Definition at line 86 of file vrpn_FileConnection.h.

◆ handle_play_to_time()

int vrpn_File_Connection::handle_play_to_time ( void *  userdata,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 1231 of file vrpn_FileConnection.C.

References vrpn_HANDLERPARAM::buffer, and play_to_time().

Referenced by vrpn_File_Connection().

Here is the call graph for this function:

◆ handle_reset()

int vrpn_File_Connection::handle_reset ( void *  userdata,
vrpn_HANDLERPARAM   
)
staticprotected

Definition at line 1221 of file vrpn_FileConnection.C.

References reset().

Referenced by vrpn_File_Connection().

Here is the call graph for this function:

◆ handle_set_replay_rate()

int vrpn_File_Connection::handle_set_replay_rate ( void *  userdata,
vrpn_HANDLERPARAM  p 
)
staticprotected

Definition at line 1209 of file vrpn_FileConnection.C.

References vrpn_HANDLERPARAM::buffer, and set_replay_rate().

Referenced by vrpn_File_Connection().

Here is the call graph for this function:

◆ jump_to_filetime()

int vrpn_File_Connection::jump_to_filetime ( timeval  absolute_time)

Definition at line 273 of file vrpn_FileConnection.C.

References d_earliest_user_time, d_earliest_user_time_valid, d_start_time, jump_to_time(), and vrpn_TimevalDiff().

Here is the call graph for this function:

◆ jump_to_time() [1/2]

int vrpn_File_Connection::jump_to_time ( timeval  newtime)

◆ jump_to_time() [2/2]

int vrpn_File_Connection::jump_to_time ( vrpn_float64  newtime)

Definition at line 232 of file vrpn_FileConnection.C.

References vrpn_MsecsTimeval().

Referenced by jump_to_filetime().

Here is the call graph for this function:

◆ limit_messages_played_back()

void vrpn_File_Connection::limit_messages_played_back ( vrpn_uint32  max_playback)
inline

Definition at line 163 of file vrpn_FileConnection.h.

References vrpn_Connection::Jane_stop_this_crazy_thing().

Here is the call graph for this function:

◆ mainloop()

◆ need_to_play()

int vrpn_File_Connection::need_to_play ( timeval  filetime)
protected

Definition at line 515 of file vrpn_FileConnection.C.

References d_currentLogEntry, d_logTail, vrpn_LOGLIST::data, vrpn_HANDLERPARAM::msg_time, read_entry(), and vrpn_TimevalGreater().

Referenced by mainloop().

Here is the call graph for this function:

◆ play_to_filetime()

int vrpn_File_Connection::play_to_filetime ( const timeval  end_filetime)

Definition at line 572 of file vrpn_FileConnection.C.

References d_time, vrpn_Connection::get_Jane_value(), playone_to_filetime(), reset(), and vrpn_TimevalGreater().

Referenced by mainloop(), and play_to_time().

Here is the call graph for this function:

◆ play_to_time() [1/2]

int vrpn_File_Connection::play_to_time ( timeval  end_time)

Definition at line 559 of file vrpn_FileConnection.C.

References d_earliest_user_time, d_earliest_user_time_valid, d_start_time, play_to_filetime(), and vrpn_TimevalSum().

Here is the call graph for this function:

◆ play_to_time() [2/2]

int vrpn_File_Connection::play_to_time ( vrpn_float64  end_time)

Definition at line 553 of file vrpn_FileConnection.C.

References vrpn_MsecsTimeval().

Referenced by handle_play_to_time().

Here is the call graph for this function:

◆ play_to_user_message()

void vrpn_File_Connection::play_to_user_message ( void  )
protected

Definition at line 185 of file vrpn_FileConnection.C.

References d_currentLogEntry, d_time, vrpn_LOGLIST::data, vrpn_HANDLERPARAM::msg_time, playone(), and vrpn_HANDLERPARAM::type.

Referenced by reset(), and vrpn_File_Connection().

Here is the call graph for this function:

◆ playone()

int vrpn_File_Connection::playone ( )

Definition at line 633 of file vrpn_FileConnection.C.

References playone_to_filetime().

Referenced by play_to_user_message().

Here is the call graph for this function:

◆ playone_to_filetime()

◆ read_cookie()

int vrpn_File_Connection::read_cookie ( void  )
protectedvirtual

Definition at line 1019 of file vrpn_FileConnection.C.

References check_vrpn_file_cookie(), vrpn_Connection::d_endpoints, d_file, vrpn_Endpoint::d_inLog, vrpn_Log::setCookie(), and vrpn_cookie_size().

Referenced by reset(), and vrpn_File_Connection().

Here is the call graph for this function:

◆ read_entry()

◆ reset()

◆ return_to_bookmark()

◆ send_pending_reports()

int vrpn_File_Connection::send_pending_reports ( void  )
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

Implements vrpn_Connection.

Definition at line 1243 of file vrpn_FileConnection.C.

References vrpn_Endpoint_IP::clearBuffers(), and vrpn_Connection::d_endpoints.

Here is the call graph for this function:

◆ set_replay_rate()

void vrpn_File_Connection::set_replay_rate ( vrpn_float32  rate)
inline

Definition at line 104 of file vrpn_FileConnection.h.

Referenced by handle_set_replay_rate().

◆ store_stream_bookmark()

◆ time_since_connection_open()

int vrpn_File_Connection::time_since_connection_open ( timeval *  elapsed_time)
virtual

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

Reimplemented from vrpn_Connection.

Definition at line 990 of file vrpn_FileConnection.C.

References d_earliest_user_time, d_earliest_user_time_valid, d_start_time, d_time, find_superlative_user_times(), and vrpn_TimevalDiff().

Here is the call graph for this function:

Member Data Documentation

◆ d_accumulate

bool vrpn_File_Connection::d_accumulate
protected

◆ d_bookmark

vrpn_FileBookmark vrpn_File_Connection::d_bookmark
protected

Definition at line 213 of file vrpn_FileConnection.h.

Referenced by return_to_bookmark(), and store_stream_bookmark().

◆ d_controllerId

vrpn_int32 vrpn_File_Connection::d_controllerId
protected

Definition at line 166 of file vrpn_FileConnection.h.

Referenced by vrpn_File_Connection().

◆ d_currentLogEntry

◆ d_earliest_user_time

timeval vrpn_File_Connection::d_earliest_user_time
protected

◆ d_earliest_user_time_valid

vrpn_bool vrpn_File_Connection::d_earliest_user_time_valid
protected

◆ d_file

FILE* vrpn_File_Connection::d_file
protected

◆ d_fileName

char* vrpn_File_Connection::d_fileName
protected

◆ d_filetime_accum

FileTime_Accumulator vrpn_File_Connection::d_filetime_accum
protected

Definition at line 258 of file vrpn_FileConnection.h.

Referenced by mainloop(), and reset().

◆ d_highest_user_time

timeval vrpn_File_Connection::d_highest_user_time
protected

◆ d_highest_user_time_valid

vrpn_bool vrpn_File_Connection::d_highest_user_time_valid
protected

◆ d_last_time

timeval vrpn_File_Connection::d_last_time
protected

Definition at line 217 of file vrpn_FileConnection.h.

Referenced by mainloop(), reset(), and vrpn_File_Connection().

◆ d_last_told

timeval vrpn_File_Connection::d_last_told
protected

Definition at line 181 of file vrpn_FileConnection.h.

Referenced by read_entry(), and vrpn_File_Connection().

◆ d_logHead

vrpn_LOGLIST* vrpn_File_Connection::d_logHead
protected

◆ d_logTail

vrpn_LOGLIST* vrpn_File_Connection::d_logTail
protected

◆ d_play_to_time_type

vrpn_int32 vrpn_File_Connection::d_play_to_time_type
protected

Definition at line 175 of file vrpn_FileConnection.h.

Referenced by vrpn_File_Connection().

◆ d_preload

bool vrpn_File_Connection::d_preload
protected

◆ d_reset_type

vrpn_int32 vrpn_File_Connection::d_reset_type
protected

Definition at line 174 of file vrpn_FileConnection.h.

Referenced by vrpn_File_Connection().

◆ d_set_replay_rate_type

vrpn_int32 vrpn_File_Connection::d_set_replay_rate_type
protected

Definition at line 173 of file vrpn_FileConnection.h.

Referenced by vrpn_File_Connection().

◆ d_start_time

timeval vrpn_File_Connection::d_start_time
protected

◆ d_startEntry

vrpn_LOGLIST* vrpn_File_Connection::d_startEntry
protected

Definition at line 320 of file vrpn_FileConnection.h.

Referenced by reset(), and vrpn_File_Connection().

◆ d_time


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