]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/os.h
Unify & improve log messages
[irrlicht.git] / source / Irrlicht / os.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __IRR_OS_H_INCLUDED__\r
6 #define __IRR_OS_H_INCLUDED__\r
7 \r
8 #include "irrTypes.h"\r
9 #include "irrString.h"\r
10 #include "path.h"\r
11 #include "ILogger.h"\r
12 #include "ITimer.h"\r
13 \r
14 namespace irr\r
15 {\r
16 \r
17 namespace os\r
18 {\r
19         class Byteswap\r
20         {\r
21         public:\r
22                 static u16 byteswap(u16 num);\r
23                 static s16 byteswap(s16 num);\r
24                 static u32 byteswap(u32 num);\r
25                 static s32 byteswap(s32 num);\r
26                 static u64 byteswap(u64 num);\r
27                 static s64 byteswap(s64 num);\r
28                 static f32 byteswap(f32 num);\r
29                 // prevent accidental swapping of chars\r
30                 static u8  byteswap(u8  num);\r
31                 static c8  byteswap(c8  num);\r
32         };\r
33 \r
34         class Printer\r
35         {\r
36         public:\r
37                 // prints out a string to the console out stdout or debug log or whatever\r
38                 static void print(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION);\r
39                 static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION);\r
40                 static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION);\r
41 \r
42                 // The string ": " is added between message and hint\r
43                 static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION);\r
44                 static void log(const c8* message, const io::path& hint, ELOG_LEVEL ll = ELL_INFORMATION);\r
45                 static ILogger* Logger;\r
46         };\r
47 \r
48         class Timer\r
49         {\r
50         public:\r
51 \r
52                 //! returns the current time in milliseconds\r
53                 static u32 getTime();\r
54 \r
55                 //! get current time and date in calendar form\r
56                 static ITimer::RealTimeDate getRealTimeAndDate();\r
57 \r
58                 //! initializes the real timer\r
59                 static void initTimer(bool usePerformanceTimer=true);\r
60 \r
61                 //! sets the current virtual (game) time\r
62                 static void setTime(u32 time);\r
63 \r
64                 //! stops the virtual (game) timer\r
65                 static void stopTimer();\r
66 \r
67                 //! starts the game timer\r
68                 static void startTimer();\r
69 \r
70                 //! sets the speed of the virtual timer\r
71                 static void setSpeed(f32 speed);\r
72 \r
73                 //! gets the speed of the virtual timer\r
74                 static f32 getSpeed();\r
75 \r
76                 //! returns if the timer currently is stopped\r
77                 static bool isStopped();\r
78 \r
79                 //! makes the virtual timer update the time value based on the real time\r
80                 static void tick();\r
81 \r
82                 //! returns the current real time in milliseconds\r
83                 static u32 getRealTime();\r
84 \r
85         private:\r
86 \r
87                 static void initVirtualTimer();\r
88 \r
89                 static f32 VirtualTimerSpeed;\r
90                 static s32 VirtualTimerStopCounter;\r
91                 static u32 StartRealTime;\r
92                 static u32 LastVirtualTime;\r
93                 static u32 StaticTime;\r
94         };\r
95 \r
96 } // end namespace os\r
97 } // end namespace irr\r
98 \r
99 \r
100 #endif\r
101 \r