AppStatisticMonitor: add empty data provider for non-implemented OSes

Add a NullDataProvider to support building & running on OSes that
do not have an actual data provider implemented (currently Linux,
Windows, macOS).

Limit also the instantiation of a LinuxDataProvider to Linux, as that
data provider is built only on Linux.

Change-Id: Ia9bea9e6d76ee6558efe62e16a9fcf559ab0a4d7
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
Pino Toscano
2024-10-05 03:39:06 +02:00
parent 836d555742
commit 6c668279df

View File

@@ -329,14 +329,36 @@ private:
};
#endif
// ------------------------- NullDataProvider --------------------------------
class NullDataProvider : public IDataProvider
{
public:
NullDataProvider(qint64 pid, QObject *parent = nullptr)
: IDataProvider(pid, parent)
{}
double getCpuConsumption()
{
return 0.0;
}
double getMemoryConsumption()
{
return 0.0;
}
};
IDataProvider *createDataProvider(qint64 pid)
{
#ifdef Q_OS_WIN
return new WindowsDataProvider(pid);
#elif defined(Q_OS_MACOS)
return new MacDataProvider(pid);
#else // Q_OS_LINUX
#elif defined(Q_OS_LINUX)
return new LinuxDataProvider(pid);
#else
return new NullDataProvider(pid);
#endif
}