Keeping an application alive in C++ on Apple Mac OS-X

If you are writing a cross-platform application you are probably not going to use the Native OS-X app development tools, and you might end up with something in C++, for example with Qt. However, you will be unable to access some internal OS-X functionality. One way to deal with this is writing something in Apple’s Objective-C that talks to the internal OS-X SDK. In this case, I have made a small wrapper to keep an application alive. So we are going to mix Objective-C into C++, which is fine and quite common for OS-X app development.
What this class does is two fold:

Prevents an ‘App Nap’, whatever the hell that entails.

Prevents the system from going automagically to some power-saving mode or idle, (display) sleep or suspend.

keepalive.h

/**
--------------------------------------------------------------------------------
- Module : keepalive.h
- Description : A wrapper to keep an app alive, written
- in C++ and Objective-C so made for the OSX platform.
- Author : Tim Zaman, 18-FEB-2016
--------------------------------------------------------------------------------
*//*
Copyright (c) 2016 Tim Zaman
Permission to use, copy, modify, distribute, and sell this software
for any purpose is hereby granted without fee, provided
that (i) the above copyright notices and this permission notice appear in
all copies of the software and related documentation.
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*/#ifndef KEEPALIVE_H#define KEEPALIVE_Hclass KeepAlive {public:
KeepAlive(){
KeepAliveMM();}
~KeepAlive(){
KeepAliveDestructorMM();}#ifdef __APPLE__ void KeepAliveMM();void KeepAliveDestructorMM();#else// Keep other platforms alive#endif };#endif