Add Static Devices
This commit is contained in:
-167
@@ -1,167 +0,0 @@
|
||||
#include "Device.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
Device::Device(const std::string& wifiMac, const std::string& bluetoothMac) :
|
||||
m_wifiMac(wifiMac),
|
||||
m_wifiState(false),
|
||||
m_bluetoothMac(bluetoothMac),
|
||||
m_bluetoothState(false)
|
||||
{
|
||||
std::transform(m_wifiMac.begin(), m_wifiMac.end(), m_wifiMac.begin(), ::tolower);
|
||||
std::transform(m_bluetoothMac.begin(), m_bluetoothMac.end(), m_bluetoothMac.begin(), ::tolower);
|
||||
}
|
||||
|
||||
Device::Device(const Device &other) :
|
||||
m_wifiMac(other.m_wifiMac),
|
||||
m_wifiState(other.m_wifiState),
|
||||
m_bluetoothMac(other.m_bluetoothMac),
|
||||
m_bluetoothState(other.m_bluetoothState),
|
||||
m_onlineURL(other.m_onlineURL),
|
||||
m_wifiOnlineURL(other.m_wifiOnlineURL),
|
||||
m_bluetoothOnlineURL(other.m_bluetoothOnlineURL),
|
||||
m_offlineURL(other.m_offlineURL),
|
||||
m_wifiOfflineURL(other.m_wifiOfflineURL),
|
||||
m_bluetoothOfflineURL(other.m_bluetoothOfflineURL)
|
||||
{
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
}
|
||||
|
||||
bool Device::HasWifiMac() const
|
||||
{
|
||||
return !m_wifiMac.empty();
|
||||
}
|
||||
|
||||
std::string Device::WifiMac() const
|
||||
{
|
||||
return m_wifiMac;
|
||||
}
|
||||
|
||||
void Device::SetWifiState(bool present)
|
||||
{
|
||||
m_wifiState = present;
|
||||
}
|
||||
|
||||
bool Device::GetWifiState() const
|
||||
{
|
||||
return m_wifiState;
|
||||
}
|
||||
|
||||
bool Device::HasBluetoothMac() const
|
||||
{
|
||||
return !m_bluetoothMac.empty();
|
||||
}
|
||||
|
||||
std::string Device::BluetoothMac() const
|
||||
{
|
||||
return m_bluetoothMac;
|
||||
}
|
||||
|
||||
void Device::SetBluetoothState(bool present)
|
||||
{
|
||||
m_bluetoothState = present;
|
||||
}
|
||||
|
||||
bool Device::GetBluetoothState() const
|
||||
{
|
||||
return m_bluetoothState;
|
||||
}
|
||||
|
||||
bool Device::HasOnlineURL() const
|
||||
{
|
||||
return !m_onlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetOnlineURL(const std::string& url)
|
||||
{
|
||||
m_onlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::OnlineURL() const
|
||||
{
|
||||
return m_onlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasWifiOnlineURL() const
|
||||
{
|
||||
return !m_wifiOnlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetWifiOnlineURL(const std::string& url)
|
||||
{
|
||||
m_wifiOnlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::WifiOnlineURL() const
|
||||
{
|
||||
return m_wifiOnlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasBluetoothOnlineURL() const
|
||||
{
|
||||
return !m_bluetoothOnlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetBluetoothOnlineURL(const std::string& url)
|
||||
{
|
||||
m_bluetoothOnlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::BluetoothOnlineURL() const
|
||||
{
|
||||
return m_bluetoothOnlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasOfflineURL() const
|
||||
{
|
||||
return !m_offlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetOfflineURL(const std::string& url)
|
||||
{
|
||||
m_offlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::OfflineURL() const
|
||||
{
|
||||
return m_offlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasWifiOfflineURL() const
|
||||
{
|
||||
return !m_wifiOfflineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetWifiOfflineURL(const std::string& url)
|
||||
{
|
||||
m_wifiOfflineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::WifiOfflineURL() const
|
||||
{
|
||||
return m_wifiOfflineURL;
|
||||
}
|
||||
|
||||
bool Device::HasBluetoothOfflineURL() const
|
||||
{
|
||||
return !m_bluetoothOfflineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetBluetoothOfflineURL(const std::string& url)
|
||||
{
|
||||
m_bluetoothOfflineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::BluetoothOfflineURL() const
|
||||
{
|
||||
return m_bluetoothOfflineURL;
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "DynamicDevice.h"
|
||||
#include <StringAlgorithm.h>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
DynamicDevice::DynamicDevice(const std::string& macAddress) :
|
||||
m_probeCounter(0),
|
||||
m_macAddress(macAddress)
|
||||
{
|
||||
}
|
||||
|
||||
std::string DynamicDevice::MacAddress()
|
||||
{
|
||||
return m_macAddress;
|
||||
}
|
||||
|
||||
int DynamicDevice::ProbeCounter() const
|
||||
{
|
||||
return m_probeCounter;
|
||||
}
|
||||
|
||||
void DynamicDevice::IncrementProbeCounter()
|
||||
{
|
||||
++m_probeCounter;
|
||||
}
|
||||
|
||||
void DynamicDevice::ResetProbeCounter()
|
||||
{
|
||||
m_probeCounter = 0;
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef UTIL_DYNAMICDEVICE_H
|
||||
#define UTIL_DYNAMICDEVICE_H
|
||||
|
||||
#include "ProbeableDevice.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
class DynamicDevice : public ProbeableDevice
|
||||
{
|
||||
public:
|
||||
DynamicDevice(const std::string& macAddress);
|
||||
|
||||
virtual int ProbeCounter() const override;
|
||||
virtual void IncrementProbeCounter() override;
|
||||
virtual void ResetProbeCounter() override;
|
||||
|
||||
std::string MacAddress();
|
||||
|
||||
private:
|
||||
int m_probeCounter;
|
||||
|
||||
std::string m_macAddress;
|
||||
};
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
|
||||
#endif // UTIL_DYNAMICDEVICE_H
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef UTIL_PROBEABLEDEVICE_H
|
||||
#define UTIL_PROBEABLEDEVICE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
class ProbeableDevice
|
||||
{
|
||||
public:
|
||||
virtual int ProbeCounter() const = 0;
|
||||
virtual void IncrementProbeCounter() = 0;
|
||||
virtual void ResetProbeCounter() = 0;
|
||||
};
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
|
||||
#endif // UTIL_PROBEABLEDEVICE_H
|
||||
@@ -0,0 +1,184 @@
|
||||
#include "StaticDevice.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
StaticDevice::StaticDevice(const std::string& wifiMac, const std::string& bluetoothMac) :
|
||||
m_probeCounter(0),
|
||||
m_wifiMac(wifiMac),
|
||||
m_wifiState(false),
|
||||
m_bluetoothMac(bluetoothMac),
|
||||
m_bluetoothState(false)
|
||||
{
|
||||
std::transform(m_wifiMac.begin(), m_wifiMac.end(), m_wifiMac.begin(), ::tolower);
|
||||
std::transform(m_bluetoothMac.begin(), m_bluetoothMac.end(), m_bluetoothMac.begin(), ::tolower);
|
||||
}
|
||||
|
||||
StaticDevice::StaticDevice(const StaticDevice &other) :
|
||||
m_probeCounter(other.m_probeCounter),
|
||||
m_wifiMac(other.m_wifiMac),
|
||||
m_wifiState(other.m_wifiState),
|
||||
m_bluetoothMac(other.m_bluetoothMac),
|
||||
m_bluetoothState(other.m_bluetoothState),
|
||||
m_onlineURL(other.m_onlineURL),
|
||||
m_wifiOnlineURL(other.m_wifiOnlineURL),
|
||||
m_bluetoothOnlineURL(other.m_bluetoothOnlineURL),
|
||||
m_offlineURL(other.m_offlineURL),
|
||||
m_wifiOfflineURL(other.m_wifiOfflineURL),
|
||||
m_bluetoothOfflineURL(other.m_bluetoothOfflineURL)
|
||||
{
|
||||
}
|
||||
|
||||
StaticDevice::~StaticDevice()
|
||||
{
|
||||
}
|
||||
|
||||
int StaticDevice::ProbeCounter() const
|
||||
{
|
||||
return m_probeCounter;
|
||||
}
|
||||
|
||||
void StaticDevice::IncrementProbeCounter()
|
||||
{
|
||||
++m_probeCounter;
|
||||
}
|
||||
|
||||
void StaticDevice::ResetProbeCounter()
|
||||
{
|
||||
m_probeCounter = 0;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasWifiMac() const
|
||||
{
|
||||
return !m_wifiMac.empty();
|
||||
}
|
||||
|
||||
std::string StaticDevice::WifiMac() const
|
||||
{
|
||||
return m_wifiMac;
|
||||
}
|
||||
|
||||
void StaticDevice::SetWifiState(bool present)
|
||||
{
|
||||
m_wifiState = present;
|
||||
}
|
||||
|
||||
bool StaticDevice::GetWifiState() const
|
||||
{
|
||||
return m_wifiState;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasBluetoothMac() const
|
||||
{
|
||||
return !m_bluetoothMac.empty();
|
||||
}
|
||||
|
||||
std::string StaticDevice::BluetoothMac() const
|
||||
{
|
||||
return m_bluetoothMac;
|
||||
}
|
||||
|
||||
void StaticDevice::SetBluetoothState(bool present)
|
||||
{
|
||||
m_bluetoothState = present;
|
||||
}
|
||||
|
||||
bool StaticDevice::GetBluetoothState() const
|
||||
{
|
||||
return m_bluetoothState;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasOnlineURL() const
|
||||
{
|
||||
return !m_onlineURL.empty();
|
||||
}
|
||||
|
||||
void StaticDevice::SetOnlineURL(const std::string& url)
|
||||
{
|
||||
m_onlineURL = url;
|
||||
}
|
||||
|
||||
std::string StaticDevice::OnlineURL() const
|
||||
{
|
||||
return m_onlineURL;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasWifiOnlineURL() const
|
||||
{
|
||||
return !m_wifiOnlineURL.empty();
|
||||
}
|
||||
|
||||
void StaticDevice::SetWifiOnlineURL(const std::string& url)
|
||||
{
|
||||
m_wifiOnlineURL = url;
|
||||
}
|
||||
|
||||
std::string StaticDevice::WifiOnlineURL() const
|
||||
{
|
||||
return m_wifiOnlineURL;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasBluetoothOnlineURL() const
|
||||
{
|
||||
return !m_bluetoothOnlineURL.empty();
|
||||
}
|
||||
|
||||
void StaticDevice::SetBluetoothOnlineURL(const std::string& url)
|
||||
{
|
||||
m_bluetoothOnlineURL = url;
|
||||
}
|
||||
|
||||
std::string StaticDevice::BluetoothOnlineURL() const
|
||||
{
|
||||
return m_bluetoothOnlineURL;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasOfflineURL() const
|
||||
{
|
||||
return !m_offlineURL.empty();
|
||||
}
|
||||
|
||||
void StaticDevice::SetOfflineURL(const std::string& url)
|
||||
{
|
||||
m_offlineURL = url;
|
||||
}
|
||||
|
||||
std::string StaticDevice::OfflineURL() const
|
||||
{
|
||||
return m_offlineURL;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasWifiOfflineURL() const
|
||||
{
|
||||
return !m_wifiOfflineURL.empty();
|
||||
}
|
||||
|
||||
void StaticDevice::SetWifiOfflineURL(const std::string& url)
|
||||
{
|
||||
m_wifiOfflineURL = url;
|
||||
}
|
||||
|
||||
std::string StaticDevice::WifiOfflineURL() const
|
||||
{
|
||||
return m_wifiOfflineURL;
|
||||
}
|
||||
|
||||
bool StaticDevice::HasBluetoothOfflineURL() const
|
||||
{
|
||||
return !m_bluetoothOfflineURL.empty();
|
||||
}
|
||||
|
||||
void StaticDevice::SetBluetoothOfflineURL(const std::string& url)
|
||||
{
|
||||
m_bluetoothOfflineURL = url;
|
||||
}
|
||||
|
||||
std::string StaticDevice::BluetoothOfflineURL() const
|
||||
{
|
||||
return m_bluetoothOfflineURL;
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
@@ -1,18 +1,23 @@
|
||||
#ifndef UTIL_DEVICE_H
|
||||
#define UTIL_DEVICE_H
|
||||
#ifndef UTIL_STATICDEVICE_H
|
||||
#define UTIL_STATICDEVICE_H
|
||||
|
||||
#include "ProbeableDevice.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
class Device
|
||||
class StaticDevice : public ProbeableDevice
|
||||
{
|
||||
public:
|
||||
Device(const std::string& wifiMac, const std::string& bluetoothMac);
|
||||
Device(const Device &other);
|
||||
~Device();
|
||||
StaticDevice(const std::string& wifiMac, const std::string& bluetoothMac);
|
||||
StaticDevice(const StaticDevice &other);
|
||||
~StaticDevice();
|
||||
|
||||
virtual int ProbeCounter() const override;
|
||||
virtual void IncrementProbeCounter() override;
|
||||
virtual void ResetProbeCounter() override;
|
||||
|
||||
bool HasWifiMac() const;
|
||||
std::string WifiMac() const;
|
||||
@@ -45,6 +50,8 @@ public:
|
||||
std::string BluetoothOfflineURL() const;
|
||||
|
||||
private:
|
||||
int m_probeCounter;
|
||||
|
||||
std::string m_wifiMac;
|
||||
bool m_wifiState;
|
||||
|
||||
@@ -62,4 +69,4 @@ private:
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
|
||||
#endif // UTIL_DEVICE_H
|
||||
#endif // UTIL_STATICDEVICE_H
|
||||
Reference in New Issue
Block a user