forked from yongchaowu/mtexplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagentinfo.cpp
61 lines (46 loc) · 1.17 KB
/
agentinfo.cpp
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
#include <iostream>
#include <QDebug>
#include "agentinfo.h"
AgentInfo::AgentInfo(string aId, string aUrl, string aComment)
{
id = aId;
url = aUrl;
comment = aComment;
}
void AgentInfo::addDevice(DeviceInfo *device)
{
deviceList.push_back(device);
}
DeviceInfo* AgentInfo::addDevice(string deviceId, string deviceName, string deviceUUID)
{
DeviceInfo* device = new DeviceInfo(url, deviceId, deviceName, deviceUUID);
addDevice(device);
return device;
}
void AgentInfo::dump()
{
cout << "url = [" << url << "]" << endl;
cout << "comment = [" << comment << "]" << endl;
cout << "# of devices = " << deviceList.size() << endl;
list<DeviceInfo*>::iterator it = deviceList.begin();
while (it != deviceList.end())
{
DeviceInfo *device = *it;
device->dump();
delete device;
++it;
}
}
AgentInfo::~AgentInfo()
{
qDebug() << "Delete Agent [" << QString(id.c_str()) << "]";
if (deviceList.size() == 0)
return;
list<DeviceInfo*>::iterator it = deviceList.begin();
while (it != deviceList.end())
{
DeviceInfo *device = *it;
delete device;
++it;
}
}