AHierarchicalStateMachine.h revision f933441648ef6a71dee783d733aac17b9508b452
1#ifndef A_HIERARCHICAL_STATE_MACHINE_H_ 2 3#define A_HIERARCHICAL_STATE_MACHINE_H_ 4 5#include <media/stagefright/foundation/AHandler.h> 6 7namespace android { 8 9struct AState : public RefBase { 10 AState(const sp<AState> &parentState = NULL); 11 12 sp<AState> parentState(); 13 14protected: 15 virtual ~AState(); 16 17 virtual void stateEntered(); 18 virtual void stateExited(); 19 20 virtual bool onMessageReceived(const sp<AMessage> &msg) = 0; 21 22private: 23 friend struct AHierarchicalStateMachine; 24 25 sp<AState> mParentState; 26 27 DISALLOW_EVIL_CONSTRUCTORS(AState); 28}; 29 30struct AHierarchicalStateMachine : public AHandler { 31 AHierarchicalStateMachine(); 32 33protected: 34 virtual ~AHierarchicalStateMachine(); 35 36 virtual void onMessageReceived(const sp<AMessage> &msg); 37 38 // Only to be called in response to a message. 39 void changeState(const sp<AState> &state); 40 41private: 42 sp<AState> mState; 43 44 DISALLOW_EVIL_CONSTRUCTORS(AHierarchicalStateMachine); 45}; 46 47} // namespace android 48 49#endif // A_HIERARCHICAL_STATE_MACHINE_H_ 50