File indexing completed on 2024-04-28 16:49:55
0001 /* 0002 SPDX-FileCopyrightText: 2007 John Tapsell <tapsell@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef PROCESSES_ATOP_H_ 0008 #define PROCESSES_ATOP_H_ 0009 0010 #include "processes_base_p.h" 0011 #include <unistd.h> //For sysconf 0012 0013 #include <QSet> 0014 class QDateTime; 0015 0016 namespace KSysGuard 0017 { 0018 class Process; 0019 0020 /** 0021 * This is the ATOP specific code to get process information for the local host. 0022 */ 0023 class ProcessesATop : public AbstractProcesses 0024 { 0025 public: 0026 explicit ProcessesATop(bool loadDefaultFile = true); 0027 ~ProcessesATop() override; 0028 QSet<long> getAllPids() override; 0029 long getParentPid(long pid) override; 0030 bool updateProcessInfo(long pid, Process *process) override; 0031 Processes::Error sendSignal(long pid, int sig) override; 0032 Processes::Error setNiceness(long pid, int priority) override; 0033 Processes::Error setScheduler(long pid, int priorityClass, int priority) override; 0034 long long totalPhysicalMemory() override; 0035 Processes::Error setIoNiceness(long pid, int priorityClass, int priority) override; 0036 bool supportsIoNiceness() override; 0037 long numberProcessorCores() override 0038 #ifdef _SC_NPROCESSORS_ONLN 0039 { 0040 return sysconf(_SC_NPROCESSORS_ONLN); 0041 } // Should work on any recent posix system 0042 #else 0043 ; 0044 #endif 0045 void updateAllProcesses(Processes::UpdateFlags updateFlags) override 0046 { 0047 mUpdateFlags = updateFlags; 0048 emit processesUpdated(); 0049 } // For local machine, there is no delay 0050 0051 bool isHistoryAvailable() const; 0052 QDateTime viewingTime() const; 0053 bool setViewingTime(const QDateTime &when); 0054 QList<QPair<QDateTime, uint>> historiesAvailable() const; 0055 bool loadHistoryFile(const QString &filename); 0056 QString historyFileName() const; 0057 0058 private: 0059 /** 0060 * You can use this for whatever data you want. 0061 * Be careful about preserving state in between getParentPid and updateProcessInfo calls 0062 * if you chose to do that. getParentPid may be called several times 0063 * for different pids before the relevant updateProcessInfo calls are made. 0064 * This is because the tree structure has to be sorted out first. 0065 */ 0066 class Private; 0067 Private *d; 0068 Processes::UpdateFlags mUpdateFlags; 0069 }; 0070 } 0071 #endif