add more spacing
[personal-kdebase.git] / workspace / libs / ksysguard / processcore / processes_base_p.h
blob5acd9568bf1f2a9fc306d59eeaed216d14f80f80
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.
22 #ifndef PROCESSES_BASE_P_H
23 #define PROCESSES_BASE_P_H
25 #include <QSet>
26 #include <QObject>
28 namespace KSysGuard
30 class Process;
31 /**
32 * This class contains the specific code to get the processes from the given host.
34 * To port this to other operating systems you need to make a processes_(osname).cpp file
35 * which implements all of the function below. If you need private functions/variables etc put them in
36 * the Private class.
38 * @author John Tapsell <tapsell@kde.org>
40 class AbstractProcesses : public QObject
42 Q_OBJECT
44 public:
46 AbstractProcesses() {}
47 virtual ~AbstractProcesses() {}
48 /**
49 * To get information about processes, this will be the first function called.
51 virtual QSet<long> getAllPids() = 0;
52 /**
53 * For each of the pids that getAllPids() returns, getParentPid will be called. This is used to setup the tree structure.
54 * For a particular pid, this is guaranteed to be called before updateProcessInfo for that pid.
55 * However this may be called several times in a row before the updateProcessInfo is called, so be careful
56 * if you want to try to preserve state in Private.
58 virtual long getParentPid(long pid) = 0;
59 /**
60 * This will be called for every pid, after getParentPid() has been called for the same parameter.
62 * The process->pid process->ppid and process->parent are all guaranteed to be filled in correctly and process->parent
63 * will be non null.
64 */
65 virtual bool updateProcessInfo(long pid, Process *process) = 0;
66 /**
67 * Send the specified named POSIX signal to the process given.
69 * For example, to indicate for process 324 to STOP do:
70 * \code
71 * #include <signals.h>
72 * ...
74 * KSysGuard::Processes::sendSignal(23, SIGSTOP);
75 * \endcode
78 virtual bool sendSignal(long pid, int sig) = 0;
80 /**
81 * Set the priority for a process. For the normal scheduler, this is usually from 19
82 * (very nice, lowest priority) to -20 (highest priority). The default value for a process is 0.
84 * This has no effect if the scheduler is not the normal one (SCHED_OTHER)
86 * @return false if you do not have permission to set the priority
88 virtual bool setNiceness(long pid, int priority) = 0;
90 /**
91 * Set the scheduler for a process. This is defined according to POSIX.1-2001
92 * See "man sched_setscheduler" for more information.
94 * @p priorityClass One of SCHED_FIFO, SCHED_RR, SCHED_OTHER, and SCHED_BATCH
95 * @p priority Set to 0 for SCHED_OTHER and SCHED_BATCH. Between 1 and 99 for SCHED_FIFO and SCHED_RR
96 * @return false if you do not have permission to set the priority
98 virtual bool setScheduler(long pid, int priorityClass, int priority) = 0;
101 * Return the total amount of physical memory in KB. This is fast (just a system call)
102 * Returns 0 on error
104 virtual long long totalPhysicalMemory() = 0;
107 * Set the io priority for a process. This is from 7 (very nice, lowest io priority) to
108 * 0 (highest priority). The default value is determined as: io_nice = (cpu_nice + 20) / 5.
110 * @return false if you do not have permission to set the priority
112 virtual bool setIoNiceness(long pid, int priorityClass, int priority) = 0;
115 * Returns true if ionice is supported on this system
117 virtual bool supportsIoNiceness() = 0;
120 * Return the number of processor cores enabled.
121 * (A system can disable procesors. Disabled processors are not counted here).
122 * This is fast (just a system call) */
123 virtual long numberProcessorCores() = 0;
126 * Get all the current process information from the machine. When done, emit updateAllProcesses().
128 virtual void updateAllProcesses() = 0;
130 Q_SIGNALS:
132 * This is emitted when the processes have been updated, and the view should be refreshed
134 void processesUpdated();
139 #endif // PROCESSES_BASE_P_H