rad  5.1.0
Public Types | Public Member Functions | List of all members
scxml4cpp::State Class Reference

#include <State.h>

Inheritance diagram for scxml4cpp::State:
scxml4cpp::StateAtomic scxml4cpp::StateCompound scxml4cpp::StateHistory scxml4cpp::StateParallel

Public Types

enum  StateType { Atomic = 0 , Compound , Parallel , History }
 

Public Member Functions

 State (const std::string &id, const StateType type)
 
virtual ~State ()
 
std::string getId () const
 
StateType getType () const
 
StategetParent ()
 
StateHistorygetHistory ()
 
ExecutableContentgetEntryActions ()
 
ExecutableContentgetExitActions ()
 
std::list< Transition * > & getInitialTrans ()
 
StategetInitialState ()
 
std::list< State * > & getSubstates ()
 
std::list< Transition * > & getTransitions ()
 
std::list< Activity * > & getActivities ()
 
void setId (const std::string &id)
 
void setParent (State *parent)
 
void setIsInitial (const bool isInitial)
 
void setIsFinal (const bool isFinal)
 
void setHistory (StateHistory *h)
 
void setInitialState (State *initialState, Action *a)
 
void setFinalState (State *finalState)
 
void setSubstates (std::list< State * > &substates)
 
void setTransitions (std::list< Transition * > &transitions)
 
void setActivities (std::list< Activity * > &activities)
 
bool isInitial ()
 
bool isFinal ()
 
bool isCompound ()
 
bool isParallel ()
 
bool isAtomic ()
 
bool isHistory ()
 
void startActivities (Context *c)
 
void cancelActivities (Context *c)
 
void addEntryAction (Action *a)
 
void addExitAction (Action *a)
 
void addSubstate (State *s)
 
void addTransition (std::list< State * > &targets, const Event &event, Action *condition, Action *action)
 
void addTransition (State *target, const Event &event, Action *condition, Action *action)
 
void addActivity (Activity *activity)
 
void delTransitions ()
 
void delInitialTrans ()
 
void delSubstates ()
 

Detailed Description

This class is the base class for the different types of SCXML states:

Member Enumeration Documentation

◆ StateType

Enumerator
Atomic 
Compound 

A state that has no sub-states.

Parallel 

A state that can have sub-states.

History 

A state that can have active concurrently sub-states.

A pseudo-state that points to state entered in the past.

Constructor & Destructor Documentation

◆ State()

State::State ( const std::string &  id,
const StateType  type 
)

Constructor for the State object. It allocates memory for:

◆ ~State()

State::~State ( )
virtual

Destructor for the State object. It releases the memory for:

  • entry ExecutableContent (entry actions) allocated in the constructor.
  • exit ExecutableContent (exit actions) allocated in the constructor.
  • any added sub-state
  • any added transition
  • any added initial transition

Member Function Documentation

◆ addActivity()

void State::addActivity ( Activity activity)

Add a do-activity to the list of activities to be started when entering this state and stopped when exiting this state.

Parameters
activityActivity to be added.

◆ addEntryAction()

void State::addEntryAction ( Action a)

Add an entry action to what has to be executed (ExecutableContent) when entering this state.

Parameters
aEntry action to be added.

◆ addExitAction()

void State::addExitAction ( Action a)

Add an exit action to what has to be executed (ExecutableContent) when exiting this state.

Parameters
aExit action to be added.

◆ addSubstate()

void State::addSubstate ( State s)

Add a sub-state.

Parameters
sState to be added.

◆ addTransition() [1/2]

void State::addTransition ( State target,
const Event event,
Action condition,
Action action 
)

Add a transition that has this state as source. This method allocates memory which is released by the destructor/delTransitions() methods.

Parameters
targetsTarget state of the transition. If the pointer is NULL the transition is considered as internal transition (i.e. a transition that does not trigger any change of state).
eventEvent triggering the transition. The event can be a NULL event, in this case the transition it taken immediately after entering the state assuming the condition (guard) is satisfied.
conditionOptional guard to be satisfied for the transition to be taken. By passing NULL, no condition is evaluated.
actionOptional action to be executed when the transition is taken. By passing NULL, no action is evaluated.

◆ addTransition() [2/2]

void State::addTransition ( std::list< State * > &  targets,
const Event event,
Action condition,
Action action 
)

Add a transition that has this state as source. This method allocates memory which is released by the destructor/delTransitions() methods.

Parameters
targetsOne or more target state of the transition. If the list is empty the transition is considered as internal transition (i.e. a transition that does not trigger any change of state).
eventEvent triggering the transition. The event can be a NULL event, in this case the transition it taken immediately after entering the state assuming the condition (guard) is satisfied.
conditionOptional guard to be satisfied for the transition to be taken. By passing NULL, no condition is evaluated.
actionOptional action to be executed when the transition is taken. By passing NULL, no action is evaluated.

◆ cancelActivities()

void State::cancelActivities ( Context c)

Terminates the do-activities associated to this state.

Parameters
cContext passed to the do-activities when stopped.

◆ delInitialTrans()

void State::delInitialTrans ( )

Deletes all added Initial Transitions.

◆ delSubstates()

void State::delSubstates ( )

Deletes all added sub-states.

◆ delTransitions()

void State::delTransitions ( )

Deletes all added Transitions.

◆ getActivities()

std::list< Activity * > & State::getActivities ( )
Returns
The list of do-activities (invoke) if available.

◆ getEntryActions()

ExecutableContent * State::getEntryActions ( )
Returns
The entry actions.

◆ getExitActions()

ExecutableContent * State::getExitActions ( )
Returns
The exit actions.

◆ getHistory()

StateHistory * State::getHistory ( )
Returns
The history info if available, NULL otherwise.

◆ getId()

std::string State::getId ( ) const
Returns
The state identifier.

◆ getInitialState()

State * State::getInitialState ( )
Returns
The initial state if available. The initial state may be available only in case of compound states.

◆ getInitialTrans()

std::list< Transition * > & State::getInitialTrans ( )
Returns
The initial transitions.

◆ getParent()

State * State::getParent ( )
Returns
The parent state or NULL if this state is a top state.

◆ getSubstates()

std::list< State * > & State::getSubstates ( )
Returns
The list of sub-states.

◆ getTransitions()

std::list< Transition * > & State::getTransitions ( )
Returns
The list of transitions that have this state as source state.

◆ getType()

State::StateType State::getType ( ) const
Returns
The type of state.

◆ isAtomic()

bool State::isAtomic ( )
Returns
true if this is an Atomic state, false otherwise.

◆ isCompound()

bool State::isCompound ( )
Returns
true if this is a Compound state, false otherwise.

◆ isFinal()

bool State::isFinal ( )
Returns
true if this is an final state, false otherwise.

◆ isHistory()

bool State::isHistory ( )
Returns
true if this is a History state, false otherwise.

◆ isInitial()

bool State::isInitial ( )
Returns
true if this is an initial state, false otherwise.

◆ isParallel()

bool State::isParallel ( )
Returns
true if this is a Parallel state, false otherwise.

◆ setActivities()

void State::setActivities ( std::list< Activity * > &  activities)

Set all do-activities for this state.

Parameters
activitiesActivities started/stopped when entering/exiting this state.

◆ setFinalState()

void State::setFinalState ( State finalState)

Set the final state.

Parameters
finalStateSub-state to enter when this Compound state is entered.

◆ setHistory()

void State::setHistory ( StateHistory h)

Set history information. TODO check whether this pointer needs to be released by the destructor.

Parameters
hHistory information.

◆ setId()

void State::setId ( const std::string &  id)

Set the state identifier.

Parameters
idState identifier.

◆ setInitialState()

void State::setInitialState ( State initialState,
Action a 
)

Creates an initial transition that is taken when entering this (Compound) state. This method allocates the memory for the initial transition which is released by the destructor/delInitialTrans() methods.

Parameters
initialStateSub-state to enter when this Compound state is entered.
aAction to be executed when transitioning to the initial state.

◆ setIsFinal()

void State::setIsFinal ( const bool  isFinal)

Set whether the state is final or not.

Parameters
isFinalFlag indicating whether this state is final or not.

◆ setIsInitial()

void State::setIsInitial ( const bool  isInitial)

Set whether the state is initial or not.

Parameters
isInitialFlag indicating whether this state is initial or not.

◆ setParent()

void State::setParent ( State parent)

Set the parent state.

Parameters
parentParent state of this state.

◆ setSubstates()

void State::setSubstates ( std::list< State * > &  substates)

Set all sub-states of this state.

Parameters
substatesSub-states to be added.

◆ setTransitions()

void State::setTransitions ( std::list< Transition * > &  transitions)

Set all transitions that have this state as source state.

Parameters
transitionsOutgoing transitions from this state.

◆ startActivities()

void State::startActivities ( Context c)

Starts the do-activities associated to this state.

Parameters
cContext passed to the do-activities when started.

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