add more spacing
[personal-kdebase.git] / workspace / libs / ksysguard / processcore / process.h
bloba1f4c6016aee527e7baef032ca2c4e7971cd2e3b
1 /* This file is part of the KDE project
3 Copyright (C) 2007 John Tapsell <tapsell@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef PROCESS_H_
22 #define PROCESS_H_
24 #include <kdemacros.h>
26 #include <QtCore/QList>
27 #include <QtCore/QTime>
28 #include <QtCore/QFlags>
30 #include <klocale.h>
33 namespace KSysGuard
36 class KDE_EXPORT Process {
37 public:
38 enum ProcessStatus { Running, Sleeping, DiskSleep, Zombie, Stopped, Paging, OtherStatus };
39 enum IoPriorityClass { None, RealTime, BestEffort, Idle };
40 enum Scheduler { Other = 0, Fifo, RoundRobin, Batch };
41 Process();
42 Process(long long _pid, long long _ppid, Process *_parent);
44 long pid; ///The system's ID for this process. 1 for init. 0 for our virtual 'parent of init' process used just for convience.
45 long parent_pid; ///The system's ID for the parent of this process. 0 for init.
47 /** A guaranteed NON-NULL pointer for all real processes to the parent process except for the fake process with pid 0.
48 * The Parent's pid is the same value as the parent_pid. The parent process will be also pointed
49 * to by ProcessModel::mPidToProcess to there is no need to worry about mem management in using parent.
50 * For init process, parent will point to a (fake) process with pid 0 to simplify things.
51 * For the fake process, this will point to NULL
53 Process *parent;
55 void setLogin(QString _login); ///The user login name. Only used for processes on remote machines. Otherwise use uid to get the name
56 void setUid(long long _uid); ///The user id that the process is running as
57 void setEuid(long long _euid); ///The effective user id that the process is running as
58 void setSuid(long long _suid); ///The set user id that the process is running as
59 void setFsuid(long long _fsuid); ///The file system user id that the process is running as.
61 void setGid(long long _gid); ///The process group id that the process is running as
62 void setEgid(long long _egid); ///The effective group id that the process is running as
63 void setSgid(long long _sgid); ///The set group id that the process is running as
64 void setFsgid(long long _fsgid); ///The file system group id that the process is running as
66 void setTracerpid(long long _tracerpid); ///If this is being debugged, this is the process that is debugging it
67 void setTty(QByteArray _tty); /// The name of the tty the process owns
68 void setUserTime(long long _userTime); ///The time, in 100ths of a second, spent in total on user calls. -1 if not known
69 void setSysTime(long long _sysTime); ///The time, in 100ths of a second, spent in total on system calls. -1 if not known
70 void setUserUsage(int _userUsage); ///Percentage (0 to 100). It might be more than 100% on multiple cpu core systems
71 void setSysUsage(int _sysUsage); ///Percentage (0 to 100). It might be more than 100% on multiple cpu core systems
72 void setTotalUserUsage(int _totalUserUsage); ///Percentage (0 to 100) from the sum of itself and all its children recursively. If there's no children, it's equal to userUsage. It might be more than 100% on multiple cpu core systems
73 void setTotalSysUsage(int _totalSysUsage); ///Percentage (0 to 100) from the sum of itself and all its children recursively. If there's no children, it's equal to sysUsage. It might be more than 100% on multiple cpu core systems
74 void setNiceLevel(int _niceLevel); ///If Scheduler = Other, niceLevel is the niceness (-20 to 20) of this process. A lower number means a higher priority. Otherwise sched priority (1 to 99)
75 void setscheduler(Scheduler _scheduler); ///The scheduler this process is running in. See man sched_getscheduler for more info
76 void setIoPriorityClass(IoPriorityClass _ioPriorityClass); /// The IO priority class. See man ionice for detailed information.
77 void setIoniceLevel(int _ioniceLevel); ///IO Niceness (0 to 7) of this process. A lower number means a higher io priority. -1 if not known or not applicable because ioPriorityClass is Idle or None
78 void setVmSize(long _vmSize); ///Virtual memory size in KiloBytes, including memory used, mmap'ed files, graphics memory etc,
79 void setVmRSS(long _vmRSS); ///Physical memory used by the process and its shared libraries. If the process and libraries are swapped to disk, this could be as low as 0
80 void setVmURSS(long _vmURSS); ///Physical memory used only by the process, and not counting the code for shared libraries. Set to -1 if unknown
81 void setName(QString _name); ///The name (e.g. "ksysguard", "konversation", "init")
82 void setCommand(QString _command); ///The command the process was launched with
83 void setStatus( ProcessStatus _status); ///Whether the process is running/sleeping/etc
87 QString login;
88 long long uid;
89 long long euid;
90 long long suid;
91 long long fsuid;
93 long long gid;
94 long long egid;
95 long long sgid;
96 long long fsgid;
98 long long tracerpid;
99 QByteArray tty;
100 long long userTime;
101 long long sysTime;
102 int userUsage;
103 int sysUsage;
104 int totalUserUsage;
105 int totalSysUsage;
106 unsigned long numChildren;
107 int niceLevel;
108 Scheduler scheduler;
109 IoPriorityClass ioPriorityClass;
110 int ioniceLevel;
111 long vmSize;
112 long vmRSS;
113 long vmURSS;
114 QString name;
115 QString command;
116 ProcessStatus status;
118 QList<Process *> children; ///A list of all the direct children that the process has. Children of children are not listed here, so note that children_pids <= numChildren
119 QTime timeKillWasSent; /// This is usually a NULL time. When trying to kill a process, this is the time that the kill signal was sent to the process.
121 QString translatedStatus() const; /// Returns a translated string of the status. e.g. "Running" etc
122 QString niceLevelAsString() const; /// Returns a simple translated string of the nice priority. e.g. "Normal", "High", etc
123 QString ioniceLevelAsString() const; /// Returns a simple translated string of the io nice priority. e.g. "Normal", "High", etc
124 QString ioPriorityClassAsString() const; /// Returns a translated string of the io nice class. i.e. "None", "Real Time", "Best Effort", "Idle"
125 QString schedulerAsString() const; /// Returns a translated string of the scheduler class. e.g. "FIFO", "Round Robin", "Batch"
127 int index; /// Each process has a parent process. Each sibling has a unique number to identify it under that parent. This is that number.
129 /** An enum to keep track of what changed since the last update. Note that we
130 * the maximum we can use is 0x4000, so some of the enums represent multiple variables
132 enum Change {
133 Nothing = 0x0,
134 Uids = 0x1,
135 Gids = 0x2,
136 Tracerpid = 0x4,
137 Tty = 0x8,
138 Usage = 0x10,
139 TotalUsage = 0x20,
140 NiceLevels = 0x40,
141 VmSize = 0x80,
142 VmRSS = 0x100,
143 VmURSS = 0x200,
144 Name = 0x400,
145 Command = 0x800,
146 Status = 0x1000,
147 Login = 0x2000
149 Q_DECLARE_FLAGS(Changes, Change)
151 Changes changes; /** A QFlags representing what has changed */
154 private:
155 void clear();
157 Q_DECLARE_OPERATORS_FOR_FLAGS(Process::Changes)
160 #endif