summaryrefslogtreecommitdiffstats
path: root/kicker-applets/ktimemon/sample.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch)
tree2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /kicker-applets/ktimemon/sample.h
downloadtdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz
tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kicker-applets/ktimemon/sample.h')
-rw-r--r--kicker-applets/ktimemon/sample.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/kicker-applets/ktimemon/sample.h b/kicker-applets/ktimemon/sample.h
new file mode 100644
index 0000000..b4a0723
--- /dev/null
+++ b/kicker-applets/ktimemon/sample.h
@@ -0,0 +1,94 @@
+/* -*- C++ -*- */
+
+/**********************************************************************/
+/* TimeMon (c) 1994 Helmut Maierhofer */
+/* KDE-ified M. Maierhofer 1998 */
+/**********************************************************************/
+
+/*
+ * sample.h
+ *
+ * Definitions for the system dependent sampling class (currently relies
+ * on the linux /proc filesystem).
+ */
+
+#ifndef SAMPLE_H
+#define SAMPLE_H
+
+// -- global constants ---------------------------------------------------
+
+#define MAX_CPU 16 // max number of CPUS in an SMP machine
+ // we get the status for
+
+// -- forward declaration ------------------------------------------------
+class KTimeMon;
+
+#ifdef USE_SOLARIS
+struct kstat_ctl;
+#endif
+
+// -- class declaration --------------------------------------------------
+
+/*
+ * KSample
+ *
+ * This class is responsible for reading the /proc file system and parsing
+ * the system information.
+ */
+class KSample {
+public:
+ // -- Sample declaration -----------------------------------------------
+ struct Sample {
+ unsigned long cputotal;
+ unsigned long user, nice, kernel, iowait, idle;
+ int cpus;
+ unsigned long smptotal[MAX_CPU], smpbusy[MAX_CPU];
+ unsigned long mtotal, free, buffers, cached, mkernel, used;
+ unsigned long stotal, sused, sfree;
+
+ void fill(unsigned scale); // fill sample with some fake values
+ };
+
+ struct MemStats {
+ const char *name;
+ unsigned long *stat;
+ };
+
+ KSample(KTimeMon *timemon, bool autoScale, unsigned pageScale,
+ unsigned swapScale, unsigned ctxScale);
+ virtual ~KSample();
+
+ void setScaling(bool autoScale, unsigned pageScale,
+ unsigned swapScale, unsigned ctxScale);
+
+ Sample getSample(unsigned scale); // returns the current sample
+ Sample getRawSample(); // returns unscaled sample
+ void updateSample(); // updates the internally stored sample
+
+private:
+ void readSample(); // reads a new sample from /proc
+ unsigned long doScale(unsigned long value, unsigned scale1,
+ unsigned long scale2);
+ // converts pages to MB
+ void makeMBytes(unsigned long &pages);
+
+ void fatal(const QString& msg);
+ void nonfatal(const QString& msg);
+
+ KTimeMon *timemon;
+#ifdef __linux__
+ int memFD, statFD;
+#elif defined(USE_SOLARIS)
+ struct kstat_ctl *kc;
+ bool warned;
+#endif
+#if defined(USE_SOLARIS) || defined(__osf__)
+ unsigned long pagesPerMB;
+#endif
+ Sample sample, oldSample;
+ unsigned pageScale, swapScale, cxScale;
+ bool autoscale;
+ struct MemStats memstats[7];
+};
+
+#endif // SAMPLE_H