rad  5.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | List of all members
scxml4cpp::Helper Class Reference

#include <Helper.h>

Public Member Functions

 Helper ()
 
 ~Helper ()
 
const std::string printStateType (State *s)
 
const std::string printTransition (Transition *t)
 
const std::string printTransitions (std::list< Transition * > &transitions)
 
const std::string printTargetState (Transition *transitions)
 
const std::string printTargetStates (std::list< Transition * > &transitions)
 
const std::string printActions (std::list< Action * > &actions)
 
const std::string printActivities (std::list< Activity * > &activities)
 
const std::string printStates (State *s)
 
const std::string printStateMachine (StateMachine &)
 
const std::string formatStatus (std::set< State * > &status, const bool usefullyqualified=false)
 
const std::string formatStatus (std::list< State * > &status, const bool usefullyqualified=false)
 
bool compareStateDocOrder (State *s1, State *s2)
 
void sortAtomicStates (std::set< State * > &status, std::vector< State * > &sortedStatus)
 
bool isInState (const std::set< State * > &status, const std::list< std::string > &stateNames)
 
bool isInState (const std::list< State * > &status, const std::list< std::string > &stateNames)
 
int countParents (State *s)
 
bool isDescendant (State *s, State *p)
 
std::set< State * > getAncestors (std::list< State * > &states)
 
std::set< State * > getAncestors (State *state)
 
std::list< State * > getAncestorsList (std::set< State * > &states)
 
std::list< State * > getAncestorsList (State *)
 
std::list< State * > getAncestorsList (std::list< State * > &states)
 
std::list< State * > getProperAncestors (State *state, State *upperBound)
 
StatefindLeastCommonAncestor (State *s1, State *s2)
 
bool eventMatch (const Event &e1, const Event &e2)
 
std::list< State * > getAtomicStates (std::set< State * > &states)
 
std::list< State * > getAtomicStates (std::list< State * > &states)
 
bool isPreempted (State *s, std::list< Transition * > &transitions)
 

Static Public Attributes

static const std::string LEAF_STATE_SEPARATOR = ";"
 
static const std::string COMP_STATE_SEPARATOR = "/"
 

Detailed Description

(Very old style) Helper class containing utilities functions. TODO could be replaced by free functions in a name space.

Constructor & Destructor Documentation

◆ Helper()

scxml4cpp::Helper::Helper ( )

Empty constructor.

◆ ~Helper()

scxml4cpp::Helper::~Helper ( )

Empty destructor.

Member Function Documentation

◆ compareStateDocOrder()

bool scxml4cpp::Helper::compareStateDocOrder ( State s1,
State s2 
)

Compare two states considering the location of the states in the SCXML document.

Parameters
s1First state to compare.
s2Second state to compare.
Returns
true if s1 < s2, false otherwise.

Compare the position of states in the model: s1 < s2 if s1 appears in the model before s2.

This practically means that, in the list of substates maintained by the common ancestor, s1 is positioned before s2.

A nullptr is considered to be always before a non-null state.

Parameters
s1First state to compare
s2Second state to compare
Returns
true if s1 < s2, false otherwise
0 if s1 == s2, -1 if s1 < s2, +1 if s1 > s2

◆ countParents()

int scxml4cpp::Helper::countParents ( State s)

Counts the number of parent states (ancestors) of a given state starting from 1. TODO change name to the method.

Parameters
sState given to start counting.
Returns
0 if s is NULL, 1 if s has no parents, N+1 if s has N parents.

This method is used by the StateComparator class to provide a way to compare states based on the number of parents (i.e. level in the state composition tree).

Returns
0 in case of nullptr, 1 in case the state has no parents, or (1 + the number of parents).

◆ eventMatch()

bool scxml4cpp::Helper::eventMatch ( const Event e1,
const Event e2 
)

Checks whether two events match by comparing the identifers and the type.

Parameters
e1First event.
e2Second event.
Returns
true if the two given events match, false otherwise.

◆ findLeastCommonAncestor()

State * scxml4cpp::Helper::findLeastCommonAncestor ( State s1,
State s2 
)

Finds the least common ancestor state of two given states. In other words it looks for the first parent state which is common to both given states.

Parameters
s1First state.
s2Second state.
Returns
the closest parent state which is common to 's1' and 's2'.

◆ formatStatus() [1/2]

const std::string scxml4cpp::Helper::formatStatus ( std::list< State * > &  status,
const bool  usefullyqualified = false 
)

Creates a textual description of the given state.

Parameters
statusList of states.
usefullyqualifiedif false it concatenates the parent states IDs.
Returns
The textual description of the given states.

◆ formatStatus() [2/2]

const std::string scxml4cpp::Helper::formatStatus ( std::set< State * > &  status,
const bool  usefullyqualified = false 
)

Obsolete method replaced by formatStatus() with std::list to retrieve the textual description of the given states. This method does not preserve the document order because the std::set is ordered on the pointer values which depends on the memory allocation.

Parameters
statusSet of states.
usefullyqualifiedif false it concatenates the parent states IDs.
Returns
The textual description of the given states.

◆ getAncestors() [1/2]

std::set< State * > scxml4cpp::Helper::getAncestors ( State state)

Retrieves the ancestor states of a given state.

Parameters
stateState to look for the parents.
Returns
Set of parents of the given 'state'.

◆ getAncestors() [2/2]

std::set< State * > scxml4cpp::Helper::getAncestors ( std::list< State * > &  states)

Retrieves the ancestor states of the given list of states.

Parameters
statesList of states to look for the parents.
Returns
Set of parents of the given 'states'.

◆ getAncestorsList() [1/3]

std::list< State * > scxml4cpp::Helper::getAncestorsList ( State state)

Retrieves the ancestor states of the given state.

Parameters
stateState to look for the parents.
Returns
List of parents of the given 'state'.

◆ getAncestorsList() [2/3]

std::list< State * > scxml4cpp::Helper::getAncestorsList ( std::list< State * > &  states)

Retrieves the ancestor states of the given list of states.

Parameters
statesList of states to look for the parents.
Returns
List of parents of the given 'states'.

◆ getAncestorsList() [3/3]

std::list< State * > scxml4cpp::Helper::getAncestorsList ( std::set< State * > &  states)

Retrieves the ancestor states of the given set of states.

Parameters
statesSet of states to look for the parents.
Returns
List of parents of the given 'states'.

◆ getAtomicStates() [1/2]

std::list< State * > scxml4cpp::Helper::getAtomicStates ( std::list< State * > &  states)

Given a list of states, returns the atomic ones.

Parameters
statesList of states.
Returns
List of atomic states retrieved from the given list.

◆ getAtomicStates() [2/2]

std::list< State * > scxml4cpp::Helper::getAtomicStates ( std::set< State * > &  states)

Given a set of states, returns the atomic ones.

Parameters
statesSet of states.
Returns
List of atomic states retrieved from the given set.

◆ getProperAncestors()

std::list< State * > scxml4cpp::Helper::getProperAncestors ( State state,
State upperBound 
)

Retrieves the 'proper' ancestor states i.e. without the state itself.

Parameters
stateState to look for the parents.
upperBoundfor the search, if NULL it searches till the very top state.
Returns
List of parents of the given 'state'.

◆ isDescendant()

bool scxml4cpp::Helper::isDescendant ( State s,
State p 
)

Checks whether a state 's' descends from 'p'. In other words it checks whether 'p' is a parent of 's'.

Parameters
sState to check.
pSupposed parent state of s.
Returns
true If s descends from p (i.e. s is a child of p or a child of a child ...) or s is NULL, false otherwise.

This method verifies whether a state 's' is descendant from a state 'p'.

Parameters
sState to check.
pSupposed parent state of s.
Returns
true If s descends from p (i.e. s is a child of p or a child of a child ...), false otherwise.

◆ isInState() [1/2]

bool scxml4cpp::Helper::isInState ( const std::list< State * > &  status,
const std::list< std::string > &  stateNames 
)

Check whether the given state identifier(s) are in the given list of states.

Parameters
statusList of states (usually the current active state configuration).
stateNamesList of state identifiers to be checked.

◆ isInState() [2/2]

bool scxml4cpp::Helper::isInState ( const std::set< State * > &  status,
const std::list< std::string > &  stateNames 
)

Check whether the given state identifier(s) are in the given set of states.

Parameters
statusSet of states (usually the current active state configuration).
stateNamesList of state identifiers to be checked.

◆ isPreempted()

bool scxml4cpp::Helper::isPreempted ( State s,
std::list< Transition * > &  transitions 
)

Checks whether there is a transition from the given list that has as source state the given 's' or one of its ancestors.

In this case, taking 't' will pull the state machine out of 's' and we say that it preempts the selection of a transition from 's'. Such preemption will occur only if 's' is a descendant of a parallel region and 't' exits that region. If we did not do this preemption check, we could end up in an illegal configuration, namely one in which there were multiple active states that were not all descendants of a common parallel ancestor.

Parameters
sState to be exited.
transitionsList of transitions to check for preemption.
Returns
true if a transition 't' in 'transitions' exits an ancestor of state 's'.

◆ printActions()

const std::string scxml4cpp::Helper::printActions ( std::list< Action * > &  actions)
Returns
The textual description of the given actions.

◆ printActivities()

const std::string scxml4cpp::Helper::printActivities ( std::list< Activity * > &  activities)
Returns
The textual description of the given activities.

◆ printStateMachine()

const std::string scxml4cpp::Helper::printStateMachine ( StateMachine sm)
Returns
The textual description of the given state machine.

◆ printStates()

const std::string scxml4cpp::Helper::printStates ( State s)
Returns
The textual description of the given state.

◆ printStateType()

const std::string scxml4cpp::Helper::printStateType ( State s)
Returns
The textual description of type of the given state.

◆ printTargetState()

const std::string scxml4cpp::Helper::printTargetState ( Transition transitions)
Returns
The textual description of the given target state.

◆ printTargetStates()

const std::string scxml4cpp::Helper::printTargetStates ( std::list< Transition * > &  transitions)
Returns
The textual description of the given target states.

◆ printTransition()

const std::string scxml4cpp::Helper::printTransition ( Transition t)
Returns
The textual description of the given transition.

◆ printTransitions()

const std::string scxml4cpp::Helper::printTransitions ( std::list< Transition * > &  transitions)
Returns
The textual description of the given transitions.

◆ sortAtomicStates()

void scxml4cpp::Helper::sortAtomicStates ( std::set< State * > &  status,
std::vector< State * > &  sortedStatus 
)

Sort the set of states according to SCXML document order.

Parameters
statusGiven set of states.
sortedStatusSorted vector of states.

Member Data Documentation

◆ COMP_STATE_SEPARATOR

const std::string scxml4cpp::Helper::COMP_STATE_SEPARATOR = "/"
inlinestatic

◆ LEAF_STATE_SEPARATOR

const std::string scxml4cpp::Helper::LEAF_STATE_SEPARATOR = ";"
inlinestatic

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