-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessContainer.h
40 lines (36 loc) · 955 Bytes
/
ProcessContainer.h
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
#pragma once
#include "Process.h"
#include <vector>
class ProcessContainer{
private:
std::vector<Process>_list;
public:
ProcessContainer(){
this->refreshList();
}
void refreshList();
std::string printList();
std::vector<std::string> getList();
};
void ProcessContainer::refreshList(){
std::vector<std::string> pidList = ProcessParser::getPidList();
this->_list.clear();
for(int i=0;i<pidList.size();i++){
Process proc(pidList[i]);
this->_list.push_back(proc);
}
}
std::string ProcessContainer::printList(){
std::string result="";
for(int i=0;i<this->_list.size();i++){
result += this->_list[i].getProcess();
}
return result;
}
std::vector<std::string> ProcessContainer::getList() {
vector<string> values;
for (int i = (this->_list.size()-10); i < this->_list.size(); i++){
values.push_back(this->_list[i].getProcess());
}
return values;
}