Timer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 <OgreSingleton.h>
  17. /**
  18. * The game timer.
  19. */
  20. class Timer : public Ogre::Singleton<Timer>{
  21. public:
  22. /**
  23. * Constructor.
  24. */
  25. Timer();
  26. /**
  27. * Retrieves the total system time.
  28. *
  29. * @return The total system time.
  30. * @todo What is the system time? What's the difference with game time?
  31. */
  32. float GetSystemTimeTotal();
  33. /**
  34. * Retrieves the system time difference.
  35. *
  36. * @return The system time difference.
  37. * @todo What is the system time? What's the difference with game time?
  38. */
  39. float GetSystemTimeDelta();
  40. /**
  41. * Retrieves the total game time.
  42. *
  43. * @return The total game time.
  44. * @todo What is the game time? What's the difference with system time?
  45. */
  46. float GetGameTimeTotal();
  47. /**
  48. * Retrieves the game time difference.
  49. *
  50. * @return The game time difference.
  51. * @todo What is the game time? What's the difference with system time?
  52. */
  53. float GetGameTimeDelta();
  54. /**
  55. * Adds time to the time.
  56. *
  57. * It can also be used to subtract time, but it will never get below 0.
  58. *
  59. * @param time[in] The time to add?
  60. * @todo What are the units? seconds?
  61. */
  62. void AddTime(const float time);
  63. /**
  64. * Sets the game timer.
  65. *
  66. * @param timer[in] The new game timer.
  67. * @todo Understand and document.
  68. */
  69. void SetGameTimer(const float timer);
  70. /**
  71. * Retrieves the game timer.
  72. *
  73. * @return The game timer.
  74. * @todo What is this timer? Why is it an int, but the setter accepts
  75. * float?
  76. */
  77. int GetGameTimer() const;
  78. private:
  79. /**
  80. * The total system time.
  81. */
  82. float system_time_total_;
  83. /**
  84. * The system time difference.
  85. */
  86. float system_time_delta_;
  87. /**
  88. * The total game time.
  89. */
  90. float game_time_total_;
  91. /**
  92. * The game time difference.
  93. */
  94. float game_time_delta_;
  95. /**
  96. * The game timer.
  97. */
  98. float game_timer_;
  99. };