[gnome-system-monitor/wip/procinforefactor: 5/5] Really hide private data in implementation file



commit 289bd24db1a72cffc30187311c629337ffc800f6
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Sat Aug 3 15:17:06 2013 +0200

    Really hide private data in implementation file

 src/procinfo.cpp |   24 ++++++++++++++++--------
 src/procinfo.h   |   12 ------------
 2 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/src/procinfo.cpp b/src/procinfo.cpp
index d9841fa..e11ef52 100644
--- a/src/procinfo.cpp
+++ b/src/procinfo.cpp
@@ -30,10 +30,18 @@
 #include "selinux.h"
 #include "util.h"
 
+typedef std::map<guint, std::string> UserMap;
+/* cached username */
+static UserMap users;
+
+// tracks cpu time per process keeps growing because if a
+// ProcInfo is deleted this does not mean that the process is
+// not going to be recreated on the next update.  For example,
+// if dependencies + (My or Active), the proclist is cleared
+// on each update.  This is a workaround
+static std::map<pid_t, guint64> cpu_times;
 
-ProcInfo::UserMap ProcInfo::users;
 ProcInfo::List ProcInfo::all;
-std::map<pid_t, guint64> ProcInfo::cpu_times;
 
 ProcInfo* ProcInfo::find(pid_t pid)
 {
@@ -195,7 +203,7 @@ ProcInfo::update (ProcmanApp *app)
     if (not app->config.solaris_mode)
         info->pcpu *= app->config.num_cpus;
 
-    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    cpu_times[info->pid] = info->cpu_time = proctime.rtime;
     info->nice = procuid.nice;
     info->ppid = procuid.ppid;
 
@@ -208,9 +216,9 @@ ProcInfo::update (ProcmanApp *app)
 std::string
 ProcInfo::lookup_user(guint uid)
 {
-    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
-    ProcInfo::UserMap::value_type hint(uid, "");
-    Pair p(ProcInfo::users.insert(hint));
+    typedef std::pair<UserMap::iterator, bool> Pair;
+    UserMap::value_type hint(uid, "");
+    Pair p(users.insert(hint));
 
     // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
 
@@ -272,8 +280,8 @@ ProcInfo::ProcInfo(pid_t pid)
     g_strfreev(arguments);
 
     guint64 cpu_time = proctime.rtime;
-    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
-    if (it != ProcInfo::cpu_times.end())
+    std::map<pid_t, guint64>::iterator it(cpu_times.find(pid));
+    if (it != cpu_times.end())
     {
         if (proctime.rtime >= it->second)
             cpu_time = it->second;
diff --git a/src/procinfo.h b/src/procinfo.h
index 5fa2d5e..142e76a 100644
--- a/src/procinfo.h
+++ b/src/procinfo.h
@@ -77,18 +77,6 @@ class ProcInfo
 
     void update (ProcmanApp *app);
     void get_writable_memory ();
-
- private:
-    typedef std::map<guint, std::string> UserMap;
-    /* cached username */
-    static UserMap users;
-
-    // tracks cpu time per process keeps growing because if a
-    // ProcInfo is deleted this does not mean that the process is
-    // not going to be recreated on the next update.  For example,
-    // if dependencies + (My or Active), the proclist is cleared
-    // on each update.  This is a workaround
-    static std::map<pid_t, guint64> cpu_times;
 };
 
 #endif /* _GSM_PROCINFO_H_ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]