CHSM  4.4.1
Public Member Functions | List of all members
CHSM::cluster Class Reference

A cluster is-a CHSM::parent that can have at most one child-state active at any given time. More...

#include <chsm.h>

Inheritance diagram for CHSM::cluster:
CHSM::parent CHSM::state

Public Member Functions

void clear ()
 Clears the history. More...
 
 cluster (CHSM_CLUSTER_ARGS)
 Constructs a cluster. More...
 
virtual void deep_clear ()
 Clear the history, if any; then clear all child cluster's history, if any. More...
 
virtual bool enter (event const &trigger, state *from_child=0)
 Enters a cluster via a transition and also enter one of its child states. More...
 
virtual bool exit (event const &trigger, state *to=0)
 Exits a cluster via a transition, but first exit its active child state. More...
 
- Public Member Functions inherited from CHSM::parent
iterator begin ()
 Returns a parent::iterator positioned at the first child state of a parent. More...
 
const_iterator begin () const
 Returns a parent::const_iterator positioned at the first child state of a parent. More...
 
bool empty () const
 Returns whether this parent has any child states. More...
 
iterator end ()
 Returns a parent::iterator positioned at one past the last child state of a parent. More...
 
const_iterator end () const
 Returns a parent::const_iterator positioned at one past the last child state of a parent. More...
 
reference front ()
 Returns a parent::reference to the first child state. More...
 
const_reference front () const
 Returns a parent::const_reference to the first child state. More...
 
- Public Member Functions inherited from CHSM::state
bool active () const
 Returns whether this state is active. More...
 
char const * name () const
 Return the name of the state. More...
 
parentparent_of () const
 Return the parent cluster or set. More...
 
 state (CHSM_STATE_ARGS)
 Construct a state. More...
 
 ~state ()
 Destroy a state. More...
 

Additional Inherited Members

- Public Types inherited from CHSM::parent
typedef value_type const * const_pointer
 A pointer to a const value_type. More...
 
typedef value_type const & const_reference
 A reference to a const value_type. More...
 
typedef value_typepointer
 A pointer to a value_type. More...
 
typedef value_typereference
 A reference to a value_type. More...
 
typedef state value_type
 The type of the value returned by iterator and const_iterator. More...
 

Detailed Description

A cluster is-a CHSM::parent that can have at most one child-state active at any given time.

A cluster may have a history. If a cluster does not have a history, or it does have a history but has not previously been active, then the child-state entered after it itself is entered is the default child-state; if a cluster does have a history and it has been visited before, then the child-state entered after it itself is entered is the one that was last active.

A cluster may alternatively have a deep history. Such a cluster behaves exactly as one with an ordinary history; the difference is that all clusters lexically-enclosed by it in the CHSM description also have a history.

The cluster class can be extended either to add additional data members and member functions, or to alter its behavior upon being entered or exited.

Author
Paul J. Lucas

Constructor & Destructor Documentation

CHSM::cluster::cluster ( CHSM_CLUSTER_ARGS  )

Constructs a cluster.

When deriving a class from cluster, the macros CHSM_CLUSTER_ARGS CHSM_CLUSTER_INIT can be used to avoid having to deal with the many constructor arguments. See CHSM::state for an example.

Member Function Documentation

void CHSM::cluster::clear ( )
inline

Clears the history.

Referenced by deep_clear().

void CHSM::cluster::deep_clear ( )
virtual

Clear the history, if any; then clear all child cluster's history, if any.

Reimplemented from CHSM::parent.

References clear(), and CHSM::parent::deep_clear().

bool CHSM::cluster::enter ( event const &  trigger,
state from_child = 0 
)
virtual

Enters a cluster via a transition and also enter one of its child states.

Parameters
triggerThe event that triggered the transition.
from_childIf not null, this child state of the cluster is being entered directly.
Returns
Returns true only if the cluster was actually entered, i.e., it wasn't already active.

Reimplemented from CHSM::state.

References CHSM::parent::empty(), CHSM::state::enter(), and CHSM::parent::front().

Referenced by CHSM::machine::enter().

bool CHSM::cluster::exit ( event const &  trigger,
state to = 0 
)
virtual

Exits a cluster via a transition, but first exit its active child state.

Parameters
triggerThe event that triggered the transition.
toThe state that is being transitioned to.
Returns
Returns true only if the cluster actually exited, i.e., it was active.

Reimplemented from CHSM::state.

References CHSM::state::active(), and CHSM::state::exit().

Referenced by CHSM::machine::exit().


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