C++ TargetRTS
Loading...
Searching...
No Matches
RTActor.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 __RTActor_h__
11#define __RTActor_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTController_h__
18#include <RTController.h>
19#endif
20
21#ifndef __RTVersionId_h__
22#include <RTVersionId.h>
23#endif
24
25struct RTActorClass;
26class RTActorProbe;
27class RTActorRef;
28struct RTActor_class;
29struct RTBindingEnd;
31class RTDebugger;
32union RTImportList;
33class RTMessage;
34struct RTObject_class;
35class RTProtocol;
36class RTRelayPort;
37
44{
45 friend class RTActorRef;
46 friend class RTController;
47 friend class RTDebugger;
48 friend class RTMessage;
49 friend class RTProtocol;
50
51private: // instance data
52 RTController * rts;
53 RTActorRef * homeReference;
54 int homeIndex;
55 RTRelayPort * relays;
56#if DEFER_IN_ACTOR
57 RTMessageQ deferredQ;
58#endif
59#if SUSPEND
60 RTMessage * suspendMsgs; // stack of messages which arrived while the actor was suspended
61#endif
62
63 RTImportList * importList;
64
65 struct State
66 {
67 RTStateId current;
68#if RTStateId_MaxSize > 1
69 unsigned char idShift; // log2( log256( getNumStates() ) )
70#endif
71 union
72 {
73 unsigned char s1[ 1 ];
74#if RTStateId_MaxSize > 1
75 unsigned short s2[ 1 ];
76#endif
77#if RTStateId_MaxSize > 2
78 unsigned int s4[ 1 ];
79#endif
80 } history;
81 };
82
83 State * state;
84
85public: // instance data
86
88 const RTMessage * msg;
89
90#if OBSERVABLE
93#endif
94
95protected: // functions
96
98 RTS_INLINE void saveHistory( void );
99
105 RTS_INLINE void setCurrentState( int s);
106
115 virtual void unhandledMessage( void );
116
122 virtual void unexpectedMessage( void );
123
131
137 void unexpectedState( void );
138
139#if ! OBSERVABLE
140 RTS_INLINE
141#endif
151 void rtgChainBegin( int origin, const char * trans );
152
153#if ! OBSERVABLE
154 RTS_INLINE
155#endif
157 void rtgTransitionBegin( void );
158
159#if ! OBSERVABLE
160 RTS_INLINE
161#endif
163 void rtgTransitionEnd( void );
164
165 void enterState( int );
166 virtual void enterStateV( void );
167
175 virtual void rtgStateEntry( void );
176
177 void exitState( const RTStateId parent[] );
178 virtual void exitStateV( void );
179 void processHistory( void );
180 void exitToChainState( int, const RTStateId parent[] );
181
182 void initializeAll( void );
183
184 int removeImport( RTActorRef * ,RTController * initiator );
185 void removeAllImports( RTController * initiator );
186
187 int _followIn( RTBindingEnd & end,
188 int portId,
189 int repIndex,
190 RTActorRef * importer );
191
192 int _followOut( RTBindingEnd & end,
193 int portId,
194 int repIndex );
195
196 void _unbind( RTActorRef * importer ,RTController* initiator);
197 virtual void _predestroy( void );
198
199public: // functions
200
206
207 virtual ~RTActor( void );
208
213 RTS_INLINE int getIndex( void ) const;
214
219 RTS_INLINE int index( void ) const;
220
224 RTS_INLINE int getId( void ) const;
225
230 const char * getName( void ) const;
231
236 RTS_INLINE RTActorRef * getReference( void ) const;
237
241 RTS_INLINE const RTMessage * getMsg( void );
242
249 RTS_INLINE int sendCopyToMe ( const RTMessage* msg );
250
256 virtual void rtsBehavior( int signal, int port ) = 0;
257
258#if LOG_MESSAGE
263 virtual void logMsg( void );
264#endif
265
269 RTS_INLINE RTController * context( void ) const;
270
274 RTS_INLINE int isActive( void ) const;
275
276 virtual int designLevel( void ) const;
277
281 RTS_INLINE const char * getTypeName( void ) const;
282
283 RTS_INLINE RTVersionId getVersion( void ) const;
284
289 RTS_INLINE int isSameType( const RTActorClass * cap) const;
290
296 int isType( const char * str) const;
297
298#if SUSPEND
299 void suspend( void );
300 void resume( void );
301 RTS_INLINE int isSuspended( void ) const;
302#endif
303
308 virtual const RTActor_class * getActorData( void ) const = 0;
309
313 int getNumStates( void ) const;
314
320 const char * getStateString( int s) const;
321
325 const char * getCurrentStateString( void ) const;
326
330 RTS_INLINE int getCurrentState( void ) const;
331
335 RTS_INLINE int getHistory( int ) const;
336
337 int _numComponents( void ) const;
338 RTActorRef * _component( int compId );
339
340 void _preinitialize( int _homeIndex,
341 const RTComponentDescriptor * );
342 int initMe( const void * data,
343 const RTObject_class * type,
344 RTController * sender );
345
346#if RTIMPORT_ISREFERENCEDBY_CHECK
347 int isReferencedBy( const RTActor * ) const;
348#endif
349
359 virtual const RTActorClass * defaultClass( RTActorRef & component,
360 int repIndex );
361
373 int repIndex );
374
375 void _incarnateAllFixed( void );
376
377 // The functions below are generated by the toolset.
378 virtual int _followOutV( RTBindingEnd & end,
379 int compId,
380 int portId,
381 int portIndex );
382
383 // This function is simply inherited unless the actor has additional
384 // (interface) ports or has excluded ports of its superclass.
385 virtual int _followInV( RTBindingEnd & end,
386 int portId,
387 int repIndex );
388
389protected:
396 RTS_INLINE RTController::Error getError( void ) const;
397
398private:
399 // unavailable methods
400 RTActor( const RTActor & );
401 RTActor & operator=( const RTActor & );
402}; //lint !e1712
403
404#if RTS_INLINES
405#include <RTActor.inl>
406#endif
407
408#endif // __RTActor_h__
An instance of this class represents a capsule instance.
Definition: RTActor.h:44
const char * getTypeName(void) const
Get the name of the capsule.
Definition: RTActor.inl:110
virtual const RTActorClass * defaultClass(RTActorRef &component, int repIndex)
Get the default capsule class for a capsule part contained in the capsule instance.
void rtgTransitionEnd(void)
This function is called just after a user-defined transition effect has executed.
int getNumStates(void) const
Get the number of states in the capsule state machine.
void setCurrentState(int s)
Force the state machine of the capsule instance into a particular state.
Definition: RTActor.inl:95
const char * getStateString(int s) const
Get the name of one of the states in the capsule state machine.
int isType(const char *str) const
Performs a lexical comparison between the name of the capsule with a specified string.
void rtgTransitionBegin(void)
This function is called just before a user-defined transition effect executes.
void unexpectedState(void)
This function is called if the TargetRTS detects that the state machine of the capsule instance in in...
int isActive(void) const
Determines if this capsule instance is currently active, i.e.
Definition: RTActor.inl:125
int getCurrentState(void) const
Get the numeric id of the currently active state in the capsule state machine.
Definition: RTActor.inl:37
virtual void logMsg(void)
This function is called just before a received message is processed by the capsule instance.
virtual void unhandledMessage(void)
This function is called when a message is dispatched to a capsule instance, but it isn't handled by i...
const char * getName(void) const
Get the name of the capsule part that contains this capsule instance.
RTActorProbe * probe
A probe attached to the capsule instance for monitoring it.
Definition: RTActor.h:92
void rtgChainBegin(int origin, const char *trans)
This function is called at the beginning of every generated chain function that corresponds to a tran...
const RTMessage * msg
The message which is currently being processed by the capsule instance.
Definition: RTActor.h:88
const RTMessage * getMsg(void)
Get the message which is currently being processed by the capsule instance.
Definition: RTActor.inl:100
int getIndex(void) const
Get the index of this capsule instance in its container capsule part (the capsule part where it was i...
Definition: RTActor.inl:65
virtual const RTActor_class * getActorData(void) const =0
Get information (meta data) about the capsule, such as its name, ports, states etc.
RTController::Error getError(void) const
Get the most recent error that occurred when using the TargetRTS.
Definition: RTActor.inl:145
void saveHistory(void)
Definition: RTActor.inl:75
RTActor(RTController *, RTActorRef *)
Constructor.
virtual void messageReceivedBeforeInitialized(void)
This function is called if a message is dispatched to the capsule instance, before its initial transi...
int index(void) const
Get the index of this capsule instance in its container capsule part (the capsule part where it was i...
Definition: RTActor.inl:70
virtual RTController * defaultController(RTActorRef &component, int repIndex)
Get the default controller for a capsule part contained in the capsule instance.
virtual void rtsBehavior(int signal, int port)=0
Defines the state machine behavior for this capsule instance.
RTActorRef * getReference(void) const
Get the capsule part that contains this capsule instance (the capsule part where it was incarnated).
Definition: RTActor.inl:55
int getHistory(int) const
Get the numeric id of the previously active state in the capsule state machine.
Definition: RTActor.inl:42
const char * getCurrentStateString(void) const
Get the name of the currently active state in the capsule state machine.
virtual void unexpectedMessage(void)
This function is called when a message is dispatched to the capsule instance, and when there is no en...
int isSameType(const RTActorClass *cap) const
Determines if the type of this capsule instance is a particular capsule type.
Definition: RTActor.inl:120
int sendCopyToMe(const RTMessage *msg)
Make a copy of a message and send it to this capsule instance.
Definition: RTActor.inl:105
RTController * context(void) const
Get the controller which runs this capsule instance.
Definition: RTActor.inl:130
virtual void rtgStateEntry(void)
This function is called when the state machine of the capsule instance enters a new state.
int getId(void) const
Get the numeric id for the capsule part that contains this capsule instance.
Definition: RTActor.inl:60
Definition: RTActorProbe.h:31
Represents a capsule part.
Definition: RTActorRef.h:39
A controller manages a group of capsule instances that all run in the same physical thread (i....
Definition: RTController.h:54
Definition: RTDebugger.h:58
Represents a message used for communication between capsule instances.
Definition: RTMessage.h:33
Represents a message queue.
Definition: RTMessageQ.h:27
Represents a general capsule port typed by a protocol which determines the set of events that can be ...
Definition: RTProtocol.h:50
Definition: RTRelayPort.h:27
Definition: RTActor_class.h:49
A type descriptor providing information about the external characteristics of a capsule.
Definition: RTActorClass.h:36
Definition: RTBindingEnd.h:24
This structure describes a capsule part (a.k.a.
Definition: RTComponentDescriptor.h:33
A type descriptor providing information about a type.
Definition: RTObject_class.h:64
Definition: RTImportList.h:35