00001 #ifndef __APP_INTERFACE_H 00002 #define __APP_INTERFACE_H 00003 00004 #include "AppTypes.h" 00005 00006 00007 class FSM; 00008 class RunnableState; 00009 class AppInterface 00010 { 00011 public: 00012 AppInterface(); 00013 virtual ~AppInterface(); 00014 // Called first to initialize memory 00015 virtual void PreConfigure(void); 00016 // Called after LoadDefaultResources. Return false to quit. 00017 virtual bool Configure(void)=0; 00018 // Called to do startup required after Configuration 00019 virtual void PostConfigure(const char *defaultResourceConfigurationPath); 00020 virtual void Update(AppTime curTimeMS,AppTime elapsedTimeMS); 00021 virtual void OnAppShutdown(void); 00022 00023 // Logging, lifetime may be ignored 00024 virtual void DebugOut(unsigned int lifetimeMS, const char *format, ...); 00025 00026 // Like focus in windows - start and stop rendering but don't necessarily stop running. 00027 bool HasFocus(void) const; 00028 virtual void SetFocus(bool hasFocus); 00029 00030 // Built-in state machine 00031 void AllocateStates(int numStates); 00032 virtual void SetState(int stateType, RunnableState* state); 00033 RunnableState* GetState(int stateType) const; 00034 RunnableState* GetCurrentState(void) const; 00035 void PushState(RunnableState* state); 00036 void PushState(int stateType); 00037 void PopState(int popCount=1); 00038 int GetStateHistorySize(void) const; 00039 00040 // Just setting a flag 00041 virtual bool ShouldQuit(void) const; 00042 void Quit(void); 00043 AppTime GetLastCurrentTime(void) const; 00044 AppTime GetLastElapsedTime(void) const; 00045 00046 protected: 00047 // Allocated in PostConfigure 00048 FSM *primaryFSM; 00049 // Up to the derived class to allocate this using allocateStates 00050 RunnableState **primaryStates; 00051 AppTime lastElapsedTimeMS, lastCurTimeMS; 00052 int primaryStatesLength; 00053 bool hasFocus; 00054 bool quit; 00055 }; 00056 00057 #endif
1.7.1