remove \r
[extl.git] / extl / platform_ / windows / counter / tick_counter.h
blob06d3235182d8631b11a73f764511623c729998de
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: tick_counter.h
4 * Created: 08.02.17
5 * Updated: 08.11.09
7 * Brief: The tick_counter class - precision: ms
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_PLATFORM_WINDOWS_TICK_COUNTER_H
13 #define EXTL_PLATFORM_WINDOWS_TICK_COUNTER_H
15 /*!\file tick_counter.h
16 * \brief tick_counter class - precision: ms
18 #ifndef __cplusplus
19 # error tick_counter.h need be supported by c++.
20 #endif
22 /* ///////////////////////////////////////////////////////////////////////
23 * Includes
25 #include "prefix.h"
27 /* ///////////////////////////////////////////////////////////////////////
28 * ::extl::platform::windows namespace
30 EXTL_WINDOWS_BEGIN_WHOLE_NAMESPACE
32 /*!\brief tick_counter class
34 * \ingroup extl_group_counter
36 class tick_counter
38 /// \name Constructors
39 /// @{
40 public :
41 tick_counter();
42 /// @}
44 /// \name Types
45 /// @{
46 private:
47 typedef tick_counter class_type;
48 typedef DWORD size_type;
49 #ifdef EXTL_64BIT_INT_SUPPORT
50 typedef e_uint64_t interval_type;
51 #else
52 typedef e_uint32_t interval_type;
53 #endif
54 /// @}
56 /// \name Members
57 /// @{
58 private:
59 size_type m_start;
60 size_type m_stop;
61 /// @}
63 /// \name Operations
64 /// @{
65 public:
66 inline void start();
67 inline void stop();
68 /// @}
70 /// \name Attributes
71 /// @{
72 public:
73 inline interval_type count() const;
74 inline interval_type s() const;
75 inline interval_type ms() const;
76 inline interval_type us() const;
77 /// @}
80 /* ///////////////////////////////////////////////////////////////////////
81 * Class implementation
83 inline tick_counter::tick_counter()
84 : m_start(0), m_stop(0)
87 inline void tick_counter::start()
89 m_start = ::GetTickCount();
91 inline void tick_counter::stop()
93 m_stop = ::GetTickCount();
95 inline tick_counter::interval_type tick_counter::count() const
97 EXTL_ASSERT(m_stop >= m_start);
98 return static_cast<interval_type>(m_stop - m_start);
100 inline tick_counter::interval_type tick_counter::s() const
102 return count() / interval_type(1000);
104 inline tick_counter::interval_type tick_counter::ms() const
106 return count();
108 inline tick_counter::interval_type tick_counter::us() const
110 return count() * interval_type(1000);
113 /* ///////////////////////////////////////////////////////////////////////
114 * ::extl::platform::windows namespace
116 EXTL_WINDOWS_END_WHOLE_NAMESPACE
118 /* //////////////////////////////////////////////////////////////////// */
119 #endif /* EXTL_PLATFORM_WINDOWS_TICK_COUNTER_H */
120 /* //////////////////////////////////////////////////////////////////// */