[gnome-usage] process: Replace getters and setter with properties



commit 1b2cad22e153c89792c5759593a4d80ee55322b7
Author: Petr Štětka <pstetka redhat com>
Date:   Fri May 26 14:06:55 2017 +0200

    process: Replace getters and setter with properties
    
    Instead of use variables and getters and setters we can use
    properties. This change will alow easier coding for as.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781542

 src/cpu-monitor.vala          |   14 ++--
 src/memory-monitor.vala       |    4 +-
 src/process-dialog.vala       |   10 +-
 src/process-list-box.vala     |   34 ++++----
 src/process-row.vala          |   26 +++---
 src/process.vala              |  183 ++++++-----------------------------------
 src/sub-process-list-box.vala |    8 +-
 src/sub-process-sub-row.vala  |   12 ++--
 src/system-monitor.vala       |  117 +++++++++++++-------------
 9 files changed, 136 insertions(+), 272 deletions(-)
---
diff --git a/src/cpu-monitor.vala b/src/cpu-monitor.vala
index 142f6fe..3a0b563 100644
--- a/src/cpu-monitor.vala
+++ b/src/cpu-monitor.vala
@@ -73,15 +73,15 @@ namespace Usage
             GTop.ProcTime proc_time;
             GTop.ProcState proc_state;
 
-            GTop.get_proc_time (out proc_time, process.get_pid());
-            GTop.get_proc_state (out proc_state, process.get_pid());
+            GTop.get_proc_time (out proc_time, process.pid);
+            GTop.get_proc_state (out proc_state, process.pid);
 
-            process.set_last_processor(proc_state.last_processor);
-            double cpu_load = (((double) (proc_time.rtime - process.get_cpu_last_used())) / 
cpu_last_total_step) * 100 * get_num_processors();
+            process.last_processor = proc_state.last_processor;
+            double cpu_load = (((double) (proc_time.rtime - process.cpu_last_used)) / cpu_last_total_step) * 
100 * get_num_processors();
             cpu_load = double.min(100, cpu_load);
-            process.set_cpu_load(cpu_load);
-            process.set_cpu_last_used(proc_time.rtime);
-            process.set_x_cpu_last_used(proc_time.xcpu_utime[process.get_last_processor()] + 
proc_time.xcpu_stime[process.get_last_processor()]);
+            process.cpu_load = cpu_load;
+            process.cpu_last_used = proc_time.rtime;
+            process.x_cpu_last_used = proc_time.xcpu_utime[process.last_processor] + 
proc_time.xcpu_stime[process.last_processor];
         }
     }
 }
diff --git a/src/memory-monitor.vala b/src/memory-monitor.vala
index 4327626..204e776 100644
--- a/src/memory-monitor.vala
+++ b/src/memory-monitor.vala
@@ -65,9 +65,9 @@ namespace Usage
             GTop.ProcMem proc_mem;
 
             GTop.get_mem (out mem);
-            GTop.get_proc_mem (out proc_mem, process.get_pid());
+            GTop.get_proc_mem (out proc_mem, process.pid);
 
-            process.set_mem_usage(proc_mem.resident - proc_mem.share);
+            process.mem_usage = proc_mem.resident - proc_mem.share;
         }
     }
 }
diff --git a/src/process-dialog.vala b/src/process-dialog.vala
index 8d2b56a..fee9c59 100644
--- a/src/process-dialog.vala
+++ b/src/process-dialog.vala
@@ -75,12 +75,12 @@ namespace Usage
 
             if(data != null)
             {
-                app_cpu_load = (int) data.get_cpu_load();
-                app_memory_usage = data.get_mem_usage();
-                int processor_other = (int) monitor.x_cpu_load[data.get_last_processor()] - app_cpu_load;
+                app_cpu_load = (int) data.cpu_load;
+                app_memory_usage = data.mem_usage;
+                int processor_other = (int) monitor.x_cpu_load[data.last_processor] - app_cpu_load;
                 processor_other = int.max(processor_other, 0);
-                processor_graph_block.update(app_cpu_load, processor_other, 100, (int) 
data.get_last_processor());
-                process_status = data.get_status();
+                processor_graph_block.update(app_cpu_load, processor_other, 100, (int) data.last_processor);
+                process_status = data.status;
             }
             else
                 processor_graph_block.update(0, (int) monitor.cpu_load, 100);
diff --git a/src/process-list-box.vala b/src/process-list-box.vala
index a83cf45..41ac03e 100644
--- a/src/process-list-box.vala
+++ b/src/process-list-box.vala
@@ -49,7 +49,7 @@ namespace Usage
                 if(opened_row != process_row)
                 {
                     process_row.activate();
-                    if(process_row.process.get_sub_processes() != null)
+                    if(process_row.process.sub_processes != null)
                         opened_row = process_row;
                     else
                         opened_row = null;
@@ -62,7 +62,7 @@ namespace Usage
             {
                 if(child != null)
                 {
-                    focused_row_cmdline = ((ProcessRow) child).process.get_cmdline();
+                    focused_row_cmdline = ((ProcessRow) child).process.cmdline;
                     //GLib.stdout.printf("focused: " + focused_row_cmdline+ "\n");
                 }
             });
@@ -78,18 +78,18 @@ namespace Usage
 
         public bool update()
         {
-               CompareDataFunc<Process> processcmp = (a, b) => {
-               Process p_a = (Process) a;
-               Process p_b = (Process) b;
-
-               switch(type)
-               {
-                       default:
-                       case ProcessListBoxType.PROCESSOR:
-                       return (int) ((uint64) (p_a.get_cpu_load() < p_b.get_cpu_load()) - (uint64) 
(p_a.get_cpu_load() > p_b.get_cpu_load()));
-                       case ProcessListBoxType.MEMORY:
-                       return (int) ((uint64) (p_a.get_mem_usage() < p_b.get_mem_usage()) - (uint64) 
(p_a.get_mem_usage() > p_b.get_mem_usage()));
-               }
+            CompareDataFunc<Process> processcmp = (a, b) => {
+                Process p_a = (Process) a;
+                Process p_b = (Process) b;
+
+                switch(type)
+                {
+                    default:
+                    case ProcessListBoxType.PROCESSOR:
+                        return (int) ((uint64) (p_a.cpu_load < p_b.cpu_load) - (uint64) (p_a.cpu_load > 
p_b.cpu_load));
+                    case ProcessListBoxType.MEMORY:
+                        return (int) ((uint64) (p_a.mem_usage < p_b.mem_usage) - (uint64) (p_a.mem_usage > 
p_b.mem_usage));
+                }
             };
 
             bind_model(null, null);
@@ -115,7 +115,7 @@ namespace Usage
             {
                 foreach(unowned Process process in system_monitor.get_ram_processes()) //because ram 
contains all processes
                 {
-                    if(process.get_display_name().down().contains(search_text.down()) || 
process.get_cmdline().down().contains(search_text.down()))
+                    if(process.display_name.down().contains(search_text.down()) || 
process.cmdline.down().contains(search_text.down()))
                         model.insert_sorted(process, processcmp);
                 }
             }
@@ -138,7 +138,7 @@ namespace Usage
             bool opened = false;
 
             if(opened_row != null)
-                if(process.get_cmdline() == opened_row.process.get_cmdline())
+                if(process.cmdline == opened_row.process.cmdline)
                     opened = true;
 
             var row = new ProcessRow(process, type, opened);
@@ -147,7 +147,7 @@ namespace Usage
 
             if(focused_row_cmdline != null)
             {
-                if(process.get_cmdline() == focused_row_cmdline)
+                if(process.cmdline == focused_row_cmdline)
                 {
                     //row.grab_focus(); TODO not working
                     //GLib.stdout.printf("grab focus for: " + focused_row_cmdline+ "\n");
diff --git a/src/process-row.vala b/src/process-row.vala
index 3ec5d33..6de92bb 100644
--- a/src/process-row.vala
+++ b/src/process-row.vala
@@ -45,7 +45,7 @@ namespace Usage
         public bool max_usage { get; private set; }
         public bool group {
             get {
-                return process.get_sub_processes() != null;
+                return process.sub_processes != null;
             }
         }
 
@@ -58,7 +58,7 @@ namespace Usage
             this.process = process;
             showing_details = opened;
 
-            load_icon(process.get_display_name());
+            load_icon(process.display_name);
             sub_process_list_box.init(process, type);
             update();
 
@@ -115,9 +115,9 @@ namespace Usage
         private void update_title_label()
         {
             if(group)
-                title_label.label = process.get_display_name() + " (" + 
process.get_sub_processes().size().to_string() + ")";
+                title_label.label = process.display_name + " (" + process.sub_processes.size().to_string() + 
")";
             else
-                title_label.label = process.get_display_name();
+                title_label.label = process.display_name;
         }
 
         private void update_load_label()
@@ -133,8 +133,8 @@ namespace Usage
                     {
                         string values_string = "";
                         var values = new GLib.List<uint64?>();
-                        foreach(Process sub_process in process.get_sub_processes().get_values())
-                            values.insert_sorted((uint64) sub_process.get_cpu_load(), sort);
+                        foreach(Process sub_process in process.sub_processes.get_values())
+                            values.insert_sorted((uint64) sub_process.cpu_load, sort);
 
                         foreach(uint64 value in values)
                             values_string += "   " + value.to_string() + " %";
@@ -142,15 +142,15 @@ namespace Usage
                         load_label.label = values_string;
                     }
                     else
-                        load_label.label = ((int) process.get_cpu_load()).to_string() + " %";
+                        load_label.label = ((int) process.cpu_load).to_string() + " %";
                     break;
                 case ProcessListBoxType.MEMORY:
                     if(group)
                     {
                         string values_string = "";
                         var values = new GLib.List<uint64?>();
-                        foreach(Process sub_process in process.get_sub_processes().get_values())
-                            values.insert_sorted(sub_process.get_mem_usage(), sort);
+                        foreach(Process sub_process in process.sub_processes.get_values())
+                            values.insert_sorted(sub_process.mem_usage, sort);
 
                         foreach(uint64 value in values)
                             values_string += "   " + Utils.format_size_values(value);
@@ -158,7 +158,7 @@ namespace Usage
                         load_label.label = values_string;
                     }
                     else
-                        load_label.label = Utils.format_size_values(process.get_mem_usage());
+                        load_label.label = Utils.format_size_values(process.mem_usage);
                     break;
             }
         }
@@ -168,7 +168,7 @@ namespace Usage
             switch(type)
             {
                 case ProcessListBoxType.PROCESSOR:
-                    if(process.get_cpu_load() >= MAX_CPU_USAGE_LIMIT)
+                    if(process.cpu_load >= MAX_CPU_USAGE_LIMIT)
                         max_usage = true;
                     else
                         max_usage = false;
@@ -177,7 +177,7 @@ namespace Usage
                 case ProcessListBoxType.MEMORY:
                     SystemMonitor monitor = SystemMonitor.get_default();
 
-                    if((((double) process.get_mem_usage() / monitor.ram_total) * 100) >= 
MAX_MEMORY_USAGE_LIMIT)
+                    if((((double) process.mem_usage / monitor.ram_total) * 100) >= MAX_MEMORY_USAGE_LIMIT)
                         max_usage = true;
                     else
                         max_usage = false;
@@ -214,7 +214,7 @@ namespace Usage
             }
             else
             {
-                var dialog = new ProcessDialog(process.get_pid(), process.get_display_name(), 
process.get_cmdline());
+                var dialog = new ProcessDialog(process.pid, process.display_name, process.cmdline);
                 dialog.show_all();
             }
         }
diff --git a/src/process.vala b/src/process.vala
index 78a0689..9dcc6fe 100644
--- a/src/process.vala
+++ b/src/process.vala
@@ -22,177 +22,42 @@ namespace Usage
 {
     public class Process : Object
     {
-        Pid pid;
-        string cmdline;
-        string cmdline_parameter; //Isn't parameters as "-p" etc, but parameter for running app, for ex. 
"--writer' with libreoffice, or "privacy" with gnome-control-center
-        string display_name;
-        double cpu_load;
-        double x_cpu_load;
-        uint64 cpu_last_used;
-        uint64 x_cpu_last_used;
-        uint last_processor;
-        uint64 mem_usage;
-        HashTable<Pid?, Process>? sub_processes;
-        bool alive;
-        ProcessStatus status;
+        public Pid pid { get; private set; }
+        public string cmdline { get; private set; }
+        public string cmdline_parameter { get; private set; } //Isn't parameters as "-p" etc, but parameter 
for running app, for ex. "--writer' with libreoffice, or "privacy" with gnome-control-center
+        public string display_name { get; private set; }
 
-        public Process(Pid pid, string cmdline, string cmdline_parameter, string display_name)
-        {
-            this.pid = pid;
-            this.cmdline = cmdline;
-            this.cmdline_parameter = cmdline_parameter;
-            this.display_name = display_name;
-            this.cpu_load = 0;
-            this.x_cpu_load = 0;
-            this.cpu_last_used = 0;
-            this.x_cpu_last_used = 0;
-            this.last_processor = 0;
-            this.mem_usage = 0;
-            this.sub_processes = null;
-            this.alive = true;
-            this.status = ProcessStatus.SLEEPING;
-        }
+        public double cpu_load { get; set; default = 0; }
+        public double x_cpu_load { get; set; default = 0; }
+        public uint64 cpu_last_used { get; set; default = 0; }
+        public uint64 x_cpu_last_used { get; set; default = 0; }
+        public uint last_processor { get; set; default = 0; }
 
-        public void update_from_process(Process process)
-        {
-            this.last_processor = process.get_last_processor();
-            this.cpu_load = process.get_cpu_load();
-            this.x_cpu_load = process.get_x_cpu_load();
-            this.cpu_last_used = process.get_cpu_last_used();
-            this.x_cpu_last_used = process.get_x_cpu_last_used();
-            this.mem_usage = process.get_mem_usage();
-            this.alive = process.get_alive();
-            this.status = process.get_status();
-        }
+        public uint64 mem_usage { get; set; default = 0; }
 
-        public Pid get_pid()
-        {
-            return pid;
-        }
-
-        public void set_pid(Pid pid)
-        {
-            this.pid = pid;
-        }
+        public HashTable<Pid?, Process>? sub_processes { get; set; }
 
-        public string get_cmdline()
-        {
-            return cmdline;
-        }
+        public bool alive { get; set; default = true; }
+        public ProcessStatus status { get; set; default = ProcessStatus.SLEEPING; }
 
-        public void set_cmdline(string cmdline)
+        public Process(Pid pid, string cmdline, string cmdline_parameter, string display_name)
         {
+            this.pid = pid;
             this.cmdline = cmdline;
-        }
-
-        public string get_cmdline_parameter()
-        {
-            return cmdline_parameter;
-        }
-
-        public void set_cmdline_parameter(string cmdline_parameter)
-        {
             this.cmdline_parameter = cmdline_parameter;
-        }
-
-        public string get_display_name()
-        {
-            return display_name;
-        }
-
-        public void set_display_name(string display_name)
-        {
             this.display_name = display_name;
         }
 
-        public double get_cpu_load()
-        {
-            return cpu_load;
-        }
-
-        public void set_cpu_load(double cpu_load)
-        {
-            this.cpu_load = cpu_load;
-        }
-
-        public double get_x_cpu_load()
-        {
-            return x_cpu_load;
-        }
-
-        public void set_x_cpu_load(double x_cpu_load)
-        {
-            this.x_cpu_load = x_cpu_load;
-        }
-
-        public uint64 get_cpu_last_used()
-        {
-            return cpu_last_used;
-        }
-
-        public void set_cpu_last_used(uint64 cpu_last_used)
-        {
-            this.cpu_last_used = cpu_last_used;
-        }
-
-        public uint64 get_x_cpu_last_used()
-        {
-            return x_cpu_last_used;
-        }
-
-        public void set_x_cpu_last_used(uint64 x_cpu_last_used)
-        {
-            this.x_cpu_last_used = x_cpu_last_used;
-        }
-
-        public uint get_last_processor()
-        {
-            return last_processor;
-        }
-
-        public void set_last_processor(uint last_processor)
-        {
-            this.last_processor = last_processor;
-        }
-
-        public uint64 get_mem_usage()
-        {
-            return mem_usage;
-        }
-
-        public void set_mem_usage(uint64 mem_usage)
-        {
-            this.mem_usage = mem_usage;
-        }
-
-        public HashTable<Pid?, Process>? get_sub_processes()
-        {
-            return sub_processes;
-        }
-
-        public void set_sub_processes(HashTable<Pid?, Process>? sub_processes)
-        {
-            this.sub_processes = sub_processes;
-        }
-
-        public bool get_alive()
-        {
-            return alive;
-        }
-
-        public void set_alive(bool alive)
-        {
-            this.alive = alive;
-        }
-
-        public ProcessStatus get_status()
-        {
-            return status;
-        }
-
-        public void set_status(ProcessStatus status)
+        public void update_from_process(Process process)
         {
-            this.status = status;
+            this.last_processor = process.last_processor;
+            this.cpu_load = process.cpu_load;
+            this.x_cpu_load = process.x_cpu_load;
+            this.cpu_last_used = process.cpu_last_used;
+            this.x_cpu_last_used = process.x_cpu_last_used;
+            this.mem_usage = process.mem_usage;
+            this.alive = process.alive;
+            this.status = process.status;
         }
     }
 
diff --git a/src/sub-process-list-box.vala b/src/sub-process-list-box.vala
index a001ea9..11331a3 100644
--- a/src/sub-process-list-box.vala
+++ b/src/sub-process-list-box.vala
@@ -63,15 +63,15 @@ namespace Usage
                 {
                     default:
                     case ProcessListBoxType.PROCESSOR:
-                        return (int) ((uint64) (p_a.get_cpu_load() < p_b.get_cpu_load()) - (uint64) 
(p_a.get_cpu_load() > p_b.get_cpu_load()));
+                        return (int) ((uint64) (p_a.cpu_load < p_b.cpu_load) - (uint64) (p_a.cpu_load > 
p_b.cpu_load));
                     case ProcessListBoxType.MEMORY:
-                        return (int) ((uint64) (p_a.get_mem_usage() < p_b.get_mem_usage()) - (uint64) 
(p_a.get_mem_usage() > p_b.get_mem_usage()));
+                        return (int) ((uint64) (p_a.mem_usage < p_b.mem_usage) - (uint64) (p_a.mem_usage > 
p_b.mem_usage));
                 }
             };
 
-           if(parent_process.get_sub_processes() != null)
+           if(parent_process.sub_processes != null)
            {
-               foreach(unowned Process process in parent_process.get_sub_processes().get_values())
+               foreach(unowned Process process in parent_process.sub_processes.get_values())
                {
                    model.insert_sorted(process, processcmp);
                }
diff --git a/src/sub-process-sub-row.vala b/src/sub-process-sub-row.vala
index 48ac96a..77d13e8 100644
--- a/src/sub-process-sub-row.vala
+++ b/src/sub-process-sub-row.vala
@@ -46,7 +46,7 @@ namespace Usage
             this.process = process;
 
             icon.set_from_icon_name("system-run-symbolic", Gtk.IconSize.BUTTON);
-            title_label.label = process.get_display_name();
+            title_label.label = process.display_name;
 
             notify["max-usage"].connect (() => {
                 set_styles();
@@ -64,18 +64,18 @@ namespace Usage
             switch(type)
             {
                 case ProcessListBoxType.PROCESSOR:
-                    load_label.label = ((uint64) process.get_cpu_load()).to_string() + " %";
+                    load_label.label = ((uint64) process.cpu_load).to_string() + " %";
 
-                    if(process.get_cpu_load() >= MAX_CPU_USAGE_LIMIT)
+                    if(process.cpu_load >= MAX_CPU_USAGE_LIMIT)
                         max_usage = true;
                     else
                         max_usage = false;
                     break;
                 case ProcessListBoxType.MEMORY:
                     SystemMonitor monitor = SystemMonitor.get_default();
-                    load_label.label = Utils.format_size_values(process.get_mem_usage());
+                    load_label.label = Utils.format_size_values(process.mem_usage);
 
-                    if((((double) process.get_mem_usage() / monitor.ram_total) * 100) >= 
MAX_MEMORY_USAGE_LIMIT)
+                    if((((double) process.mem_usage / monitor.ram_total) * 100) >= MAX_MEMORY_USAGE_LIMIT)
                         max_usage = true;
                     else
                         max_usage = false;
@@ -93,7 +93,7 @@ namespace Usage
 
         public new void activate()
         {
-            var dialog = new ProcessDialog(process.get_pid(), process.get_cmdline(), process.get_cmdline());
+            var dialog = new ProcessDialog(process.pid, process.cmdline, process.cmdline);
             dialog.show_all();
         }
     }
diff --git a/src/system-monitor.vala b/src/system-monitor.vala
index 6d7a47c..7a37e28 100644
--- a/src/system-monitor.vala
+++ b/src/system-monitor.vala
@@ -122,7 +122,7 @@ namespace Usage
 
             foreach(unowned Process process in process_table.get_values())
             {
-                process.set_alive(false);
+                process.alive = false;
             }
 
             set_alive_false(ref cpu_process_table);
@@ -145,8 +145,8 @@ namespace Usage
                 else
                 {
                     Process process = process_table[pids[i]];
-                    process.set_alive(true);
-                    get_process_status(ref process);
+                    process.alive = true;
+                    update_process_status(ref process);
                     cpu_monitor.update_process(ref process);
                     memory_monitor.update_process(ref process);
                 }
@@ -154,26 +154,26 @@ namespace Usage
 
             foreach(unowned Process process in process_table.get_values())
             {
-                if (process.get_alive() == false)
+                if (!process.alive)
                 {
-                    process.set_status(ProcessStatus.DEAD);
-                    process_table.remove (process.get_pid());
+                    process.status = ProcessStatus.DEAD;
+                    process_table.remove (process.pid);
                 }
             }
 
             var process_table_temp = new HashTable<Pid?, Process>(int_hash, int_equal);
             foreach(unowned Process process in process_table.get_values())
             {
-                if(process.get_cpu_load() >= 1)
-                    process_table_temp.insert(process.get_pid(), process);
+                if(process.cpu_load >= 1)
+                    process_table_temp.insert(process.pid, process);
             }
             update_processes(process_table_temp, ref cpu_process_table);
 
             process_table_temp.remove_all();
             foreach(unowned Process process in process_table.get_values())
             {
-                if(process.get_mem_usage() >= 1)
-                    process_table_temp.insert(process.get_pid(), process);
+                if(process.mem_usage >= 1)
+                    process_table_temp.insert(process.pid, process);
             }
             update_processes(process_table_temp, ref ram_process_table);
 
@@ -275,44 +275,44 @@ namespace Usage
             return cmd;
         }
 
-        private void get_process_status (ref Process process)
+        private void update_process_status (ref Process process)
         {
             GTop.ProcState proc_state;
-            GTop.get_proc_state (out proc_state, process.get_pid());
+            GTop.get_proc_state (out proc_state, process.pid);
 
             switch(proc_state.state)
             {
                 case GTop.PROCESS_RUNNING:
                 case GTop.PROCESS_UNINTERRUPTIBLE:
-                    process.set_status(ProcessStatus.RUNNING);
+                    process.status = ProcessStatus.RUNNING;
                     break;
                 case GTop.PROCESS_SWAPPING:
                 case GTop.PROCESS_INTERRUPTIBLE:
                 case GTop.PROCESS_STOPPED:
-                    process.set_status(ProcessStatus.SLEEPING);
+                    process.status = ProcessStatus.SLEEPING;
                     break;
                 case GTop.PROCESS_DEAD:
                 case GTop.PROCESS_ZOMBIE:
                 default:
-                    process.set_status(ProcessStatus.DEAD);
+                    process.status = ProcessStatus.DEAD;
                     break;
             }
 
-            if(process.get_cpu_load() > 0)
-                process.set_status(ProcessStatus.RUNNING);
+            if(process.cpu_load > 0)
+                process.status = ProcessStatus.RUNNING;
         }
 
         private void set_alive_false(ref HashTable<string, Process> process_table)
         {
             foreach(unowned Process process in process_table.get_values())
             {
-                if(process.get_sub_processes() == null)
-                    process.set_alive(false);
+                if(process.sub_processes == null)
+                    process.alive = false;
                 else
                 {
-                    foreach(unowned Process sub_process in process.get_sub_processes().get_values())
+                    foreach(unowned Process sub_process in process.sub_processes.get_values())
                     {
-                        sub_process.set_alive(false);
+                        sub_process.alive = false;
                     }
                 }
             }
@@ -322,91 +322,90 @@ namespace Usage
         {
             foreach(unowned Process process_it in from_table.get_values())
             {
-                if(process_it.get_cmdline() in to_table) //subprocess or update process
+                if(process_it.cmdline in to_table) //subprocess or update process
                 {
-                    if(to_table[process_it.get_cmdline()].get_sub_processes() != null) //subprocess
+                    if(to_table[process_it.cmdline].sub_processes != null) //subprocess
                     {
-                        if(process_it.get_pid() in to_table[process_it.get_cmdline()].get_sub_processes()) 
//update subprocess
+                        if(process_it.pid in to_table[process_it.cmdline].sub_processes) //update subprocess
                         {
-                            unowned Process process = 
to_table[process_it.get_cmdline()].get_sub_processes()[process_it.get_pid()];
+                            unowned Process process = 
to_table[process_it.cmdline].sub_processes[process_it.pid];
                             process.update_from_process(process_it);
                         }
                         else //add subrow
                         {
-                            var process = new Process(process_it.get_pid(), process_it.get_cmdline(), 
process_it.get_cmdline_parameter(), process_it.get_display_name());
+                            var process = new Process(process_it.pid, process_it.cmdline, 
process_it.cmdline_parameter, process_it.display_name);
                             process.update_from_process(process_it);
-                            to_table[process.get_cmdline()].get_sub_processes().insert(process.get_pid(), 
(owned) process);
+                            to_table[process.cmdline].sub_processes.insert(process.pid, (owned) process);
                         }
                     }
                     else //update process or transform to group and add subrow
                     {
-                        if(process_it.get_pid() == to_table[process_it.get_cmdline()].get_pid()) //update 
process
+                        if(process_it.pid == to_table[process_it.cmdline].pid) //update process
                         {
-                            unowned Process process = to_table[process_it.get_cmdline()];
+                            unowned Process process = to_table[process_it.cmdline];
                             process.update_from_process(process_it);
                         }
                         else //transform to group and add subrow
                         {
-                            to_table[process_it.get_cmdline()].set_sub_processes(new HashTable<Pid?, 
Process>(int_hash, int_equal));
-                            unowned Process process = to_table[process_it.get_cmdline()];
+                            to_table[process_it.cmdline].sub_processes = new HashTable<Pid?, 
Process>(int_hash, int_equal);
+                            unowned Process process = to_table[process_it.cmdline];
 
-                            var sub_process_one = new Process(process.get_pid(), process.get_cmdline(), 
process.get_cmdline_parameter(), process.get_display_name());
+                            var sub_process_one = new Process(process.pid, process.cmdline, 
process.cmdline_parameter, process.display_name);
                             sub_process_one.update_from_process(process);
-                            
to_table[process_it.get_cmdline()].get_sub_processes().insert(sub_process_one.get_pid(), (owned) 
sub_process_one);
-                            process.set_cmdline_parameter("");
+                            to_table[process_it.cmdline].sub_processes.insert(sub_process_one.pid, (owned) 
sub_process_one);
 
-                            var sub_process = new Process(process_it.get_pid(), process_it.get_cmdline(), 
process_it.get_cmdline_parameter(), process_it.get_display_name());
+                            var sub_process = new Process(process_it.pid, process_it.cmdline, 
process_it.cmdline_parameter, process_it.display_name);
                             sub_process.update_from_process(process_it);
-                            
to_table[process_it.get_cmdline()].get_sub_processes().insert(process_it.get_pid(), (owned) sub_process);
+                            to_table[process_it.cmdline].sub_processes.insert(process_it.pid, (owned) 
sub_process);
                         }
                     }
                 }
                 else //add process
                 {
-                     var process = new Process(process_it.get_pid(), process_it.get_cmdline(), 
process_it.get_cmdline_parameter(), process_it.get_display_name());
+                     var process = new Process(process_it.pid, process_it.cmdline, 
process_it.cmdline_parameter, process_it.display_name);
                      process.update_from_process(process_it);
-                     to_table.insert(process.get_cmdline(), (owned) process);
+                     to_table.insert(process.cmdline, (owned) process);
                 }
             }
 
             foreach(unowned Process process in to_table.get_values())
             {
-                if(process.get_sub_processes() == null)
+                if(process.sub_processes == null)
                 {
-                    if(process.get_alive() == false)
-                        to_table.remove (process.get_cmdline());
+                    if(!process.alive)
+                        to_table.remove (process.cmdline);
                 }
                 else
                 {
                     double cpu_load = 0;
                     uint64 mem_usage = 0;
-                    foreach(unowned Process sub_process in process.get_sub_processes().get_values())
+                    foreach(unowned Process sub_process in process.sub_processes.get_values())
                     {
-                        if (sub_process.get_alive() == false)
-                            process.get_sub_processes().remove(sub_process.get_pid());
-                       else
-                       {
-                               cpu_load += sub_process.get_cpu_load();
-                               mem_usage += sub_process.get_mem_usage();
-                       }
+                        if (!sub_process.alive)
+                            process.sub_processes.remove(sub_process.pid);
+                        else
+                        {
+                            cpu_load += sub_process.cpu_load;
+                            mem_usage += sub_process.mem_usage;
+                        }
                     }
-                    process.set_cpu_load(cpu_load);
-                    process.set_mem_usage(mem_usage);
+                    process.cpu_load = cpu_load;
+                    process.mem_usage = mem_usage;
 
-                    if(process.get_sub_processes().length == 1) //tranform to process
+                    if(process.sub_processes.length == 1) //tranform to process
                     {
-                        foreach(unowned Process sub_process in process.get_sub_processes().get_values()) 
//only one
+                        foreach(unowned Process sub_process in process.sub_processes.get_values()) //only one
                         {
-                            process.set_sub_processes(null);
+                            process.sub_processes = null;
                             process = sub_process;
                         }
                     }
-                    else if(process.get_sub_processes().length == 0)
+                    else if(process.sub_processes.length == 0)
                     {
-                        process.set_sub_processes(null);
-                        process.set_alive(false);
-                        process.set_status(ProcessStatus.DEAD);
-                        to_table.remove(process.get_cmdline());
+                        process.sub_processes = null;
+                        process.alive = false;
+                        process.status = ProcessStatus.DEAD;
+                        to_table.remove(process.cmdline);
                     }
                 }
             }


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