AppInterface.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __APP_INTERFACE_H
  11. #define __APP_INTERFACE_H
  12. #include "AppTypes.h"
  13. class FSM;
  14. class RunnableState;
  15. class AppInterface
  16. {
  17. public:
  18. AppInterface();
  19. virtual ~AppInterface();
  20. // Called first to initialize memory
  21. virtual void PreConfigure(void);
  22. // Called after LoadDefaultResources. Return false to quit.
  23. virtual bool Configure(void)=0;
  24. // Called to do startup required after Configuration
  25. virtual void PostConfigure(const char *defaultResourceConfigurationPath);
  26. virtual void Update(AppTime curTimeMS,AppTime elapsedTimeMS);
  27. virtual void OnAppShutdown(void);
  28. // Logging, lifetime may be ignored
  29. virtual void DebugOut(unsigned int lifetimeMS, const char *format, ...);
  30. // Like focus in windows - start and stop rendering but don't necessarily stop running.
  31. bool HasFocus(void) const;
  32. virtual void SetFocus(bool hasFocus);
  33. // Built-in state machine
  34. void AllocateStates(int numStates);
  35. virtual void SetState(int stateType, RunnableState* state);
  36. RunnableState* GetState(int stateType) const;
  37. RunnableState* GetCurrentState(void) const;
  38. void PushState(RunnableState* state);
  39. void PushState(int stateType);
  40. void PopState(int popCount=1);
  41. int GetStateHistorySize(void) const;
  42. // Just setting a flag
  43. virtual bool ShouldQuit(void) const;
  44. void Quit(void);
  45. AppTime GetLastCurrentTime(void) const;
  46. AppTime GetLastElapsedTime(void) const;
  47. protected:
  48. // Allocated in PostConfigure
  49. FSM *primaryFSM;
  50. // Up to the derived class to allocate this using allocateStates
  51. RunnableState **primaryStates;
  52. AppTime lastElapsedTimeMS, lastCurTimeMS;
  53. int primaryStatesLength;
  54. bool hasFocus;
  55. bool quit;
  56. };
  57. #endif
粤ICP备19079148号