Let's take a look at the Mac implementation of the SysInfo class. Start by creating a new C++ class named SysInfoMacImpl that inherits from the SysInfo class. Override SysInfo virtual functions and you should have a SysInfoMacImpl.h file like this:
#include "SysInfo.h" #include <QtGlobal> #include <QVector> class SysInfoMacImpl : public SysInfo { public: SysInfoMacImpl(); void init() override; double cpuLoadAverage() override; double memoryUsed() override; };
The first implementation we will do will be the memoryUsed() function, in the SysInfoMacImpl.cpp file:
#include <mach/vm_statistics.h> #include <mach/mach_types.h> #include <mach/mach_init.h> #include <mach/mach_host.h> #include <mach/vm_map.h> SysInfoMacImpl::SysInfoMacImpl() ...