remove \r
[extl.git] / extl / platform_ / windows / counter / multimedia_counter.h
blob8537d25f260bc1cc9a8dc4fc44161b8e7182572e
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: multimedia_counter.h
4 * Created: 08.02.17
5 * Updated: 08.11.13
7 * Brief: The multimedia_counter class - precision: ms
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_PLATFORM_WINDOWS_MULTIMEDIA_COUNTER_H
13 #define EXTL_PLATFORM_WINDOWS_MULTIMEDIA_COUNTER_H
15 /*!\file multimedia_counter.h
16 * \brief multimedia_counter class - precision: ms
18 #ifndef __cplusplus
19 # error multimedia_counter.h need be supported by c++.
20 #endif
22 /* ///////////////////////////////////////////////////////////////////////
23 * Includes
25 #include "prefix.h"
26 #include <mmsystem.h>
28 #if !defined(EXTL_COMPILER_IS_GCC) && \
29 !defined(EXTL_COMPILER_IS_BORLAND)
30 # pragma comment(lib, "WinMM.lib")
31 #endif
33 /* ///////////////////////////////////////////////////////////////////////
34 * ::extl::platform::windows namespace
36 EXTL_WINDOWS_BEGIN_WHOLE_NAMESPACE
38 /*!\brief multimedia_counter class
40 * \ingroup extl_group_counter
42 class multimedia_counter
44 /// \name Constructors
45 /// @{
46 public :
47 multimedia_counter();
48 /// @}
50 /// \name Types
51 /// @{
52 private:
53 typedef multimedia_counter class_type;
54 #ifdef EXTL_64BIT_INT_SUPPORT
55 typedef e_uint64_t interval_type;
56 #else
57 typedef e_uint32_t interval_type;
58 #endif
59 typedef DWORD size_type;
60 /// @}
62 /// \name Operations
63 /// @{
64 public:
65 inline void start();
66 inline void stop();
67 /// @}
69 /// \name Attributes
70 /// @{
71 public:
72 inline interval_type count() const;
73 inline interval_type s() const;
74 inline interval_type ms() const;
75 inline interval_type us() const;
76 /// @}
78 /// \name Members
79 /// @{
80 private:
81 size_type m_start;
82 size_type m_stop;
83 /// @}
86 /* ///////////////////////////////////////////////////////////////////////
87 * Class implementation
89 inline multimedia_counter::multimedia_counter()
90 : m_start(0), m_stop(0)
93 inline void multimedia_counter::start()
95 m_start = ::timeGetTime();
98 inline void multimedia_counter::stop()
100 m_stop = ::timeGetTime();
102 inline multimedia_counter::interval_type multimedia_counter::count() const
104 return static_cast<interval_type>(m_stop - m_start);
106 inline multimedia_counter::interval_type multimedia_counter::s() const
108 return count() / interval_type(1000);
110 inline multimedia_counter::interval_type multimedia_counter::ms() const
112 return count();
114 inline multimedia_counter::interval_type multimedia_counter::us() const
116 return count() * interval_type(1000);
119 /* ///////////////////////////////////////////////////////////////////////
120 * ::extl::platform::windows namespace
122 EXTL_WINDOWS_END_WHOLE_NAMESPACE
124 /* //////////////////////////////////////////////////////////////////// */
125 #endif /* EXTL_PLATFORM_WINDOWS_MULTIMEDIA_COUNTER_H */
126 /* //////////////////////////////////////////////////////////////////// */