C++ TargetRTS
|
An instance of this class represents a capsule instance. More...
#include <RTActor.h>
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. | |
RTActorRef * | getReference (void) const |
Get the capsule part that contains this capsule instance (the capsule part where it was incarnated). | |
const RTMessage * | getMsg (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. | |
RTController * | context (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_class * | getActorData (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 RTActorClass * | defaultClass (RTActorRef &component, int repIndex) |
Get the default capsule class for a capsule part contained in the capsule instance. | |
virtual RTController * | defaultController (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 RTMessage * | msg |
The message which is currently being processed by the capsule instance. | |
RTActorProbe * | probe |
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 |
An instance of this class represents a capsule instance.
All classes that are generated for capsules inherit from this class.
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.
RTController * RTActor::context | ( | void | ) | const |
Get the controller which runs this capsule instance.
|
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.
[in] | component | A capsule part of the capsule instance. |
[in] | repIndex | The index within the capsule part where the Frame service will insert the capsule instance to be created. It is unused in the default implementation. |
|
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.
[in] | component | A capsule part of the capsule instance. |
[in] | repIndex | The index within the capsule part where the Frame service will insert the capsule instance to be created. It is unused in the default implementation. |
|
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.
Implemented in RTSuperActor, and RTTimerActor.
int RTActor::getCurrentState | ( | void | ) | const |
Get the numeric id of the currently active state in the capsule state machine.
const char * RTActor::getCurrentStateString | ( | void | ) | const |
Get the name of the currently active state in the capsule state machine.
|
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.
int RTActor::getHistory | ( | int | s | ) | const |
Get the numeric id of the previously active state in the capsule state machine.
int RTActor::getId | ( | void | ) | const |
Get the numeric id for the capsule part that contains this capsule instance.
int RTActor::getIndex | ( | void | ) | const |
Get the index of this capsule instance in its container capsule part (the capsule part where it was incarnated).
const RTMessage * RTActor::getMsg | ( | void | ) |
Get the message which is currently being processed by the capsule instance.
const char * RTActor::getName | ( | void | ) | const |
Get the name of the capsule part that contains this capsule instance.
int RTActor::getNumStates | ( | void | ) | const |
Get the number of states in the capsule state machine.
RTActorRef * RTActor::getReference | ( | void | ) | const |
Get the capsule part that contains this capsule instance (the capsule part where it was incarnated).
const char * RTActor::getStateString | ( | int | s | ) | const |
Get the name of one of the states in the capsule state machine.
[in] | s | The numeric identifier of a state. |
const char * RTActor::getTypeName | ( | void | ) | const |
Get the name of the capsule.
int RTActor::index | ( | void | ) | const |
Get the index of this capsule instance in its container capsule part (the capsule part where it was incarnated).
int RTActor::isActive | ( | void | ) | const |
Determines if this capsule instance is currently active, i.e.
is processing a message.
int RTActor::isSameType | ( | const RTActorClass * | cap | ) | const |
Determines if the type of this capsule instance is a particular capsule type.
[in] | cap | A capsule type. |
int RTActor::isType | ( | const char * | str | ) | const |
Performs a lexical comparison between the name of the capsule with a specified string.
[in] | str | A string to compare the capsule name with. |
|
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.
|
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.
|
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.
[in] | origin | Identifies the start point of the chain. Numbers from 1 to getNumStates(), inclusive, refer to states, larger numbers refer to choice-points. |
[in] | trans | The name of the transition. |
|
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.
|
pure virtual |
Defines the state machine behavior for this capsule instance.
This function is implemented in each concrete capsule subclass.
[in] | signal | The event of the currently processed message. |
[in] | port | The port on which the currently processed message arrived. |
Implemented in RTSuperActor, and RTTimerActor.
|
protected |
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.
[in] | msg | A message (typically the one currently being processed by the capsule instance). |
|
protected |
Force the state machine of the capsule instance into a particular state.
[in] | s | The 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. |
|
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.
|
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.
|
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.