mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-10-29 18:02:20 +00:00
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
//
|
|
// Created by stephane bourque on 2021-07-13.
|
|
//
|
|
|
|
#ifndef UCENTRALFMS_DEVICECACHE_H
|
|
#define UCENTRALFMS_DEVICECACHE_H
|
|
|
|
#include <string>
|
|
#include "framework/MicroService.h"
|
|
|
|
namespace OpenWifi {
|
|
|
|
struct DeviceCacheEntry {
|
|
std::string deviceType;
|
|
std::string host;
|
|
std::string revision;
|
|
};
|
|
typedef std::map<std::string, DeviceCacheEntry> DeviceCacheMap;
|
|
|
|
class DeviceCache : public SubSystemServer {
|
|
public:
|
|
static auto instance() {
|
|
static auto instance_ = new DeviceCache;
|
|
return instance_;
|
|
}
|
|
|
|
int Start() override;
|
|
void Stop() override;
|
|
void AddToCache(const std::string &serialNumber, const std::string & DeviceType,
|
|
const std::string &Host, const std::string &Revision);
|
|
void DumpCache();
|
|
bool GetDevice(const std::string &SerialNumber, DeviceCacheEntry & E);
|
|
|
|
private:
|
|
std::atomic_bool Running_=false;
|
|
DeviceCacheMap DeviceCache_;
|
|
explicit DeviceCache() noexcept:
|
|
SubSystemServer("DeviceCache", "DEVICE-CACHE", "devicecache")
|
|
{
|
|
}
|
|
};
|
|
|
|
inline auto DeviceCache() { return DeviceCache::instance(); }
|
|
}
|
|
|
|
|
|
|
|
#endif //UCENTRALFMS_DEVICECACHE_H
|