CHSM  4.4.1
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
CHSM::machine Class Reference

A machine contains an entire Concurrent, Hierarchical, Finite State machine. More...

#include <chsm.h>

Classes

class  const_iterator
 This is an iterator in "STL style" to iterate over the (direct child) states a machine has. More...
 

Public Types

enum  { D_none, D_enex, D_event, D_alg, D_all }
 
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 state value_type
 The type of the value returned by const_iterator. More...
 

Public Member Functions

bool active () const
 A machine as a whole is active only if its root cluster is. More...
 
const_iterator begin () const
 Returns a new const_iterator positioned at the first state in a machine. More...
 
unsigned debug () const
 Gets the current debugging state. More...
 
unsigned debug (unsigned state)
 Sets the debugging state. More...
 
void dump_state () const
 Dumps a printout of the current state to standard error. More...
 
const_iterator end () const
 Returns a new const_iterator positioned one past the last state in a machine. More...
 
virtual bool enter (event const &trigger=prime_)
 Enter a machine via a transition by entering its root cluster. More...
 
virtual bool exit (event const &trigger=prime_)
 Exit a machine via a transition by exiting its root cluster. More...
 
virtual ~machine ()
 Destroy a machine. More...
 

Protected Member Functions

 machine (CHSM_MACHINE_ARGS)
 Construct a machine. More...
 

Detailed Description

A machine contains an entire Concurrent, Hierarchical, Finite State machine.

Every machine is self-contained: there may be multiple instances of the same machine (or different machines) in different states in the same program.

Author
Paul J. Lucas

Member Typedef Documentation

A pointer to a const value_type.

A reference to a const value_type.

The type of the value returned by const_iterator.

Member Enumeration Documentation

anonymous enum
Enumerator
D_none 

Do not print any debugging information.

D_enex 

Prints entrances to and exits from states.

D_event 

Prints events queueing and dequeuing.

D_alg 

Reports progress during the broadcast algorithm.

D_all 

Reports all debugging information.

Constructor & Destructor Documentation

CHSM::machine::~machine ( )
virtual

Destroy a machine.

CHSM::machine::machine ( CHSM_MACHINE_ARGS  )
protected

Construct a machine.

When deriving a class from machine, the macros CHSM_MACHINE_ARGS and CHSM_MACHINE_INIT can be used to avoid having to deal with the many constructor arguments, e.g.:

class my_machine : public CHSM::machine {
public:
my_machine( CHSM_MACHINE_ARGS ) :
// ...
}
// ...
};

References exit().

Member Function Documentation

bool CHSM::machine::active ( ) const
inline

A machine as a whole is active only if its root cluster is.

Returns
Returns true only if this machine is active.

References CHSM::state::active().

const_iterator CHSM::machine::begin ( ) const
inline

Returns a new const_iterator positioned at the first state in a machine.

Returns
Returns said iterator.

Referenced by dump_state().

unsigned CHSM::machine::debug ( ) const
inline

Gets the current debugging state.

Returns
Returns said state.

Referenced by CHSM::state::enter(), and CHSM::state::exit().

unsigned CHSM::machine::debug ( unsigned  state)
inline

Sets the debugging state.

Debugging information is printed to system error.

Parameters
stateThe state to set that is the bitwise "or" of the debugging states D_enex, D_event, D_alg, or D_all.
Returns
Returns the previous debugging state.
void CHSM::machine::dump_state ( ) const

Dumps a printout of the current state to standard error.

The dump consists of each state's name, one per line, preceded by an asterisk only if it is active; a space otherwise.

References CHSM::state::active(), begin(), end(), and CHSM::state::name().

const_iterator CHSM::machine::end ( ) const
inline

Returns a new const_iterator positioned one past the last state in a machine.

Returns
Returns said iterator.

Referenced by dump_state().

bool CHSM::machine::enter ( event const &  trigger = prime_)
virtual

Enter a machine via a transition by entering its root cluster.

Parameters
triggerThe event to start the machine.
Returns
Returns true only if the machine was actually entered, i.e., it wasn't already active.

References CHSM::cluster::enter().

bool CHSM::machine::exit ( event const &  trigger = prime_)
virtual

Exit a machine via a transition by exiting its root cluster.

Parameters
triggerThe event to exit the machine.
Returns
Returns true only if the machine was actually exited, i.e., it wasn't already inactive.

References CHSM::cluster::exit().

Referenced by machine().


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