Main Page
Namespaces
Classes
Files
File List
File Members
Gosu
WinUtility.hpp
Go to the documentation of this file.
1
2
3
4
5
6
#ifndef GOSU_WINUTILITY_HPP
7
#define GOSU_WINUTILITY_HPP
8
9
#include <windows.h>
10
#include <
Gosu/Platform.hpp
>
11
#include <
Gosu/TR1.hpp
>
12
#include <string>
13
14
namespace
Gosu
15
{
17
namespace
Win
18
{
20
HINSTANCE
instance
();
21
24
void
handleMessage
();
25
28
void
processMessages
();
29
33
void
registerMessageHook
(
const
std::tr1::function<
bool
(MSG&)>& hook);
34
38
GOSU_NORETURN
void
throwLastError
(
const
std::string& action =
""
);
39
43
template
<
typename
T>
44
inline
T
check
(T valToCheck,
const
std::string& action =
""
)
45
{
46
if
(!valToCheck)
47
throwLastError
(action);
48
return
valToCheck;
49
}
50
51
// IMPR: Why can't I use mem_fn for releasing objects even though it is
52
// shown like that in the shared_ptr documentation?
53
template
<
typename
T>
54
void
releaseComPtr
(T* ptr)
55
{
56
ptr->Release();
57
}
58
61
template
<
typename
T>
62
inline
std::tr1::shared_ptr<T>
shareComPtr
(T* ptr)
63
{
64
return
std::tr1::shared_ptr<T>(ptr, releaseComPtr<T>);
65
}
66
68
std::wstring
appFilename
();
69
71
std::wstring
appDirectory
();
72
}
73
}
74
75
#endif