1 /* BEGIN_COMMON_COPYRIGHT_HEADER 2 * (c)LGPL2+ 3 ** 4 ** SysStat is a Qt-based interface to system statistics 5 ** 6 ** Authors: 7 ** Copyright (c) 2009 - 2012 Kuzma Shapran <Kuzma.Shapran@gmail.com> 8 ** 9 ** This library is free software; you can redistribute it and/or 10 ** modify it under the terms of the GNU Lesser General Public 11 ** License as published by the Free Software Foundation; either 12 ** version 2.1 of the License, or (at your option) any later version. 13 ** 14 ** This library is distributed in the hope that it will be useful, 15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 ** Lesser General Public License for more details. 18 ** 19 ** You should have received a copy of the GNU Lesser General Public 20 ** License along with this library; 21 ** if not, write to the Free Software Foundation, Inc., 22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 ** 24 ** END_COMMON_COPYRIGHT_HEADER */ 25 26 27 #ifndef LIBSYSSTAT__CPU_STAT__INCLUDED 28 #define LIBSYSSTAT__CPU_STAT__INCLUDED 29 30 #ifdef HAVE_CONFIG_H 31 #include "config.h" 32 #endif 33 #include <QtCore/QObject> 34 35 #include "basestat.h" 36 37 38 namespace SysStat { 39 #ifdef HAVE_SYSCTL_H 40 char *GetFirstFragment(char *string, const char *delim); 41 int GetCpu(void); 42 #endif 43 class CpuStatPrivate; 44 45 class SYSSTATSHARED_EXPORT CpuStat : public BaseStat 46 { 47 Q_OBJECT 48 49 Q_ENUMS(Monitoring) 50 51 public: 52 enum Monitoring { LoadAndFrequency, LoadOnly, FrequencyOnly }; 53 54 public: 55 CpuStat(QObject *parent = nullptr); 56 ~CpuStat() override; 57 58 void updateSources(); 59 60 uint minFreq(const QString &source) const; 61 uint maxFreq(const QString &source) const; 62 signals: 63 void update(float user, float nice, float system, float other, float frequencyRate, uint frequency); 64 void update(float user, float nice, float system, float other); 65 void update(uint frequency); 66 67 void monitoringChanged(Monitoring); 68 69 public: 70 Q_PROPERTY(Monitoring monitoring READ monitoring WRITE setMonitoring NOTIFY monitoringChanged) 71 72 public slots: 73 Monitoring monitoring() const; 74 void setMonitoring(Monitoring value); 75 76 protected: 77 CpuStatPrivate* impl; 78 }; 79 80 } 81 82 #endif //LIBSYSSTAT__CPU_STAT__INCLUDED 83