OpenTTD Source  20240919-master-gdf0233f4c2
macos.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef MACOS_H
11 #define MACOS_H
12 
14 void ShowMacDialog(const char *title, const char *message, const char *button_label);
15 
16 void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix);
17 
25 inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
26 {
27  int version_major, version_minor, version_bugfix;
28  GetMacOSVersion(&version_major, &version_minor, &version_bugfix);
29 
30  if (version_major < major) return false;
31  if (version_major == major && version_minor < minor) return false;
32  if (version_major == major && version_minor == minor && version_bugfix < bugfix) return false;
33 
34  return true;
35 }
36 
37 bool IsMonospaceFont(CFStringRef name);
38 
39 void MacOSSetThreadName(const char *name);
40 
41 uint64_t MacOSGetPhysicalMemory();
42 
43 
45 template <typename T> struct CFDeleter {
46  void operator()(T *p)
47  {
48  if (p) ::CFRelease(p);
49  }
50 };
51 
53 template <typename T>
54 using CFAutoRelease = std::unique_ptr<typename std::remove_pointer<T>::type, CFDeleter<typename std::remove_pointer<T>::type>>;
55 
56 #endif /* MACOS_H */
CFAutoRelease
std::unique_ptr< typename std::remove_pointer< T >::type, CFDeleter< typename std::remove_pointer< T >::type > > CFAutoRelease
Specialisation of std::unique_ptr for CoreFoundation objects.
Definition: macos.h:54
MacOSVersionIsAtLeast
bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
Check if we are at least running on the specified version of Mac OS.
Definition: macos.h:25
ShowMacDialog
void ShowMacDialog(const char *title, const char *message, const char *button_label)
Helper function displaying a message the best possible way.
CFDeleter
Deleter that calls CFRelease rather than deleting the pointer.
Definition: macos.h:45