[gnome-system-monitor/wip/procinforefactor: 3/5] Consolidate MutableProcInfo into ProcInfo class



commit de5ebe123d072e94a70b4b40d1137c11fb77201e
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Sat Aug 3 14:49:28 2013 +0200

    Consolidate MutableProcInfo into ProcInfo class

 src/procinfo.cpp  |    7 +++++--
 src/procinfo.h    |   45 ++++++++++++++++-----------------------------
 src/proctable.cpp |    2 +-
 3 files changed, 22 insertions(+), 32 deletions(-)
---
diff --git a/src/procinfo.cpp b/src/procinfo.cpp
index 126c56c..892c725 100644
--- a/src/procinfo.cpp
+++ b/src/procinfo.cpp
@@ -162,13 +162,15 @@ get_process_memory_info(ProcInfo *info)
 }
 
 void
-update_info (ProcmanApp *app, ProcInfo *info)
+ProcInfo::update (ProcmanApp *app)
 {
     glibtop_proc_state procstate;
     glibtop_proc_uid procuid;
     glibtop_proc_time proctime;
     glibtop_proc_kernel prockernel;
 
+    ProcInfo *info = this;
+
     glibtop_get_proc_kernel(&prockernel, info->pid);
     g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
 
@@ -239,7 +241,8 @@ ProcInfo::set_user(guint uid)
 }
 
 ProcInfo::ProcInfo(pid_t pid)
-    : tooltip(NULL),
+    : status(0),
+      tooltip(NULL),
       name(NULL),
       arguments(NULL),
       security_context(NULL),
diff --git a/src/procinfo.h b/src/procinfo.h
index c3bd791..cf30f6c 100644
--- a/src/procinfo.h
+++ b/src/procinfo.h
@@ -8,12 +8,9 @@
 
 #include <procman-app.h>
 
-struct MutableProcInfo
+class ProcInfo
 {
-MutableProcInfo()
-: status(0)
-    { }
-
+  public:
     std::string user;
 
     gchar wchan[40];
@@ -45,20 +42,18 @@ MutableProcInfo()
     gchar *seat;
 
     std::string owner;
-};
-
 
-class ProcInfo
-: public MutableProcInfo
-{
-    /* undefined */ ProcInfo& operator=(const ProcInfo&);
-    /* undefined */ ProcInfo(const ProcInfo&);
+    GtkTreeIter     node;
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
 
-    typedef std::map<guint, std::string> UserMap;
-    /* cached username */
-    static UserMap users;
+    gchar           *security_context;
 
-  public:
+    const guint     pid;
+    guint           ppid;
+    guint           uid;
 
     // TODO: use a set instead
     // sorted by pid. The map has a nice property : it is sorted
@@ -73,7 +68,6 @@ class ProcInfo
     static Iterator begin() { return ProcInfo::all.begin(); }
     static Iterator end() { return ProcInfo::all.end(); }
 
-
     ProcInfo(pid_t pid);
     ~ProcInfo();
     // adds one more ref to icon
@@ -81,19 +75,13 @@ class ProcInfo
     void set_user(guint uid);
     std::string lookup_user(guint uid);
 
-    GtkTreeIter     node;
-    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
-    gchar           *tooltip;
-    gchar           *name;
-    gchar           *arguments;
+    void update (ProcmanApp *app);
 
-    gchar           *security_context;
-
-    const guint     pid;
-    guint           ppid;
-    guint           uid;
+ private:
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
 
-// private:
     // 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,
@@ -102,7 +90,6 @@ class ProcInfo
     static std::map<pid_t, guint64> cpu_times;
 };
 
-void update_info (ProcmanApp *app, ProcInfo *info);
 void get_process_memory_writable (ProcInfo *info);
 
 #endif /* _GSM_PROCINFO_H_ */
diff --git a/src/proctable.cpp b/src/proctable.cpp
index c179d2f..922523c 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -828,7 +828,7 @@ refresh_list (ProcmanApp *app, const pid_t* pid_list, const guint n)
             addition.push_back(info);
         }
 
-        update_info (app, info);
+        info->update (app);
     }
 
 


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