-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathport.cpp
45 lines (39 loc) · 968 Bytes
/
port.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
#include "port.h"
Port::Port(QString p,QObject *parent) :
QObject(parent),_name(p)
{
}
QString Port::getName() {
return _name;
}
QStringList Port::info() {
QStringList sl;
if (interfaceList.length() == 0) {
sl<<"No interface";
}
for (int i=0;i<interfaceList.length();i++) {
sl<<QString("接口类型:%1").arg(interfaceList[i]->getType());
}
return sl;
}
void Port::addInterface(QString name) {
Interface *in = new Interface(name);
interfaceList.append(in);
}
Interface * Port::getInterface(QString name) {
for (int i=0;i<interfaceList.length();i++) {
if (interfaceList[i]->getName() == name) {
return interfaceList[i];
}
}
return NULL;
}
Interface * Port::getInterface(int index) {
if (index >=0 && index <= interfaceList.length()) {
return interfaceList[index];
}
return NULL;
}
QString Port::getKey() {
return interfaceList[0]->getKey();
}