summaryrefslogtreecommitdiffstats
path: root/app/procinfo.cpp
blob: 76a0df374edfa987ba5609f3ce5a471b58d74510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "procinfo.h"
#include <QJsonObject>
#include <QString>

ProcInfo::ProcInfo(const QJsonObject& obj)
{
	m_cmd = obj["cmd"].toString();
	m_tid = obj["tid"].toInt();
	m_euid = obj["euid"].toInt();
	m_scpu = obj["scpu"].toDouble();
	m_ucpu = obj["ucpu"].toDouble();
	m_resident_memory = obj["resident_mem"].toDouble();
	m_state = obj["state"].toString();
}

bool ProcInfo::operator==(const ProcInfo& o)
{
	// TODO: re-implement
	if (&o == this)
		return true;
	return	m_tid == o.m_tid;
}

QString ProcInfo::cmd() const
{
	return m_cmd;
}

int ProcInfo::tid() const
{
	return m_tid;
}

int ProcInfo::euid() const
{
	return m_euid;
}

double ProcInfo::scpu() const
{
	return m_scpu;
}

double ProcInfo::ucpu() const
{
	return m_ucpu;
}

double ProcInfo::resident_memory() const
{
	return m_resident_memory;
}

QString ProcInfo::state() const
{
	return m_state;
}

/*
 * TODO: either it's a member operator that take one parameter (see above), either it's a global function which take two parameters.
bool operator==(const ProcInfo &obj) {
	ProcInfo obj2(jobj); 
	if(this.m_cmd == obj.m_cmd &&
	   this.m_tid == obj.m_tid &&
	   this.m_euid == obj.m_euid &&
	   this.m_scpu == obj.m_scpu &&
	   this.m_ucpu == obj.m_ucpu &&
	   this.m_resident_memory == obj.m_resident_memory &&
	   this.m_state == obj.m_state) {
		return true;
	} else {
		return false;
	}
}
*/