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>
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 Message * | CreateMessage (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. | |
Message * | 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. | |
Message * | 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. | |
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. | |
Message * | GetMessageFromTemplate (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. |
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.
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.
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.
[in] | message | Pointer 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.
[in] | messageCode | Message 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.
Given a message code, the Service attempts to create a Message object that can be used for de-serialization of JAUS packets.
Implements JAUS::Service.
Definition at line 199 of file transport.cpp.
Converts a packet containing a message type (UShort) and payload to a Message structure if supported by the child services.
[in] | packet | Packet of payload data with the frist 2 bytes being the message code. This packet should not contain the general transport header. |
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.
[in] | messageCode | JAUS Message to try create. |
[in] | service | The Service to use to create a message. |
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.
[in] | flag | If 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.
Creates the desired message from templates.
[in] | messageCode | Message type. |
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.
Method called whenever a JAUS packet has been received by the transport layer.
[in] | packet | JAUS formatted packet to process. Any transport headers excluding the transport header must be removed. |
[in] | header | General 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).
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).
[in] | messageCode | The type of message to register the callback for. |
[in] | callback | The callback to use. |
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.
[in] | message | JAUS Message to send. |
[in] | broadcastFlags | Values 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. |
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.
[in] | message | JAUS Message to send. |
[out] | response | Pointer to message that is the response to the message sent which will read received data. |
[in] | waitTimeMs | How long to wait in ms for a response to be received. |
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.
[in] | message | JAUS Message to send. |
[out] | possibleResponses | Lists 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] | waitTimeMs | How long to wait in ms for a response to be received. |
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).
[in] | maxThreads | Number 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).
[in] | delayTimeMs | Delay 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.
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.