simplehsm/simplehsm.c File Reference

#include <stdio.h>
#include <tchar.h>
#include "simplehsm.h"

Functions

void simplehsm_initialize (simplehsm_t *hsm, stfunc top_state)
BOOL _is_parent (simplehsm_t *hsm, stfunc parent_state, stfunc child_state)
void simplehsm_transition_state_ex (simplehsm_t *hsm, stfunc new_state, BOOL to_deep_hist)
void simplehsm_transition_state (simplehsm_t *hsm, stfunc new_state)
void simplehsm_init_transition_state (simplehsm_t *hsm, stfunc new_state)
void simplehsm_signal_current_state (simplehsm_t *hsm, int signal, void *param)
BOOL simplehsm_is_in_state (simplehsm_t *hsm, stfunc state)
void simplehsm_record_deephist (simplehsm_t *hsm, stfunc history_parent, stfunc history_state)
stfunc simplehsm_retrieve_deephist (simplehsm_t *hsm, stfunc history_parent)

Detailed Description

Author:
Daniel Newton <djpnewton@gmail.com>
Version:
1.0

LICENSE

Copyright (c) 2009 Daniel Newton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

DESCRIPTION

The simplehsm C implementation

Function Documentation

BOOL _is_parent ( simplehsm_t hsm,
stfunc  parent_state,
stfunc  child_state 
)

Check is one state is the parent of another.

Parameters:
hsm The state machine to check
parent_state The parent state to check
child_state The child state to check
Returns:
True if the parent_state parameter is a parent to the child_state parameter

void simplehsm_init_transition_state ( simplehsm_t hsm,
stfunc  new_state 
)

Initiate an initial transition to a new state (this function should only be used from a SIG_INIT state event).

Parameters:
hsm The state machine to transition
new_state The state to transition to

void simplehsm_initialize ( simplehsm_t hsm,
stfunc  top_state 
)

Initialise a simplehsm state machine.

Parameters:
hsm The state machine to initialise
top_state The topmost (and initial) state of the hierarchy

BOOL simplehsm_is_in_state ( simplehsm_t hsm,
stfunc  state 
)

Check if a state machine is currently in a certain state.

Parameters:
hsm The state machine to check
state The state to check
Returns:
True if the state machine is currently in the specified state

void simplehsm_record_deephist ( simplehsm_t hsm,
stfunc  history_parent,
stfunc  history_state 
)

Record deep history psuedostate.

Parameters:
hsm The state machine
history_parent The parent state of the deep history psuedostate
history_state The state to return to if transitioning to the deep history psuedostate

stfunc simplehsm_retrieve_deephist ( simplehsm_t hsm,
stfunc  history_parent 
)

Retrive deep history psuedostate.

Parameters:
hsm The state machine
history_parent The parent state of the deep history psuedostate
Returns:
The state to transition to via the deep history psuedostate

void simplehsm_signal_current_state ( simplehsm_t hsm,
int  signal,
void *  param 
)

Send a signal to the state machine.

Parameters:
hsm The state machine to signal
signal The signal flag
param An optional parameter to accompany the signal

void simplehsm_transition_state ( simplehsm_t hsm,
stfunc  new_state 
)

Initiate a transition to a new state.

Parameters:
hsm The state machine to transition
new_state The state to transition to

void simplehsm_transition_state_ex ( simplehsm_t hsm,
stfunc  new_state,
BOOL  to_deep_hist 
)

Initiate a transition to a new state.

This function will:

  • replace the target state with the deep history target if required
  • store a deep history target state if exiting a composite state with a deep history child
  • perform the exit/entry chain from the current state to the target state

Parameters:
hsm The state machine to transition
new_state The state to transition to
to_deep_hist Whether to transition to the states internal deep history psuedostate


Generated on Thu Feb 4 09:32:56 2010 for simplehsm(C) by  doxygen 1.5.9