/* state.h */

#ifndef STATE_H
#define STATE_H

#define NAME_LEN 10
#define MAX_STATES 2

#define FALSE 0
#define TRUE 1


/*
 * State with a name and a capacity of maximum MAX_STATES connections
 * to other states (or itself).
 */
struct _State {
  char name[NAME_LEN];                 // holds the name of the state
  int nofStates;                       // holds number of active connections
  struct _State *arr[MAX_STATES];      // array containg pointers to other
};                                     //  states
typedef struct _State State;

typedef int boolean;



/*
 * Initialize state with name etc.
 * *state           - pointer to state to be initialized
 * *stateName       - pointer to char array representing the name of the state
 */
void initState(State *state, char *stateName);


/*
 * Connect the fromState with the toState. Direction is from .. to.
 * If connections are made to several states, connections are numbered
 * starting with 0.
 * *fromState       - pointer to state from where to start when traversing
 * *toState         - pointer to state to where to arrive when traversing
 *
 * return value:      TRUE, if connection could be established, else FALSE
 */
boolean connectStates(State *fromState, State *toState);


/*
 * Print the name of the state.
 * *state           - pointer to state
 */
void printStateName(State *state);


/*
 * Print the name of the state between stars.
 * *state           - pointer to state
 */
void printStateNameBetweenStars(State *state);


/*
 * Visit several states starting from firstState proceeding to next state
 * according the steering array stateIndicesArray. In arriving at a state
 * (except firstState), the action is performed which *outFctPtr is poining
 * to. Repeat for all array indices.
 * *firstState      - pointer to state where to start visiting (traversing)
 *                    from
 * *stateIndicesArray - array containing indices. Each index steers which
 *                    connection in a state to choose next. Order (and index)
 *                    of connections are determined when connecting states.
 * arrSize          - size of the array stateIndicesArray
 * (*outFctPtr)()   - pointer to function to (output) action when visiting
 *                    a state
 */
void visitStates(
  State *firstState, int *stateIndicesArr, int arrSize, void (*outFctPtr)());

#endif
