|
|
|||
File indexing completed on 2026-06-02 08:58:14
0001 //////////////////////////////////////////////////////////// 0002 // 0003 // SFML - Simple and Fast Multimedia Library 0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) 0005 // 0006 // This software is provided 'as-is', without any express or implied warranty. 0007 // In no event will the authors be held liable for any damages arising from the use of this software. 0008 // 0009 // Permission is granted to anyone to use this software for any purpose, 0010 // including commercial applications, and to alter it and redistribute it freely, 0011 // subject to the following restrictions: 0012 // 0013 // 1. The origin of this software must not be misrepresented; 0014 // you must not claim that you wrote the original software. 0015 // If you use this software in a product, an acknowledgment 0016 // in the product documentation would be appreciated but is not required. 0017 // 0018 // 2. Altered source versions must be plainly marked as such, 0019 // and must not be misrepresented as being the original software. 0020 // 0021 // 3. This notice may not be removed or altered from any source distribution. 0022 // 0023 //////////////////////////////////////////////////////////// 0024 0025 #ifndef SFML_CLOCK_HPP 0026 #define SFML_CLOCK_HPP 0027 0028 //////////////////////////////////////////////////////////// 0029 // Headers 0030 //////////////////////////////////////////////////////////// 0031 #include <SFML/System/Export.hpp> 0032 #include <SFML/System/Time.hpp> 0033 0034 0035 namespace sf 0036 { 0037 //////////////////////////////////////////////////////////// 0038 /// \brief Utility class that measures the elapsed time 0039 /// 0040 //////////////////////////////////////////////////////////// 0041 class SFML_SYSTEM_API Clock 0042 { 0043 public: 0044 0045 //////////////////////////////////////////////////////////// 0046 /// \brief Default constructor 0047 /// 0048 /// The clock starts automatically after being constructed. 0049 /// 0050 //////////////////////////////////////////////////////////// 0051 Clock(); 0052 0053 //////////////////////////////////////////////////////////// 0054 /// \brief Get the elapsed time 0055 /// 0056 /// This function returns the time elapsed since the last call 0057 /// to restart() (or the construction of the instance if restart() 0058 /// has not been called). 0059 /// 0060 /// \return Time elapsed 0061 /// 0062 //////////////////////////////////////////////////////////// 0063 Time getElapsedTime() const; 0064 0065 //////////////////////////////////////////////////////////// 0066 /// \brief Restart the clock 0067 /// 0068 /// This function puts the time counter back to zero. 0069 /// It also returns the time elapsed since the clock was started. 0070 /// 0071 /// \return Time elapsed 0072 /// 0073 //////////////////////////////////////////////////////////// 0074 Time restart(); 0075 0076 private: 0077 0078 //////////////////////////////////////////////////////////// 0079 // Member data 0080 //////////////////////////////////////////////////////////// 0081 Time m_startTime; //!< Time of last reset, in microseconds 0082 }; 0083 0084 } // namespace sf 0085 0086 0087 #endif // SFML_CLOCK_HPP 0088 0089 0090 //////////////////////////////////////////////////////////// 0091 /// \class sf::Clock 0092 /// \ingroup system 0093 /// 0094 /// sf::Clock is a lightweight class for measuring time. 0095 /// 0096 /// Its provides the most precise time that the underlying 0097 /// OS can achieve (generally microseconds or nanoseconds). 0098 /// It also ensures monotonicity, which means that the returned 0099 /// time can never go backward, even if the system time is 0100 /// changed. 0101 /// 0102 /// Usage example: 0103 /// \code 0104 /// sf::Clock clock; 0105 /// ... 0106 /// Time time1 = clock.getElapsedTime(); 0107 /// ... 0108 /// Time time2 = clock.restart(); 0109 /// \endcode 0110 /// 0111 /// The sf::Time value returned by the clock can then be 0112 /// converted to a number of seconds, milliseconds or even 0113 /// microseconds. 0114 /// 0115 /// \see sf::Time 0116 /// 0117 ////////////////////////////////////////////////////////////
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|