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

JAUS::Transport Class Reference

Transport is an interface class for creating Transport Services defined by the SAE-JAUS standard. All Transport Service implementations are based from this class. More...

#include <transport.h>

Inheritance diagram for JAUS::Transport:
JAUS::Service JAUS::JTCPClient JAUS::JUDP

List of all members.

Classes

class  Callback
 Callback class used to register to get a copy of a message received by the Transport Service. Messages received through the Callback are still received by the Component Services. More...
class  Receipt
 Data structure used to store information about messages waiting for incomming responses.

Public Member Functions

 Transport ()
 Constructor, initializes default values.
virtual ~Transport ()
 Destructor.
virtual bool CloseConnection (const Address &id)
virtual bool IsDiscoverable () const
void SetMaxMessageProcessingThreads (const unsigned int maxThreads=2)
 Sets how many threads should be created to handle processing of messages received by the Transport Service. Only works if IsInitialized is false (i.e. before calling Initialize).
void AddPriorityMessage (const UShort messageCode)
 A priority message is processed within it's own message processing thread. Priority messages are not queued, and any old messages will be overwritten with new ones.
virtual void SetMessagePollingDelayMs (const unsigned int delayTimeMs=1)
 Sets the delay time between checks for new messages to process by each message processing thread.
virtual bool Initialize (const Address &componentID)=0
virtual bool IsInitialized () const =0
virtual void Shutdown ()=0
virtual Address::List GetConnections () const =0
virtual bool HaveConnection (const Address &id) const =0
virtual void Receive (const Message *message)
 Processes messages passed-to or received by this Service.
virtual bool SendPacket (const Packet &packet, const Header &header, const int broadcastFlags=NoBroadcast) const =0
virtual bool SerializeMessage (const Message *message, Packet::List &stream, Header::List &streamHeaders, const UShort startingSequenceNumber, const int broadcastFlags) const =0
virtual Packet GetTransportHeader () const =0
virtual Address::List GetManualConnections () const =0
virtual MessageCreateMessage (const UShort messageCode) const
 Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.
virtual bool Send (const Message *message, const int broadcastFlags=Service::NoBroadcast) const
 Sends a JAUS message.
virtual bool Send (const Message *message, Message *response, const unsigned int waitTimeMs=Service::DefaultWaitMs) const
 Sends a JAUS message, and blocks until a response is received.
virtual bool Send (const Message *message, Message::List &possibleResponses, const unsigned int waitTimeMs=Service::DefaultWaitMs) const
 Sends a JAUS message, and blocks until a response is received. You must pass pointers to the response message object by adding them to the list passed.
void RegisterCallback (const UShort messageCode, Callback *callback)
 Allows external programs to get notified when specific types of messages are received by the Transport Service.
void EnableLogging (const bool flag=true)
 Turns on logging of data sent to/from the component using the transport service.
MessageCreateMessageFromService (const UShort messageCode, const Service *service) const
 Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.
MessageCreateMessageFromPacket (const Packet &packet) const
 Converts a packet containing a message type (UShort) and payload to a Message structure if supported by the child services.
void TriggerMessageCallbacks (const Message *message)
 Triggers any callbacks registered for the given message type.
void AddMessageTemplate (Message *message)
 Add a message class that the Transport service will save and use to deserialize custom messages no created by any known Service.
MessageGetMessageFromTemplate (const UShort messageCode) const
 Creates the desired message from templates.

Static Public Attributes

static const std::string Name = "urn:jaus:jss:core:Transport"
 Name of the service.
static const unsigned int MaxQueueSize = 1000
 Maximum packet queue size.

Protected Member Functions

virtual void ProcessPacket (const Packet &packet, const Header &header)
 Method called whenever a JAUS packet has been received by the transport layer.

Detailed Description

Transport is an interface class for creating Transport Services defined by the SAE-JAUS standard. All Transport Service implementations are based from this class.

Definition at line 61 of file transport.h.


Constructor & Destructor Documentation

Transport::Transport (  )

Constructor, initializes default values.

Definition at line 92 of file transport.cpp.

Transport::~Transport (  ) [virtual]

Destructor.

Definition at line 108 of file transport.cpp.


Member Function Documentation

void Transport::AddMessageTemplate ( Message message )

Add a message class that the Transport service will save and use to deserialize custom messages no created by any known Service.

Parameters:
[in]messagePointer to message template. Pointer ownership will be taken and any memory deleted by service.

Definition at line 680 of file transport.cpp.

void Transport::AddPriorityMessage ( const UShort  messageCode )

A priority message is processed within it's own message processing thread. Priority messages are not queued, and any old messages will be overwritten with new ones.

This feature is useful if you have a message type that arrives frequently from a given data source, and you do not want it queued because it will cause delays in your system.

Parameters:
[in]messageCodeMessage type to process seperately from other messages.

Definition at line 155 of file transport.cpp.

virtual bool JAUS::Transport::CloseConnection ( const Address id ) [inline, virtual]

Reimplemented in JAUS::JUDP.

Definition at line 86 of file transport.h.

Message * Transport::CreateMessage ( const UShort  messageCode ) const [virtual]

Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.

Parameters:
[in]messageCodeJAUS Message to try create.
Returns:
Pointer to created message, NULL if message not supported by any Services attached to the Transport.

Implements JAUS::Service.

Definition at line 199 of file transport.cpp.

Message * Transport::CreateMessageFromPacket ( const Packet packet ) const

Converts a packet containing a message type (UShort) and payload to a Message structure if supported by the child services.

Parameters:
[in]packetPacket of payload data with the frist 2 bytes being the message code. This packet should not contain the general transport header.
Returns:
Pointer to created message, NULL if message not supported by or attached to the given Service.

Definition at line 621 of file transport.cpp.

Message * Transport::CreateMessageFromService ( const UShort  messageCode,
const Service service 
) const

Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.

Parameters:
[in]messageCodeJAUS Message to try create.
[in]serviceThe Service to use to create a message.
Returns:
Pointer to created message, NULL if message not supported by or attached to the given Service.

Definition at line 565 of file transport.cpp.

void Transport::EnableLogging ( const bool  flag = true )

Turns on logging of data sent to/from the component using the transport service.

Parameters:
[in]flagIf true, turns logging on, if false, turns off. Logging is off by default.

Definition at line 384 of file transport.cpp.

virtual Address::List JAUS::Transport::GetConnections (  ) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

virtual Address::List JAUS::Transport::GetManualConnections (  ) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

Message * Transport::GetMessageFromTemplate ( const UShort  messageCode ) const

Creates the desired message from templates.

Parameters:
[in]messageCodeMessage type.
Returns:
Pointer to message structure (you must delete) on success, NULL if message type not found.

Definition at line 701 of file transport.cpp.

virtual Packet JAUS::Transport::GetTransportHeader (  ) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

virtual bool JAUS::Transport::HaveConnection ( const Address id ) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

virtual bool JAUS::Transport::Initialize ( const Address componentID ) [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

virtual bool JAUS::Transport::IsDiscoverable (  ) const [inline, virtual]

Implements JAUS::Service.

Definition at line 88 of file transport.h.

virtual bool JAUS::Transport::IsInitialized (  ) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

void Transport::ProcessPacket ( const Packet packet,
const Header header 
) [protected, virtual]

Method called whenever a JAUS packet has been received by the transport layer.

Parameters:
[in]packetJAUS formatted packet to process. Any transport headers excluding the transport header must be removed.
[in]headerGeneral Transport Header for the packet.

Definition at line 426 of file transport.cpp.

virtual void JAUS::Transport::Receive ( const Message message ) [inline, virtual]

Processes messages passed-to or received by this Service.

Whenever a Service receives a message, this method is called. New Services must overload this method to add processing capabilities.

If the service does not support the Message, then it must use the PushMessageToChildren method to pass it to inheriting Services that do support it (this is the default behavior of the method).

Parameters:
[in]messageJAUS Message data to process.

Reimplemented from JAUS::Service.

Definition at line 106 of file transport.h.

void Transport::RegisterCallback ( const UShort  messageCode,
Transport::Callback callback 
)

Allows external programs to get notified when specific types of messages are received by the Transport Service.

Messages are always passed to the inheriting Services, only copies of those messages are sent to registered callbacks (after Service receives them).

Parameters:
[in]messageCodeThe type of message to register the callback for.
[in]callbackThe callback to use.
Returns:
True on success, false on failure.

Definition at line 368 of file transport.cpp.

bool Transport::Send ( const Message message,
const int  broadcastFlags = Service::NoBroadcast 
) const [virtual]

Sends a JAUS message.

Parameters:
[in]messageJAUS Message to send.
[in]broadcastFlagsValues to use to signify if message should be sent using any broadcast options (e.g. multicast). 0 = no options, 1 = local broadcast, 2 = global broadcast.
Returns:
True on success, false on failure.

Reimplemented from JAUS::Service.

Definition at line 224 of file transport.cpp.

bool Transport::Send ( const Message message,
Message response,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) const [virtual]

Sends a JAUS message, and blocks until a response is received.

Parameters:
[in]messageJAUS Message to send.
[out]responsePointer to message that is the response to the message sent which will read received data.
[in]waitTimeMsHow long to wait in ms for a response to be received.
Returns:
True on success, false on failure.

Reimplemented from JAUS::Service.

Definition at line 272 of file transport.cpp.

bool Transport::Send ( const Message message,
Message::List possibleResponses,
const unsigned int  waitTimeMs = Service::DefaultWaitMs 
) const [virtual]

Sends a JAUS message, and blocks until a response is received. You must pass pointers to the response message object by adding them to the list passed.

On a succesful return, the possibleResponses list is modified to contain only the message containing the response. Make sure you manage the memory of the messages put in this list to prevent memory leaks.

Parameters:
[in]messageJAUS Message to send.
[out]possibleResponsesLists of messages that are possible responses to the message sent. For example Create Event can be responded with Confirm or Reject Event Request. Method does not delete or modify pointers.
[in]waitTimeMsHow long to wait in ms for a response to be received.
Returns:
True on success, false on failure.

Reimplemented from JAUS::Service.

Definition at line 304 of file transport.cpp.

virtual bool JAUS::Transport::SendPacket ( const Packet packet,
const Header header,
const int  broadcastFlags = NoBroadcast 
) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

virtual bool JAUS::Transport::SerializeMessage ( const Message message,
Packet::List &  stream,
Header::List streamHeaders,
const UShort  startingSequenceNumber,
const int  broadcastFlags 
) const [pure virtual]

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

void Transport::SetMaxMessageProcessingThreads ( const unsigned int  maxThreads = 2 )

Sets how many threads should be created to handle processing of messages received by the Transport Service. Only works if IsInitialized is false (i.e. before calling Initialize).

Parameters:
[in]maxThreadsNumber of threads (maxThreads >= 1).

Definition at line 132 of file transport.cpp.

void Transport::SetMessagePollingDelayMs ( const unsigned int  delayTimeMs = 1 ) [virtual]

Sets the delay time between checks for new messages to process by each message processing thread.

The default value is 1 ms, but can be set to 0 for no delay, or larger for less frequent checking of messages (use larger numbers on slower hardware).

Parameters:
[in]delayTimeMsDelay time between checks in milliseconds.

Definition at line 182 of file transport.cpp.

virtual void JAUS::Transport::Shutdown (  ) [pure virtual]

Reimplemented from JAUS::Service.

Implemented in JAUS::JTCPClient, and JAUS::JUDP.

void Transport::TriggerMessageCallbacks ( const Message message )

Triggers any callbacks registered for the given message type.

Definition at line 653 of file transport.cpp.


Member Data Documentation

const unsigned int JAUS::Transport::MaxQueueSize = 1000 [static]

Maximum packet queue size.

Definition at line 82 of file transport.h.

const std::string Transport::Name = "urn:jaus:jss:core:Transport" [static]

Name of the service.

Definition at line 81 of file transport.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines