C++ TargetRTS
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Friends | List of all members
RTActor Class Referenceabstract

An instance of this class represents a capsule instance. More...

#include <RTActor.h>

Inheritance diagram for RTActor:
RTConnector_Actor RTSuperActor RTTimerActor

Public Member Functions

 RTActor (RTController *, RTActorRef *)
 Constructor.
 
int getIndex (void) const
 Get the index of this capsule instance in its container capsule part (the capsule part where it was incarnated).
 
int index (void) const
 Get the index of this capsule instance in its container capsule part (the capsule part where it was incarnated).
 
int getId (void) const
 Get the numeric id for the capsule part that contains this capsule instance.
 
const char * getName (void) const
 Get the name of the capsule part that contains this capsule instance.
 
RTActorRefgetReference (void) const
 Get the capsule part that contains this capsule instance (the capsule part where it was incarnated).
 
const RTMessagegetMsg (void)
 Get the message which is currently being processed by the capsule instance.
 
int sendCopyToMe (const RTMessage *msg)
 Make a copy of a message and send it to this capsule instance.
 
virtual void rtsBehavior (int signal, int port)=0
 Defines the state machine behavior for this capsule instance.
 
virtual void logMsg (void)
 This function is called just before a received message is processed by the capsule instance.
 
RTControllercontext (void) const
 Get the controller which runs this capsule instance.
 
int isActive (void) const
 Determines if this capsule instance is currently active, i.e.
 
virtual int designLevel (void) const
 
const char * getTypeName (void) const
 Get the name of the capsule.
 
RTVersionId getVersion (void) const
 
int isSameType (const RTActorClass *cap) const
 Determines if the type of this capsule instance is a particular capsule type.
 
int isType (const char *str) const
 Performs a lexical comparison between the name of the capsule with a specified string.
 
virtual const RTActor_classgetActorData (void) const =0
 Get information (meta data) about the capsule, such as its name, ports, states etc.
 
int getNumStates (void) const
 Get the number of states in the capsule state machine.
 
const char * getStateString (int s) const
 Get the name of one of the states in the capsule state machine.
 
const char * getCurrentStateString (void) const
 Get the name of the currently active state in the capsule state machine.
 
int getCurrentState (void) const
 Get the numeric id of the currently active state in the capsule state machine.
 
int getHistory (int) const
 Get the numeric id of the previously active state in the capsule state machine.
 
int _numComponents (void) const
 
RTActorRef_component (int compId)
 
void _preinitialize (int _homeIndex, const RTComponentDescriptor *)
 
int initMe (const void *data, const RTObject_class *type, RTController *sender)
 
int isReferencedBy (const RTActor *) const
 
virtual const RTActorClassdefaultClass (RTActorRef &component, int repIndex)
 Get the default capsule class for a capsule part contained in the capsule instance.
 
virtual RTControllerdefaultController (RTActorRef &component, int repIndex)
 Get the default controller for a capsule part contained in the capsule instance.
 
void _incarnateAllFixed (void)
 
virtual int _followOutV (RTBindingEnd &end, int compId, int portId, int portIndex)
 
virtual int _followInV (RTBindingEnd &end, int portId, int repIndex)
 

Public Attributes

const RTMessagemsg
 The message which is currently being processed by the capsule instance.
 
RTActorProbeprobe
 A probe attached to the capsule instance for monitoring it.
 

Protected Member Functions

void saveHistory (void)
 
void setCurrentState (int s)
 Force the state machine of the capsule instance into a particular state.
 
virtual void unhandledMessage (void)
 This function is called when a message is dispatched to a capsule instance, but it isn't handled by its state machine.
 
virtual void unexpectedMessage (void)
 This function is called when a message is dispatched to the capsule instance, and when there is no enabled transition in the current state that can be triggered to handle the received message.
 
virtual void messageReceivedBeforeInitialized (void)
 This function is called if a message is dispatched to the capsule instance, before its initial transition has executed.
 
void unexpectedState (void)
 This function is called if the TargetRTS detects that the state machine of the capsule instance in in an invalid state (i.e.
 
void rtgChainBegin (int origin, const char *trans)
 This function is called at the beginning of every generated chain function that corresponds to a transition in the state machine.
 
void rtgTransitionBegin (void)
 This function is called just before a user-defined transition effect executes.
 
void rtgTransitionEnd (void)
 This function is called just after a user-defined transition effect has executed.
 
void enterState (int)
 
virtual void enterStateV (void)
 
virtual void rtgStateEntry (void)
 This function is called when the state machine of the capsule instance enters a new state.
 
void exitState (const RTStateId parent[])
 
virtual void exitStateV (void)
 
void processHistory (void)
 
void exitToChainState (int, const RTStateId parent[])
 
void initializeAll (void)
 
int removeImport (RTActorRef *, RTController *initiator)
 
void removeAllImports (RTController *initiator)
 
int _followIn (RTBindingEnd &end, int portId, int repIndex, RTActorRef *importer)
 
int _followOut (RTBindingEnd &end, int portId, int repIndex)
 
void _unbind (RTActorRef *importer, RTController *initiator)
 
virtual void _predestroy (void)
 
RTController::Error getError (void) const
 Get the most recent error that occurred when using the TargetRTS.
 

Friends

class RTActorRef
 
class RTController
 
class RTDebugger
 
class RTMessage
 
class RTProtocol
 

Detailed Description

An instance of this class represents a capsule instance.

All classes that are generated for capsules inherit from this class.

See also
RTActorId is a wrapper object around an RTActor pointer and hence also represents a capsule instance

Constructor & Destructor Documentation

◆ RTActor()

RTActor::RTActor ( RTController ,
RTActorRef  
)

Constructor.

Never create a capsule instance directly using the new operator. Always create a capsule instance using Frame::Base::incarnate(), or automatically at start-up by means of fixed capsule parts.

Member Function Documentation

◆ context()

RTController * RTActor::context ( void  ) const

Get the controller which runs this capsule instance.

Returns
The controller object which runs this capsule instance.

◆ defaultClass()

virtual const RTActorClass * RTActor::defaultClass ( RTActorRef component,
int  repIndex 
)
virtual

Get the default capsule class for a capsule part contained in the capsule instance.

This function is used by the Frame service when incarnating capsules without specifying the capsule type. The default implementation just returns the capsule that types the capsule part. You may override the function to use a different capsule as the default capsule class.

Parameters
[in]componentA capsule part of the capsule instance.
[in]repIndexThe index within the capsule part where the Frame service will insert the capsule instance to be created. It is unused in the default implementation.
Returns
The default capsule class for the capsule part.

◆ defaultController()

virtual RTController * RTActor::defaultController ( RTActorRef component,
int  repIndex 
)
virtual

Get the default controller for a capsule part contained in the capsule instance.

This function is used by the Frame service when incarnating capsules without specifying the controller to run the created capsule instance. The default implementation just returns the controller of this capsule instance. You may override the function to use a different controller as the default.

Parameters
[in]componentA capsule part of the capsule instance.
[in]repIndexThe index within the capsule part where the Frame service will insert the capsule instance to be created. It is unused in the default implementation.
Returns
The default controller for the capsule part.

◆ getActorData()

virtual const RTActor_class * RTActor::getActorData ( void  ) const
pure virtual

Get information (meta data) about the capsule, such as its name, ports, states etc.

This information is static and comes from the definition of the capsule.

Returns
Information about the capsule.

Implemented in RTSuperActor, and RTTimerActor.

◆ getCurrentState()

int RTActor::getCurrentState ( void  ) const

Get the numeric id of the currently active state in the capsule state machine.

Returns
The id of the currently active state.

◆ getCurrentStateString()

const char * RTActor::getCurrentStateString ( void  ) const

Get the name of the currently active state in the capsule state machine.

Returns
The name of the currently active state.

◆ getError()

RTController::Error RTActor::getError ( void  ) const
protected

Get the most recent error that occurred when using the TargetRTS.

Call this function immediately after a function has returned with an error code to find out more information about the error that occurred.

Returns
An RTController::Error value describing the error that occurred most recently when using the TargetRTS.

◆ getHistory()

int RTActor::getHistory ( int  s) const

Get the numeric id of the previously active state in the capsule state machine.

Returns
The id of the state that was most previously active.

◆ getId()

int RTActor::getId ( void  ) const

Get the numeric id for the capsule part that contains this capsule instance.

Returns
A numeric id for the container capsule part that is unique within the capsule

◆ getIndex()

int RTActor::getIndex ( void  ) const

Get the index of this capsule instance in its container capsule part (the capsule part where it was incarnated).

Returns
A zero-based index.

◆ getMsg()

const RTMessage * RTActor::getMsg ( void  )

Get the message which is currently being processed by the capsule instance.

Returns
The currently processed message.

◆ getName()

const char * RTActor::getName ( void  ) const

Get the name of the capsule part that contains this capsule instance.

Returns
The name of the container capsule part. For the top capsule instance the string "Top" is returned.

◆ getNumStates()

int RTActor::getNumStates ( void  ) const

Get the number of states in the capsule state machine.

Returns
Number of state machine states.

◆ getReference()

RTActorRef * RTActor::getReference ( void  ) const

Get the capsule part that contains this capsule instance (the capsule part where it was incarnated).

Returns
The container capsule part.

◆ getStateString()

const char * RTActor::getStateString ( int  s) const

Get the name of one of the states in the capsule state machine.

Parameters
[in]sThe numeric identifier of a state.
Returns
The name of the specified state. An error string is returned in case of error (for example if an invalid state id is specified).

◆ getTypeName()

const char * RTActor::getTypeName ( void  ) const

Get the name of the capsule.

Returns
Name of the capsule instance type.

◆ index()

int RTActor::index ( void  ) const

Get the index of this capsule instance in its container capsule part (the capsule part where it was incarnated).

Returns
A 1-based index.

◆ isActive()

int RTActor::isActive ( void  ) const

Determines if this capsule instance is currently active, i.e.

is processing a message.

Returns
1 if the capsule instance is active, 0 otherwise.

◆ isSameType()

int RTActor::isSameType ( const RTActorClass cap) const

Determines if the type of this capsule instance is a particular capsule type.

Parameters
[in]capA capsule type.
Returns
1 if the type of this capsule instance equals the capsule type, 0 otherwise.

◆ isType()

int RTActor::isType ( const char *  str) const

Performs a lexical comparison between the name of the capsule with a specified string.

Parameters
[in]strA string to compare the capsule name with.
Returns
0 if the capsule type name equals the string. A negative or positive value is returned depending on the result of comparing the first character that is different.

◆ logMsg()

virtual void RTActor::logMsg ( void  )
virtual

This function is called just before a received message is processed by the capsule instance.

The default implementation prints a message to the log (depending on the current debug level). Override this function to perform any other general action before a message is processed.

◆ messageReceivedBeforeInitialized()

virtual void RTActor::messageReceivedBeforeInitialized ( void  )
protectedvirtual

This function is called if a message is dispatched to the capsule instance, before its initial transition has executed.

The default behavior is to defer such messages, and recall them when executing the initial transition, to give the capsule instance a chance to handle them. You may override this function to provide a different behavior, for example to call unexpectedMessage() in case you don't expect this scenario to occur.

◆ rtgChainBegin()

void RTActor::rtgChainBegin ( int  origin,
const char *  trans 
)
protected

This function is called at the beginning of every generated chain function that corresponds to a transition in the state machine.

The parameters identifies the start of the transition chain. Note that the first argument is implied by the second, but skipping it would require generation of a mapping table which, on some architectures, could be larger than the code which passes the argument.

Parameters
[in]originIdentifies the start point of the chain. Numbers from 1 to getNumStates(), inclusive, refer to states, larger numbers refer to choice-points.
[in]transThe name of the transition.

◆ rtgStateEntry()

virtual void RTActor::rtgStateEntry ( void  )
protectedvirtual

This function is called when the state machine of the capsule instance enters a new state.

The call is made immediately after the state has become active, before the entry action of that state executes. The default implementation of this function does nothing. The function can be overridden on a capsule that wants to perform some common actions whenever a new state in its state machine becomes active. To override this function, simply add a new operation to the capsule with the same name and prototype.

◆ rtsBehavior()

virtual void RTActor::rtsBehavior ( int  signal,
int  port 
)
pure virtual

Defines the state machine behavior for this capsule instance.

This function is implemented in each concrete capsule subclass.

Parameters
[in]signalThe event of the currently processed message.
[in]portThe port on which the currently processed message arrived.

Implemented in RTSuperActor, and RTTimerActor.

◆ saveHistory()

void RTActor::saveHistory ( void  )
protected
Deprecated:
This function does nothing.

◆ sendCopyToMe()

int RTActor::sendCopyToMe ( const RTMessage msg)

Make a copy of a message and send it to this capsule instance.

This function can for example be used in order to defer the handling of a reply message, or in general where a message cannot be completely handled in a single transition.

Parameters
[in]msgA message (typically the one currently being processed by the capsule instance).
Returns
1 in case the message was successfully copied and sent, 0 otherwise.

◆ setCurrentState()

void RTActor::setCurrentState ( int  s)
protected

Force the state machine of the capsule instance into a particular state.

Parameters
[in]sThe numeric id of a state to be set as the active state. Make sure to pass an id of a valid state, defined in the state machine of the capsule instance. If the state machine is forced into an invalid state, unexpectedState() will be called.

◆ unexpectedMessage()

virtual void RTActor::unexpectedMessage ( void  )
protectedvirtual

This function is called when a message is dispatched to the capsule instance, and when there is no enabled transition in the current state that can be triggered to handle the received message.

The default implementation prints a message to stderr. You may override the function to provide a different behavior.

◆ unexpectedState()

void RTActor::unexpectedState ( void  )
protected

This function is called if the TargetRTS detects that the state machine of the capsule instance in in an invalid state (i.e.

the current state does not match any of the states defined in the capsule state machine). This is an abnormal situation which will cause the application to terminate.

◆ unhandledMessage()

virtual void RTActor::unhandledMessage ( void  )
protectedvirtual

This function is called when a message is dispatched to a capsule instance, but it isn't handled by its state machine.

In most cases this indicates a problem in the application, and a call to unexpectedMessage() will then be performed. However, there is also the scenario where a message is unhandled because it was received before the state machine has been initialized. In that case a call to messageReceivedBeforeInitialized() will be performed instead.


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