Device.cpp 941 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "Device.h"
  2. namespace PresenceDetection {
  3. namespace Device {
  4. Device::Device(int id, const std::string& wifiMacAddress, const std::string& bluetoothAddress) :
  5. m_id(id),
  6. m_wifiMacAddress(wifiMacAddress),
  7. m_bluetoothMacAddress(bluetoothAddress),
  8. m_online(false)
  9. {
  10. }
  11. Device::~Device()
  12. {
  13. }
  14. Device::Device(const Device& other)
  15. {
  16. m_id = other.m_id;
  17. m_wifiMacAddress = other.m_wifiMacAddress;
  18. m_bluetoothMacAddress = other.m_bluetoothMacAddress;
  19. m_online = other.m_online;
  20. }
  21. int Device::ID() const
  22. {
  23. return m_id;
  24. }
  25. std::string Device::WifiMacAddress() const
  26. {
  27. return m_wifiMacAddress;
  28. }
  29. std::string Device::BluetoothMacAddress() const
  30. {
  31. return m_bluetoothMacAddress;
  32. }
  33. bool Device::Online() const
  34. {
  35. std::lock_guard<std::mutex> lock(m_mutex);
  36. return m_online;
  37. }
  38. void Device::Online(bool online)
  39. {
  40. std::lock_guard<std::mutex> lock(m_mutex);
  41. m_online = online;
  42. }
  43. } // namespace Device
  44. } // namespace PresenceDetection