/* dynState.h */

#ifndef DYN_STATE_H
#define DYN_STATE_H

#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;                          // pointer for array to hold the name
                                       //  of the state
  int nofStates;                       // holds number of active connections
  struct _State **arr;                 // pointer for array containg pointers
};                                     //  to other states
typedef struct _State State;

typedef int boolean;



/*
 * Allocate memory and initialize state with name etc.
 * *stateName       - pointer to char array representing the name of the state
 *
 * return Value:      pointer to new state or NULL, respectively
 */
State *newState(char *stateName);


/*
 * Free previously allocated memory.
 * *state           - pointer to state
 */
void deleteState(State *state);


/*
 * 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
 */
void 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
