Next: , Up: The GO Factory

7.5.1 State definitions

The GO Factory state structure is defined like this:

     struct of_state
         uns flags;
         enum of_input_kind input_kind;
         uns input_type;
         uns input_subtype;
             struct dist_pass_result dpr;
             struct prop prop;
         } value;
         char * description;
         void (* action_func)(struct of_state *);
         void (* cleanup_func)(struct of_state *);
         struct of_state * prev;
         struct of_state * next;
         struct undo_gui * prev_undo_item;
         struct go * tmp_go[OFR_CNT];

The input_kind specifies what input is wanted from the user. Its value is one of OFIK_NONE, OFIK_DPR, OFIK_PROP, OFIK_SEL, OFIK_TRANSFORM, and OFIK_TF. The last three ones are special and used in the selection and transformation tools; OFIK_NONE is used only in some special GO Factory states. The OFIK_DPR input kind means that the input is the result of a snap distance pass, and OFIK_PROP stands for a property value.

The action_func function is called before proceeding to the next GO Factory state (after the state input value has been filled). It is called inside a transaction on the current context tlo, so the function can use transaction fails for error reporting. The of_state function argument is a pointer to the current state.

The cleanup_func is called when moving back and undoing the effects of the state, and after a successful GO creation as well. It does not have to unlink any created objects; that is done by undo automatically. It should only free any additionally allocated memory or release all references that the action function created.

There are some predefined GO Factory states including the most important ones:

     struct of_state ofs_start;
     struct of_state ofs_end;

These two states do not take part in creation of any go directly. But the state structure is linked in such a way that the prev pointer of all the starting states points to the ofs_start state and the next pointer of all the last states points to ofs_end.