-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigurableInterface.cpp
More file actions
92 lines (76 loc) · 2.29 KB
/
ConfigurableInterface.cpp
File metadata and controls
92 lines (76 loc) · 2.29 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @file ConfigurableInterface.cpp
* @brief A common interface to set/get IP, MASK, GW, DNS, DHC and MAC
*
* Common interface implementation
*
* @author Amine BAGGA (2025)
*/
#include <iostream>
#include "ConfigurableInterface.h"
using namespace std;
ConfigurableInterface::ConfigurableInterface() : m_ipAddress(""), m_subnetMask(""), m_gateway(""), m_dns(""), m_macAddress(""), m_dhcp(false), m_mutex(new mutex()) {
}
ConfigurableInterface& ConfigurableInterface::operator=(const ConfigurableInterface& cp) {
if (this != &cp) {
lock_guard<mutex> lock(*m_mutex);
m_ipAddress = cp.m_ipAddress;
m_subnetMask = cp.m_subnetMask;
m_gateway = cp.m_gateway;
m_dns = cp.m_dns;
m_macAddress = cp.m_macAddress;
m_dhcp = cp.m_dhcp;
}
return *this;
}
ConfigurableInterface::~ConfigurableInterface() {
delete m_mutex;
}
void ConfigurableInterface::setIpAddress(const string& ip) {
lock_guard<mutex> lock(*m_mutex);
m_ipAddress = ip;
}
void ConfigurableInterface::setSubnetMask(const string& mask) {
lock_guard<mutex> lock(*m_mutex);
m_subnetMask = mask;
}
void ConfigurableInterface::setGateway(const string& gateway) {
lock_guard<mutex> lock(*m_mutex);
m_gateway = gateway;
}
void ConfigurableInterface::setDns(const string& dns) {
lock_guard<mutex> lock(*m_mutex);
m_dns = dns;
}
void ConfigurableInterface::setDhcp(const bool dhcp) {
lock_guard<mutex> lock(*m_mutex);
m_dhcp = dhcp;
}
void ConfigurableInterface::setMacAddress(const string& mac) {
lock_guard<mutex> lock(*m_mutex);
m_macAddress = mac;
}
string ConfigurableInterface::getIpAddress(void) const {
lock_guard<mutex> lock(*m_mutex);
return m_ipAddress;
}
string ConfigurableInterface::getSubnetMask(void) const {
lock_guard<mutex> lock(*m_mutex);
return m_subnetMask;
}
string ConfigurableInterface::getGateway(void) const {
lock_guard<mutex> lock(*m_mutex);
return m_gateway;
}
string ConfigurableInterface::getDns(void) const {
lock_guard<mutex> lock(*m_mutex);
return m_dns;
}
bool ConfigurableInterface::getDhcp(void) const {
lock_guard<mutex> lock(*m_mutex);
return m_dhcp;
}
string ConfigurableInterface::getMacAddress(void) const {
lock_guard<mutex> lock(*m_mutex);
return m_macAddress;
}