00001
00002
00003
00004
00005
00006 #ifndef GOSU_WINUTILITY_HPP
00007 #define GOSU_WINUTILITY_HPP
00008
00009 #include <windows.h>
00010 #include <Gosu/Platform.hpp>
00011 #include <boost/function.hpp>
00012 #include <boost/shared_ptr.hpp>
00013 #include <string>
00014
00015 namespace Gosu
00016 {
00018 namespace Win
00019 {
00021 HINSTANCE instance();
00022
00025 void handleMessage();
00026
00029 void processMessages();
00030
00034 void registerMessageHook(const boost::function<bool (MSG&)>& hook);
00035
00039 GOSU_NORETURN void throwLastError(const std::string& action = "");
00040
00044 template<typename T>
00045 inline T check(T valToCheck, const std::string& action = "")
00046 {
00047 if (!valToCheck)
00048 throwLastError(action);
00049 return valToCheck;
00050 }
00051
00052
00053
00054 template<typename T>
00055 void releaseComPtr(T* ptr)
00056 {
00057 ptr->Release();
00058 }
00059
00062 template<typename T>
00063 inline boost::shared_ptr<T> shareComPtr(T* ptr)
00064 {
00065 return boost::shared_ptr<T>(ptr, releaseComPtr<T>);
00066 }
00067
00069 std::wstring appFilename();
00070
00072 std::wstring appDirectory();
00073 }
00074 }
00075
00076 #endif