Module.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OIS/OIS.h>
  17. #include "Event.h"
  18. /**
  19. * Possible states of a module.
  20. */
  21. enum MODULE_STATE{
  22. /**
  23. * The module is starting.
  24. */
  25. MODULE_START,
  26. /**
  27. * The module is running.
  28. */
  29. MODULE_RUN,
  30. /**
  31. * The module has finished running.
  32. */
  33. MODULE_FINISH,
  34. /**
  35. * The module is stopped.
  36. */
  37. MODULE_STOP,
  38. /**
  39. * The module is paused.
  40. */
  41. MODULE_PAUSE
  42. };
  43. /**
  44. * A game module
  45. */
  46. class Module {
  47. public:
  48. /**
  49. * Destructor.
  50. */
  51. virtual ~Module(){}
  52. /**
  53. * Handles an input event.
  54. */
  55. virtual void Input(const Event& event) = 0;
  56. /**
  57. * Updates the module state.
  58. */
  59. virtual void Update() = 0;
  60. /**
  61. * Sets the module state.
  62. *
  63. * @param state[in] Module's new state.
  64. */
  65. void SetState(const MODULE_STATE state){state_ = state;}
  66. /**
  67. * Retrieves the module state.
  68. *
  69. * @return The module's current state.
  70. */
  71. const MODULE_STATE GetState() const {return state_;}
  72. private:
  73. /**
  74. * The current module state.
  75. */
  76. MODULE_STATE state_;
  77. };