StaticDevice.cpp 3.3 KB

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