1 /* 2 SPDX-FileCopyrightText: 2007 John Tapsell <tapsell@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #ifndef PROCESSES_ATOP_H_ 8 #define PROCESSES_ATOP_H_ 9 10 #include "processes_base_p.h" 11 #include <unistd.h> //For sysconf 12 13 #include <QSet> 14 class QDateTime; 15 16 namespace KSysGuard 17 { 18 class Process; 19 20 /** 21 * This is the ATOP specific code to get process information for the local host. 22 */ 23 class ProcessesATop : public AbstractProcesses 24 { 25 public: 26 explicit ProcessesATop(bool loadDefaultFile = true); 27 ~ProcessesATop() override; 28 QSet<long> getAllPids() override; 29 long getParentPid(long pid) override; 30 bool updateProcessInfo(long pid, Process *process) override; 31 Processes::Error sendSignal(long pid, int sig) override; 32 Processes::Error setNiceness(long pid, int priority) override; 33 Processes::Error setScheduler(long pid, int priorityClass, int priority) override; 34 long long totalPhysicalMemory() override; 35 Processes::Error setIoNiceness(long pid, int priorityClass, int priority) override; 36 bool supportsIoNiceness() override; numberProcessorCores()37 long numberProcessorCores() override 38 #ifdef _SC_NPROCESSORS_ONLN 39 { 40 return sysconf(_SC_NPROCESSORS_ONLN); 41 } // Should work on any recent posix system 42 #else 43 ; 44 #endif updateAllProcesses(Processes::UpdateFlags updateFlags)45 void updateAllProcesses(Processes::UpdateFlags updateFlags) override 46 { 47 mUpdateFlags = updateFlags; 48 emit processesUpdated(); 49 } // For local machine, there is no delay 50 51 bool isHistoryAvailable() const; 52 QDateTime viewingTime() const; 53 bool setViewingTime(const QDateTime &when); 54 QList<QPair<QDateTime, uint>> historiesAvailable() const; 55 bool loadHistoryFile(const QString &filename); 56 QString historyFileName() const; 57 58 private: 59 /** 60 * You can use this for whatever data you want. 61 * Be careful about preserving state in between getParentPid and updateProcessInfo calls 62 * if you chose to do that. getParentPid may be called several times 63 * for different pids before the relevant updateProcessInfo calls are made. 64 * This is because the tree structure has to be sorted out first. 65 */ 66 class Private; 67 Private *d; 68 Processes::UpdateFlags mUpdateFlags; 69 }; 70 } 71 #endif 72