VR-Link API Documentation for DIS
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions
DtExerciseConn Class Reference

Instances of DtExerciseConn are used to provide an application's interface or connection to the network in a DIS environment. More...

+ Inheritance diagram for DtExerciseConn:
+ Collaboration diagram for DtExerciseConn:

List of all members.

Public Types

enum  {
  DtNET_READ_SUCCESS = 0, DtNET_READ_NO_PACKETS = 1, DtNET_READ_BAD_PACKET = 2, DtNET_READ_SERVER_MSG = 3,
  DtNET_READ_SIZE_MISMATCH = 4
}
 Status return codes for DtExerciseConn methods. More...
enum  { DtPROCESS_PDU_SUCCESS = 0, DtPROCESS_PDU_WRONG_EXID = 5, DtPROCESS_PDU_NO_PDU = 6, DtNET_READ_FILTERED_PACKET = 7 }
enum  InitializationStatus { DtINIT_SUCCESS = 0, DtCOULD_NOT_CREATE_SOCKET = 1 }
 InitializationStatus enumerates possible values to be returned by the ExerciseConns's optional 'status' variable. More...
typedef int(* DtPredicate )(DtPdu *pdu, void *arg)

Public Member Functions

 DtExerciseConn (const DtExerciseConnInitializer &initial, InitializationStatus *status=0)
 The preferred constructor.
 DtExerciseConn (int port, int exercise_id, int site_id, int application_num, InitializationStatus *status=0, bool use_async_io=false, bool useIpv6=false, bool suppressSelfReflect=false)
 Constructor.
 DtExerciseConn (int port, const DtInetAddr &destAddr, int exercise_id, int site_id, int application_num, InitializationStatus *status=0, bool use_async_io=false, bool suppressSelfReflect=false)
 Constructor.
 DtExerciseConn (DtInetSocket *skt, int exercise_id, int site_id, int application_num, InitializationStatus *status=0)
 Constructor.
virtual ~DtExerciseConn ()
 Destructor.
virtual void addPduCallback (DtPduKind pduKind, DtPduCallbackFcn fcn, void *usr)
 Register callbacks by PDU kind, should not be called directly.
virtual void removePduCallback (DtPduKind pduKind, DtPduCallbackFcn fcn, void *usr)
 Deregister callbacks by PDU kind, should not be called directly.
virtual int drainInput (DtTime timeout=-1, int nReadPerTimeCheck=100)
 Normal way of processing input from the network.
virtual int readAndProcess (void)
 Called by drainInput, so application code rarely needs to use this.
virtual int processPdu (DtPdu *pdu)
 Called by readAndProcess (which is called by drainInput).
virtual DtPdunetRead (int *retCode=0)
 Reads the network, users should seldom need to call this function.
virtual void addInterestInPduKind (DtPduKind kind)
 Adds interest in a PDU kind, users should not call directly.
virtual void subtractInterestInPduKind (DtPduKind kind)
 Subtracts interest in a PDU kind, users should not call directly.
virtual DtPduKind readUntil (DtPredicate predicate, void *arg, DtTime timeout, DtTime sleepTime=0.1)
 Repeatedly call readAndProcess until predicate holds on the PDU that is being read, or until timeout seconds have elapsed.
virtual void addInterestInMcastAddr (const DtInetAddr &addr)
 Add interest in a multicast address.
virtual void subtractInterestInMcastAddr (const DtInetAddr &addr)
 Subtract interest in a multicast address.
virtual void send (const DtStateMsg &msg)
 Send a message - call down to send(DtPdu &pdu....)
virtual void send (const DtInteraction &msg)
 Send an interaction - call down to send(DtPdu &pdu....)
virtual void sendStamped (const DtStateMsg &msg)
 Send a stamped message - call down to sendStamped(DtPdu &pdu....)
virtual void sendStamped (const DtInteraction &msg)
 Send a stamped message - call down to sendStamped(DtPdu &pdu....)
virtual int send (const DtPdu &pdu, const DtInetAddr *addr=0)
 Send a PDU to the specified address, or the DtExerciseConn's default destination address if addr is 0.
virtual int sendStamped (const DtPdu &pdu, const DtInetAddr *addr=0)
 Send a PDU to the specified address, or the DtExerciseConn's default destination address if addr is 0.
virtual DtInetAddrdestinationAddr (const DtPdu &pdu)
 Returns the current destination address for the PDU.
virtual bool addDestination (const DtInetAddr &destination, DtU16 port=0)
 Add an additional destination.
virtual bool removeDestination (const DtInetAddr &destination, DtU16 port=0)
 Remove a destination.
virtual void setExerciseId (int exercise_id)
 Set the current exercise ID.
virtual DtExerciseId exerciseId () const
 Get the current exercise ID.
virtual const DtEventIDnextEventId ()
 Return an event ID consisting of the DtExerciseConn's site and host numbers, and the current value of an event number counter.
virtual DtInetSocketsocket ()
 Returns the current DtDisSocket that we are using for communication.
virtual DtPduFactorypduFactory ()
 Get the PDU factory used by netRead to create the right kind of derived DtPDU.
virtual void setPduFactory (DtPduFactory *fact)
 Rather than just modifying the ExerciseConn's current PDU factory, you can tell the ExerciseConn to use a different PDU factory object.
virtual void enableFiltering ()
 EnablePDU filtering.
virtual void disableFiltering ()
 Disable PDU filtering.
virtual void setTimeStampType (DtTimeStampType relOrAbs)
 set time stamp type (DtTimeStampAbsolute or DtTimeStampRelative).
virtual DtTimeStampType timeStampType () const
 Get time stamp type (DtTimeStampAbsolute or DtTimeStampRelative).
virtual void setTimeStampType (int relOrAbs)
 This function has been obsoleted by the version above that use the DtTimeStampType enumeration, but is included for backwards compatibility.
virtual DtDisObjectManagerdisObjectManager ()
 Get the disObjectManager.

Static Public Member Functions

static DtString vrlinkVersion ()
 Returns a string indicating the VR-Link version number.

Static Public Attributes

static const int nSizeMismatchComplain
 For VR-Link use only, should not be considered part of the public interface.

Protected Member Functions

virtual DtTime currentTimeForStamping ()
 Return time to send with outgoing messages (default is sim time if absolute timestamping, real time otherwise.)
void init0 (int port, int exerId, int siteId, int applNum, InitializationStatus *status, bool async_io, bool useIpv6, bool suppressSelfReflect)
 Called by constructor.
void init0 (DtInetSocket *s, int exerId, int siteId, int applNum, InitializationStatus *status)
 Called by constructor.
virtual void setRemoteEndpoint (const DtInetAddr &addr, int port)
void init (DtInetSocket *s, int deleteSkt, int exerId, int siteId, int applNum, InitializationStatus *status)
 Called by constructor.
DtDisSocketinitializeSocket (const DtInetAddr &address, int port, bool useAsyncIo, DtInetDevice *device, bool suppressSelfReflect)
void zeroPduInterestList ()

Protected Attributes

DtExerciseId myExerciseId
int availEventNum
int deleteSocket
DtPduCallbackManager myPduCbMgr
int pduInterest [DtMAX_PDU_KINDS+1]
int nSizeMismatch
bool filtering
DtHashlist mcastAddrs
DtPduFactorymyPduFact
DtPduFactorymyDfltPduFact
DtEventID myCurrentEventId
DtTimeStampType myRelOrAbs
DtDisObjectManagermyDisObjectManager
DtInetSocketmySocket
DtInetEndpoint myRemoteEndpoint
DtInetBufferChain myBufferChain
DtInetBuffer myBuffer
char * myPacketBuffer
DtInetEndpoint myEndpointReceivedFrom

Private Member Functions

 DtExerciseConn (const DtExerciseConn &orig)
 Copy constructor - not implemented.
DtExerciseConnoperator= (const DtExerciseConn &orig)
 Assignment operator - not implemented.

Detailed Description

Instances of DtExerciseConn are used to provide an application's interface or connection to the network in a DIS environment.

The DtExerciseConn instance is the central class in a VR-Link application.

Examples
See also:
DtExerciseConnInitializer

Member Typedef Documentation

typedef int(* DtExerciseConn::DtPredicate)(DtPdu *pdu, void *arg)

Member Enumeration Documentation

anonymous enum

Status return codes for DtExerciseConn methods.

Enumerator:
DtNET_READ_SUCCESS 

No error, call was sucessful.

DtNET_READ_NO_PACKETS 

No packets were read.

DtNET_READ_BAD_PACKET 

A packet read error occured.

DtNET_READ_SERVER_MSG 
DtNET_READ_SIZE_MISMATCH 

Received a packet with an invalid size.

anonymous enum
Enumerator:
DtPROCESS_PDU_SUCCESS 
DtPROCESS_PDU_WRONG_EXID 
DtPROCESS_PDU_NO_PDU 
DtNET_READ_FILTERED_PACKET 

InitializationStatus enumerates possible values to be returned by the ExerciseConns's optional 'status' variable.

When status is non-null, DtFatalError will not get called, allowing users to check programmatically for initialization errors and hence deal with them as they wish. If no errors occur, status will equal DtINIT_SUCCESS.

Note:
Do not attempt to use a DtExerciseConn instance when an error is indicated: VR-Link's behavior will be undefined.
Enumerator:
DtINIT_SUCCESS 

Class initialized with no error.

DtCOULD_NOT_CREATE_SOCKET 

Class could not open socket, the class is not usable.


Constructor & Destructor Documentation

The preferred constructor.

Use status when you want to know whether the exercise connection has successfully initialized itself. When status is non-null, DtFatalError will not get called, allowing users to check programmatically for errors and hence deal with them as they wish.

Note:
Do not attempt to use a DtExerciseConn instance when status is not DtINIT_SUCESS, VR-Link's behavior will be undefined.
DtExerciseConn::DtExerciseConn ( int  port,
int  exercise_id,
int  site_id,
int  application_num,
InitializationStatus status = 0,
bool  use_async_io = false,
bool  useIpv6 = false,
bool  suppressSelfReflect = false 
) [inline]

Constructor.

Deprecated:
Users should now use the DtExeciseConnInitializer CTOR

References init0().

DtExerciseConn::DtExerciseConn ( int  port,
const DtInetAddr destAddr,
int  exercise_id,
int  site_id,
int  application_num,
InitializationStatus status = 0,
bool  use_async_io = false,
bool  suppressSelfReflect = false 
)

Constructor.

Deprecated:
Users should now use the DtExeciseConnInitializer CTOR
DtExerciseConn::DtExerciseConn ( DtInetSocket skt,
int  exercise_id,
int  site_id,
int  application_num,
InitializationStatus status = 0 
) [inline]

Constructor.

Deprecated:
Users should now use the DtExeciseConnInitializer CTOR

References init0().

virtual DtExerciseConn::~DtExerciseConn ( ) [virtual]

Destructor.

DtExerciseConn::DtExerciseConn ( const DtExerciseConn orig) [private]

Copy constructor - not implemented.


Member Function Documentation

virtual bool DtExerciseConn::addDestination ( const DtInetAddr destination,
DtU16  port = 0 
) [virtual]

Add an additional destination.

Packets will be sent to these destinations in addition to the sockets destination. Use the given port to create the destination endpoint to be added. By default (port == 0), the destination port of the exercise connection's socket will be used unless specified otherwise. Return indicates if destination was added successfully (true) or not (false).

virtual void DtExerciseConn::addInterestInMcastAddr ( const DtInetAddr addr) [virtual]

Add interest in a multicast address.

Valid multicast addresses are between 224.0.0.0 and 239.255.255.255.

virtual void DtExerciseConn::addInterestInPduKind ( DtPduKind  kind) [virtual]

Adds interest in a PDU kind, users should not call directly.

PDUs in which no interest has been registered are filtered out below the level of netRead (possibly by the packet server). All PDU kinds for which user callbacks have been registered automatically are "interesting", so there is rarely a need to application code to call these functions.

virtual void DtExerciseConn::addPduCallback ( DtPduKind  pduKind,
DtPduCallbackFcn  fcn,
void *  usr 
) [virtual]

Register callbacks by PDU kind, should not be called directly.

Called by each derived DtPdu's addCallback function, which should be called instead of these by user code.

virtual DtTime DtExerciseConn::currentTimeForStamping ( ) [protected, virtual]

Return time to send with outgoing messages (default is sim time if absolute timestamping, real time otherwise.)

virtual DtInetAddr* DtExerciseConn::destinationAddr ( const DtPdu pdu) [virtual]

Returns the current destination address for the PDU.

Defaults to a null pointer. The pointer should be deleted by the calling code.

virtual void DtExerciseConn::disableFiltering ( ) [virtual]

Disable PDU filtering.

Get the disObjectManager.

References myDisObjectManager.

virtual int DtExerciseConn::drainInput ( DtTime  timeout = -1,
int  nReadPerTimeCheck = 100 
) [virtual]

Normal way of processing input from the network.

Repeatedly calls readAndProcess to read PDUs and execute user callbacks. If timeout is -1, return only when there are no PDUs left to read. Otherwise, read for a maximum of timeout seconds. nReadPerTimeCheck is the number of PDUs to read in between checks to see if timeout has expired.

virtual void DtExerciseConn::enableFiltering ( ) [virtual]

EnablePDU filtering.

DtExerciseId DtExerciseConn::exerciseId ( ) const [inline, virtual]

Get the current exercise ID.

References myExerciseId.

void DtExerciseConn::init ( DtInetSocket s,
int  deleteSkt,
int  exerId,
int  siteId,
int  applNum,
InitializationStatus status 
) [protected]

Called by constructor.

void DtExerciseConn::init0 ( int  port,
int  exerId,
int  siteId,
int  applNum,
InitializationStatus status,
bool  async_io,
bool  useIpv6,
bool  suppressSelfReflect 
) [protected]

Called by constructor.

Referenced by DtExerciseConn().

void DtExerciseConn::init0 ( DtInetSocket s,
int  exerId,
int  siteId,
int  applNum,
InitializationStatus status 
) [protected]

Called by constructor.

DtDisSocket* DtExerciseConn::initializeSocket ( const DtInetAddr address,
int  port,
bool  useAsyncIo,
DtInetDevice device,
bool  suppressSelfReflect 
) [protected]
virtual DtPdu* DtExerciseConn::netRead ( int *  retCode = 0) [virtual]

Reads the network, users should seldom need to call this function.

Caller, (usually readAndProcess()), is responsible for deleting it when through. netRead() creates a new DtPdu on the heap. Caller,

Referenced by readAndProcess().

virtual const DtEventID& DtExerciseConn::nextEventId ( ) [virtual]

Return an event ID consisting of the DtExerciseConn's site and host numbers, and the current value of an event number counter.

DtExerciseConn& DtExerciseConn::operator= ( const DtExerciseConn orig) [private]

Assignment operator - not implemented.

DtPduFactory * DtExerciseConn::pduFactory ( ) [inline, virtual]

Get the PDU factory used by netRead to create the right kind of derived DtPDU.

You can use DtPduFactory member function, including its assignment operator to configure it to "know" about various PDU classes. For example, you can use *(exConn.pduFactory()) = DtDisPduFactory(); to configure the PDU factory to know about all DIS PDUs and the VR-Link classes that represent them.

References myPduFact.

virtual int DtExerciseConn::processPdu ( DtPdu pdu) [virtual]

Called by readAndProcess (which is called by drainInput).

The default behavior is to execute any user callbacks that have been registered on the pdu's kind.

Referenced by readAndProcess().

int DtExerciseConn::readAndProcess ( void  ) [inline, virtual]

Called by drainInput, so application code rarely needs to use this.

Reads and processes (via netRead and processPdu) a single PDU.

References DtNET_READ_SUCCESS, netRead(), and processPdu().

virtual DtPduKind DtExerciseConn::readUntil ( DtPredicate  predicate,
void *  arg,
DtTime  timeout,
DtTime  sleepTime = 0.1 
) [virtual]

Repeatedly call readAndProcess until predicate holds on the PDU that is being read, or until timeout seconds have elapsed.

sleepTime indicates the amount of time to sleep in between polling the network when there are no packets to read.

virtual bool DtExerciseConn::removeDestination ( const DtInetAddr destination,
DtU16  port = 0 
) [virtual]

Remove a destination.

Address will be removed from the list of additional destinations for sending packets. Use the given port to create the destination endpoint to be removed. By default (port == 0), the destination port of the exercise connection's socket will be used unless specified otherwise. Return indicates if destination was removed successfully (true) or not (false).

virtual void DtExerciseConn::removePduCallback ( DtPduKind  pduKind,
DtPduCallbackFcn  fcn,
void *  usr 
) [virtual]

Deregister callbacks by PDU kind, should not be called directly.

Called by each derived DtPdu's addCallback function, which should be called instead of these by user code.

virtual void DtExerciseConn::send ( const DtStateMsg msg) [virtual]

Send a message - call down to send(DtPdu &pdu....)

Implements DtBaseExerciseConn.

virtual void DtExerciseConn::send ( const DtInteraction msg) [virtual]

Send an interaction - call down to send(DtPdu &pdu....)

Implements DtBaseExerciseConn.

virtual int DtExerciseConn::send ( const DtPdu pdu,
const DtInetAddr addr = 0 
) [virtual]

Send a PDU to the specified address, or the DtExerciseConn's default destination address if addr is 0.

PDU must be completely filled out, as it is not touched by this call. Return the number of bytes sent or -1 if there was an error.

virtual void DtExerciseConn::sendStamped ( const DtStateMsg msg) [virtual]

Send a stamped message - call down to sendStamped(DtPdu &pdu....)

Implements DtBaseExerciseConn.

virtual void DtExerciseConn::sendStamped ( const DtInteraction msg) [virtual]

Send a stamped message - call down to sendStamped(DtPdu &pdu....)

Implements DtBaseExerciseConn.

virtual int DtExerciseConn::sendStamped ( const DtPdu pdu,
const DtInetAddr addr = 0 
) [virtual]

Send a PDU to the specified address, or the DtExerciseConn's default destination address if addr is 0.

The outgoing PDU is stamped with the current timeStamp (obtained using currentTimeForStamping()), and the current exerciseId. Return the number of bytes sent or -1 if there was an error.

virtual void DtExerciseConn::setExerciseId ( int  exercise_id) [virtual]

Set the current exercise ID.

virtual void DtExerciseConn::setPduFactory ( DtPduFactory fact) [virtual]

Rather than just modifying the ExerciseConn's current PDU factory, you can tell the ExerciseConn to use a different PDU factory object.

The object passed belongs to the ExerciseConn, and should not be deleted until after a subsequent call to setPduFactory, or the ExerciseConn is deleted.

virtual void DtExerciseConn::setRemoteEndpoint ( const DtInetAddr addr,
int  port 
) [protected, virtual]
virtual void DtExerciseConn::setTimeStampType ( DtTimeStampType  relOrAbs) [virtual]

set time stamp type (DtTimeStampAbsolute or DtTimeStampRelative).

virtual void DtExerciseConn::setTimeStampType ( int  relOrAbs) [virtual]

This function has been obsoleted by the version above that use the DtTimeStampType enumeration, but is included for backwards compatibility.

DtInetSocket * DtExerciseConn::socket ( ) [inline, virtual]

Returns the current DtDisSocket that we are using for communication.

References mySocket.

virtual void DtExerciseConn::subtractInterestInMcastAddr ( const DtInetAddr addr) [virtual]

Subtract interest in a multicast address.

Valid multicast addresses are between 224.0.0.0 and 239.255.255.255.

virtual void DtExerciseConn::subtractInterestInPduKind ( DtPduKind  kind) [virtual]

Subtracts interest in a PDU kind, users should not call directly.

PDUs in which no interest has been registered are filtered out below the level of netRead (possibly by the packet server). All PDU kinds for which user callbacks have been registered automatically are "interesting", so there is rarely a need to application code to call these functions.

virtual DtTimeStampType DtExerciseConn::timeStampType ( ) const [virtual]

Get time stamp type (DtTimeStampAbsolute or DtTimeStampRelative).

Returns a string indicating the VR-Link version number.


Member Data Documentation

bool DtExerciseConn::filtering [protected]

Referenced by disObjectManager().

Referenced by exerciseId().

char* DtExerciseConn::myPacketBuffer [protected]

Referenced by pduFactory().

Referenced by socket().

For VR-Link use only, should not be considered part of the public interface.


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

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)