Device.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #include <algorithm>
  2. #include "Device.h"
  3. namespace PresenceDetection {
  4. namespace Util {
  5. Device::Device(const std::string& wifiMac, const std::string& bluetoothMac) :
  6. m_wifiMac(wifiMac),
  7. m_wifiState(false),
  8. m_bluetoothMac(bluetoothMac),
  9. m_bluetoothState(false)
  10. {
  11. std::transform(m_wifiMac.begin(), m_wifiMac.end(), m_wifiMac.begin(), ::tolower);
  12. std::transform(m_bluetoothMac.begin(), m_bluetoothMac.end(), m_bluetoothMac.begin(), ::tolower);
  13. }
  14. Device::Device(const Device &other) :
  15. m_wifiMac(other.m_wifiMac),
  16. m_wifiState(other.m_wifiState),
  17. m_bluetoothMac(other.m_bluetoothMac),
  18. m_bluetoothState(other.m_bluetoothState),
  19. m_onlineURL(other.m_onlineURL),
  20. m_wifiOnlineURL(other.m_wifiOnlineURL),
  21. m_bluetoothOnlineURL(other.m_bluetoothOnlineURL),
  22. m_offlineURL(other.m_offlineURL),
  23. m_wifiOfflineURL(other.m_wifiOfflineURL),
  24. m_bluetoothOfflineURL(other.m_bluetoothOfflineURL)
  25. {
  26. }
  27. Device::~Device()
  28. {
  29. }
  30. bool Device::HasWifiMac() const
  31. {
  32. return !m_wifiMac.empty();
  33. }
  34. std::string Device::WifiMac() const
  35. {
  36. return m_wifiMac;
  37. }
  38. void Device::SetWifiState(bool present)
  39. {
  40. m_wifiState = present;
  41. }
  42. bool Device::GetWifiState() const
  43. {
  44. return m_wifiState;
  45. }
  46. bool Device::HasBluetoothMac() const
  47. {
  48. return !m_bluetoothMac.empty();
  49. }
  50. std::string Device::BluetoothMac() const
  51. {
  52. return m_bluetoothMac;
  53. }
  54. void Device::SetBluetoothState(bool present)
  55. {
  56. m_bluetoothState = present;
  57. }
  58. bool Device::GetBluetoothState() const
  59. {
  60. return m_bluetoothState;
  61. }
  62. bool Device::HasOnlineURL() const
  63. {
  64. return !m_onlineURL.empty();
  65. }
  66. void Device::SetOnlineURL(const std::string& url)
  67. {
  68. m_onlineURL = url;
  69. }
  70. std::string Device::OnlineURL() const
  71. {
  72. return m_onlineURL;
  73. }
  74. bool Device::HasWifiOnlineURL() const
  75. {
  76. return !m_wifiOnlineURL.empty();
  77. }
  78. void Device::SetWifiOnlineURL(const std::string& url)
  79. {
  80. m_wifiOnlineURL = url;
  81. }
  82. std::string Device::WifiOnlineURL() const
  83. {
  84. return m_wifiOnlineURL;
  85. }
  86. bool Device::HasBluetoothOnlineURL() const
  87. {
  88. return !m_bluetoothOnlineURL.empty();
  89. }
  90. void Device::SetBluetoothOnlineURL(const std::string& url)
  91. {
  92. m_bluetoothOnlineURL = url;
  93. }
  94. std::string Device::BluetoothOnlineURL() const
  95. {
  96. return m_bluetoothOnlineURL;
  97. }
  98. bool Device::HasOfflineURL() const
  99. {
  100. return !m_offlineURL.empty();
  101. }
  102. void Device::SetOfflineURL(const std::string& url)
  103. {
  104. m_offlineURL = url;
  105. }
  106. std::string Device::OfflineURL() const
  107. {
  108. return m_offlineURL;
  109. }
  110. bool Device::HasWifiOfflineURL() const
  111. {
  112. return !m_wifiOfflineURL.empty();
  113. }
  114. void Device::SetWifiOfflineURL(const std::string& url)
  115. {
  116. m_wifiOfflineURL = url;
  117. }
  118. std::string Device::WifiOfflineURL() const
  119. {
  120. return m_wifiOfflineURL;
  121. }
  122. bool Device::HasBluetoothOfflineURL() const
  123. {
  124. return !m_bluetoothOfflineURL.empty();
  125. }
  126. void Device::SetBluetoothOfflineURL(const std::string& url)
  127. {
  128. m_bluetoothOfflineURL = url;
  129. }
  130. std::string Device::BluetoothOfflineURL() const
  131. {
  132. return m_bluetoothOfflineURL;
  133. }
  134. } // namespace Util
  135. } // namespace PresenceDetection