X-Git-Url: http://git.maemo.org/git/?p=mardrone;a=blobdiff_plain;f=mardrone%2FARDrone_SDK_Version_1_8_20110726%2FExamples%2FiPhone%2FFreeFlight%2FClasses%2FMenus%2FFiniteStateMachine.h;fp=mardrone%2FARDrone_SDK_Version_1_8_20110726%2FExamples%2FiPhone%2FFreeFlight%2FClasses%2FMenus%2FFiniteStateMachine.h;h=db3680dce3abc50557f4cdbfe40503d61e509ece;hp=0000000000000000000000000000000000000000;hb=9ec9bc13b75d30bc45535c54a652934debfcea92;hpb=ae0a3c2dc0898400aca0dd6b439c5db8044db7b2 diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/iPhone/FreeFlight/Classes/Menus/FiniteStateMachine.h b/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/iPhone/FreeFlight/Classes/Menus/FiniteStateMachine.h new file mode 100644 index 0000000..db3680d --- /dev/null +++ b/mardrone/ARDrone_SDK_Version_1_8_20110726/Examples/iPhone/FreeFlight/Classes/Menus/FiniteStateMachine.h @@ -0,0 +1,80 @@ +// +// FiniteStateMachine.h +// ArDroneGameLib +// +// Created by clement choquereau on 5/4/11. +// Copyright 2011 Parrot. All rights reserved. +// + +#import + +#define NO_STATE (-1) + +@class FSMXMLParsing; + +@interface FiniteStateMachine : NSObject +{ + id delegate; + + unsigned int statesCount; + unsigned int actionsCount; + unsigned int currentState; + + NSMutableDictionary *objects; + NSMutableDictionary *enterCallbacks; + NSMutableDictionary *quitCallbacks; + NSMutableDictionary *stateActions; + + // should always be nil: + FSMXMLParsing *xml; +} + +@property (nonatomic, retain) id delegate; +@property (readonly) id currentObject; + +@property (readonly) unsigned int statesCount; +@property (readonly) unsigned int actionsCount; +@property unsigned int currentState; + +/* + * You can create a FSM with a XML file: + * (For element 'state', attributes 'enter-callback', 'quit-callback' and 'object' aren't mandatory.) + * + * + * + * + * + * ... + * + * + * + * ... + * + * + * + * + * + */ ++ (id) fsm; ++ (id) fsmWithXML:(NSString *)fileName; + +// Managing states: +- (unsigned int) createState; +- (void) createStates:(unsigned int)count inArray:(unsigned int *)states; +- (void) setObject:(id)object forState:(unsigned int)state; +- (void) setEnterStateCallback:(SEL)enter forState:(unsigned int)state; +- (void) setQuitStateCallback:(SEL)quit forState:(unsigned int)state; + +- (unsigned int) createStateWithObject:(id)object andEnterStateCallback:(SEL)enter andQuitStateCallback:(SEL)quit; +- (void) createStates:(unsigned int)count withObjects:(id *)items andEnterStateCallbacks:(SEL *)enters andQuitStateCallbacks:(SEL *)quits inArray:(unsigned int *)states; + +// Managing actions: +- (unsigned int) createAction; +- (void) createActions:(unsigned int)count inArray:(unsigned int *)actions; + +// Associations: +- (void) createAssociationFromState:(unsigned int)start withAction:(unsigned int)action toState:(unsigned int)end; +- (void) createAssociationFromState:(unsigned int)start withActions:(unsigned int *)actions toStates:(unsigned int *)ends andNumAssociations:(unsigned int)count; +- (void) doAction:(unsigned int)action; + +@end