C++ TargetRTS
Loading...
Searching...
No Matches
RTMessage.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTMessage_h__
11#define __RTMessage_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTTimespec_h__
18#include <RTTimespec.h>
19#endif
20
21class RTActor;
22class RTController;
23class RTDataObject;
24struct RTObject_class;
25class RTProtocol;
26struct RTTypedValue;
27
33{
34public: // these really should be private
35 RTMessage * next;
36
37#if OTRTSDEBUG != DEBUG_NONE
38 int _sendPortId;
39 int _sendPortIndex;
40 int _sendProbeId;
41 RTTimespec _sendTime;
42#endif
43
44public:
45 union
46 {
47 void * data;
48 const void * const_data;
49 };
50 short signal;
51 unsigned char priority;
52
53protected:
54 unsigned char _flags;
55 RTActor * _receiver;
56 RTProtocol * _port;
57 int _portIndex;
58 const RTObject_class * _type;
59
60#if RTMESSAGE_PAYLOAD_SIZE != 0
61 // space for a small amount of data
62 union
63 {
64 char _data_area[ RTMESSAGE_PAYLOAD_SIZE ];
65 RTAlignment _alignment;
66 };
67#endif
68
69 void _internData( bool moveData );
70
71 enum
72 {
73 MaskDeferred = 1,
74 MaskDataOwned = 2
75 };
76
77public:
82 RTS_INLINE void clear( void );
83
84 RTS_INLINE RTMessage( void );
85 RTMessage( const RTMessage & );
86
87 RTS_INLINE ~RTMessage( void );
88
93 RTS_INLINE int isRTData( void ) const;
94
98 RTS_INLINE void setDeferred( void );
99
103 RTS_INLINE void resetDeferred( void );
104
108 RTS_INLINE int isDeferred( void ) const;
109
110 RTS_INLINE void setInvalid( void );
111
115 RTS_INLINE int isValid( void ) const;
116
120 RTS_INLINE void setSignal( int id);
121
125 RTS_INLINE int getSignal( void ) const;
126
130 const char * getSignalName( void ) const;
131
135 RTS_INLINE void setPriority( int prio);
136
140 RTS_INLINE int getPriority( void ) const;
141
145 RTS_INLINE void * getData( void ) const;
146
151 RTS_INLINE void setData( const void * data, const RTObject_class * type);
152
156 RTS_INLINE void setData( const RTDataObject & data);
157
161 RTS_INLINE void internData( bool moveData = false );
162
166 RTS_INLINE const RTObject_class * getType( void ) const;
167
171 RTS_INLINE RTProtocol * sap( void ) const;
172
177 int sapId( void ) const;
178
183 RTS_INLINE int sapIndex0( void ) const;
184
189 RTS_INLINE int sapIndex( void ) const;
190
191 enum DeliverResult
192 {
193 Accepted
194 , Deferred
195 , Rejected // signal or type invalid
196 };
197
202 DeliverResult deliver( void );
203
204 RTMessage & operator=( const RTMessage & );
205
210 int defer( void ) const;
211
218 RTS_INLINE void setDestination( RTActor * cap, RTProtocol * port, int index);
219
223 RTS_INLINE RTActor * receiver( void ) const;
224
228 RTS_INLINE RTController * context( void ) const;
229};
230
231#if RTS_INLINES
232#include <RTMessage.inl>
233#endif
234
235#endif // __RTMessage_h__
An instance of this class represents a capsule instance.
Definition: RTActor.h:44
A controller manages a group of capsule instances that all run in the same physical thread (i....
Definition: RTController.h:54
Provides a common interface to certain data type implementations (e.g.
Definition: RTDataObject.h:33
Represents a message used for communication between capsule instances.
Definition: RTMessage.h:33
void setSignal(int id)
Set the signal id of the message, i.e.
Definition: RTMessage.inl:131
int isRTData(void) const
Determines if the message carries a data object which is an RTDataObject.
Definition: RTMessage.inl:100
DeliverResult deliver(void)
Attempt to deliver the message to its specified receiver.
const char * getSignalName(void) const
Get the signal name of the message, i.e.
void setPriority(int prio)
Set the priority of the message.
Definition: RTMessage.inl:141
const RTObject_class * getType(void) const
Get the type of the data object of the message, if any.
Definition: RTMessage.inl:151
RTController * context(void) const
Return the controller of the message receiver.
Definition: RTActor.inl:140
void internData(bool moveData=false)
Intern the data object of the message.
Definition: RTMessage.inl:173
void resetDeferred(void)
Mark this message as not deferred.
Definition: RTMessage.inl:111
RTActor * receiver(void) const
Return the currently set receiver for the message.
Definition: RTMessage.inl:188
int defer(void) const
Defer the message by placing it in the defer queue.
void clear(void)
Destroy the data object stored in the message, and reset the message object to make it ready to be us...
Definition: RTMessage.inl:59
void setDeferred(void)
Mark this message as deferred.
Definition: RTMessage.inl:106
RTProtocol * sap(void) const
Return the capsule port on which this message was received.
Definition: RTMessage.inl:193
int getSignal(void) const
Get the signal id of the message, i.e.
Definition: RTMessage.inl:136
void setData(const void *data, const RTObject_class *type)
Set the data object of the message.
Definition: RTMessage.inl:161
void * getData(void) const
Get the data object carried by the message, if any.
Definition: RTMessage.inl:156
int sapIndex0(void) const
Return the index (0-based) of the replicated port on which this message was received.
Definition: RTMessage.inl:198
int sapId(void) const
Return the id of the capsule port on which this message was received.
Definition: RTMessage.inl:208
int isDeferred(void) const
Determines if this message has been deferred, i.e.
Definition: RTMessage.inl:116
int sapIndex(void) const
Return the index (1-based) of the replicated port on which this message was received.
Definition: RTMessage.inl:203
int getPriority(void) const
Get the priority of the message.
Definition: RTMessage.inl:146
int isValid(void) const
A message is considered valid as soon as its protocol event (i.e.
Definition: RTMessage.inl:121
void setDestination(RTActor *cap, RTProtocol *port, int index)
Set the destination (i.e.
Definition: RTMessage.inl:179
Represents a general capsule port typed by a protocol which determines the set of events that can be ...
Definition: RTProtocol.h:50
A type descriptor providing information about a type.
Definition: RTObject_class.h:64
A time value which can represent either an absolute or relative time.
Definition: RTTimespec.h:29
Encapsulates a data object and its type descriptor.
Definition: RTTypedValue.h:29