C++ TargetRTS
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
RTMessage Class Reference

Represents a message used for communication between capsule instances. More...

#include <RTMessage.h>

Public Types

enum  DeliverResult { Accepted , Deferred , Rejected }
 

Public Member Functions

void clear (void)
 Destroy the data object stored in the message, and reset the message object to make it ready to be used in another communication.
 
 RTMessage (const RTMessage &)
 
int isRTData (void) const
 Determines if the message carries a data object which is an RTDataObject.
 
void setDeferred (void)
 Mark this message as deferred.
 
void resetDeferred (void)
 Mark this message as not deferred.
 
int isDeferred (void) const
 Determines if this message has been deferred, i.e.
 
void setInvalid (void)
 
int isValid (void) const
 A message is considered valid as soon as its protocol event (i.e.
 
void setSignal (int id)
 Set the signal id of the message, i.e.
 
int getSignal (void) const
 Get the signal id of the message, i.e.
 
const char * getSignalName (void) const
 Get the signal name of the message, i.e.
 
void setPriority (int prio)
 Set the priority of the message.
 
int getPriority (void) const
 Get the priority of the message.
 
void * getData (void) const
 Get the data object carried by the message, if any.
 
void setData (const void *data, const RTObject_class *type)
 Set the data object of the message.
 
void setData (const RTDataObject &data)
 Set the data object of the message.
 
void internData (bool moveData=false)
 Intern the data object of the message.
 
const RTObject_classgetType (void) const
 Get the type of the data object of the message, if any.
 
RTProtocolsap (void) const
 Return the capsule port on which this message was received.
 
int sapId (void) const
 Return the id of the capsule port on which this message was received.
 
int sapIndex0 (void) const
 Return the index (0-based) of the replicated port on which this message was received.
 
int sapIndex (void) const
 Return the index (1-based) of the replicated port on which this message was received.
 
DeliverResult deliver (void)
 Attempt to deliver the message to its specified receiver.
 
RTMessageoperator= (const RTMessage &)
 
int defer (void) const
 Defer the message by placing it in the defer queue.
 
void setDestination (RTActor *cap, RTProtocol *port, int index)
 Set the destination (i.e.
 
RTActorreceiver (void) const
 Return the currently set receiver for the message.
 
RTControllercontext (void) const
 Return the controller of the message receiver.
 

Public Attributes

RTMessagenext
 
int _sendPortId
 
int _sendPortIndex
 
int _sendProbeId
 
RTTimespec _sendTime
 
union {
   void *   data
 
   const void *   const_data
 
}; 
 
short signal
 
unsigned char priority
 

Protected Types

enum  { MaskDeferred = 1 , MaskDataOwned = 2 }
 

Protected Member Functions

void _internData (bool moveData)
 

Protected Attributes

unsigned char _flags
 
RTActor_receiver
 
RTProtocol_port
 
int _portIndex
 
const RTObject_class_type
 

Detailed Description

Represents a message used for communication between capsule instances.

The message may carry a data object. A message object is usually an instance of a protocol event. However, there are also internal messages used by the TargetRTS itself.

Member Function Documentation

◆ clear()

void RTMessage::clear ( void  )

Destroy the data object stored in the message, and reset the message object to make it ready to be used in another communication.

This function is called internally by the TargetRTS and there is usually no need to call it directly.

◆ context()

RTController * RTMessage::context ( void  ) const

Return the controller of the message receiver.

Returns
The controller of the capsule instance that is set-up as the receiver of the message.

◆ defer()

int RTMessage::defer ( void  ) const

Defer the message by placing it in the defer queue.

You can later recall a deferred message by calling one of the recall functions of RTInSignal or RTProtocol.

Returns
1 if the message was successfully deferred, 0 otherwise.

◆ deliver()

DeliverResult RTMessage::deliver ( void  )

Attempt to deliver the message to its specified receiver.

This function is called by the TargetRTS when a message is sent, and it's normally not useful to call it directly.

Returns
A delivery status informing about how the receiver handled the message.

◆ getData()

void * RTMessage::getData ( void  ) const

Get the data object carried by the message, if any.

Returns
The data object carried by the message, or NULL if none.

◆ getPriority()

int RTMessage::getPriority ( void  ) const

Get the priority of the message.

See RTPriority.h for a list of valid message priorities.

Returns
The priority for the message.

◆ getSignal()

int RTMessage::getSignal ( void  ) const

Get the signal id of the message, i.e.

the id of its protocol event.

Returns
Numeric id of the protocol event of the message.

◆ getSignalName()

const char * RTMessage::getSignalName ( void  ) const

Get the signal name of the message, i.e.

the name of its protocol event.

Returns
Name of the protocol event of the message.

◆ getType()

const RTObject_class * RTMessage::getType ( void  ) const

Get the type of the data object of the message, if any.

Returns
Type descriptor for the data object, or NULL in case the message does not have one.

◆ internData()

void RTMessage::internData ( bool  moveData = false)

Intern the data object of the message.

Normally this means the data object will be copied into the message but if moveData is true, the data object will instead be moved into the message.

◆ isDeferred()

int RTMessage::isDeferred ( void  ) const

Determines if this message has been deferred, i.e.

placed in a defer queue.

Returns
1 if yes, 0 if no.

◆ isRTData()

int RTMessage::isRTData ( void  ) const

Determines if the message carries a data object which is an RTDataObject.

Mainly provided for backwards compatibility.

Returns
1 if yes, 0 if no.

◆ isValid()

int RTMessage::isValid ( void  ) const

A message is considered valid as soon as its protocol event (i.e.

signal id) has been setup.

Returns
1 if the message has a protocol event setup, 0 otherwise.

◆ receiver()

RTActor * RTMessage::receiver ( void  ) const

Return the currently set receiver for the message.

Returns
The capsule instance set-up as the receiver of the message.

◆ resetDeferred()

void RTMessage::resetDeferred ( void  )

Mark this message as not deferred.

This function is called internally by the TargetRTS and there is usually no need to call it directly.

◆ sap()

RTProtocol * RTMessage::sap ( void  ) const

Return the capsule port on which this message was received.

Returns
The port on which the message was received, or NULL if it was not yet received.

◆ sapId()

int RTMessage::sapId ( void  ) const

Return the id of the capsule port on which this message was received.

Returns
The id of the port on which the message was received, or NULL if it was not yet received.

◆ sapIndex()

int RTMessage::sapIndex ( void  ) const

Return the index (1-based) of the replicated port on which this message was received.

It's for example useful to get this index if you want to send a message back to the sender.

Returns
The 1-based index of the port on which the message was received.

◆ sapIndex0()

int RTMessage::sapIndex0 ( void  ) const

Return the index (0-based) of the replicated port on which this message was received.

It's for example useful to get this index if you want to send a message back to the sender.

Returns
The 0-based index of the port on which the message was received.

◆ setData() [1/2]

void RTMessage::setData ( const RTDataObject data)

Set the data object of the message.

Parameters
[in]dataData object.

◆ setData() [2/2]

void RTMessage::setData ( const void *  data,
const RTObject_class type 
)

Set the data object of the message.

Parameters
[in]dataData object.
[in]typeType descriptor of the data object.

◆ setDeferred()

void RTMessage::setDeferred ( void  )

Mark this message as deferred.

This function is called internally by the TargetRTS and there is usually no need to call it directly.

◆ setDestination()

void RTMessage::setDestination ( RTActor cap,
RTProtocol port,
int  index 
)

Set the destination (i.e.

receiver) of the message. This function is called by the TargetRTS when a message is sent, and it's normally not useful to call it directly.

Parameters
[in]capReceiver capsule instance.
[in]portThe receiver port on the capsule instance to which the message is sent.
[in]indexThe 0-based index of the receiver port (in case it is replicated).

◆ setPriority()

void RTMessage::setPriority ( int  prio)

Set the priority of the message.

See RTPriority.h for a list of valid message priorities.

Parameters
[in]prioPriority for the message.

◆ setSignal()

void RTMessage::setSignal ( int  id)

Set the signal id of the message, i.e.

the id of its the protocol event.

Parameters
[in]idNumeric id of the protocol event of the message.

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