FilesystemDeviceCache implements DeviceCache by creating and removing files inside a filesystem directory. Each paired device has a file named by its ID created. Devices are categorized by the ID prefix.
More...
#include <FilesystemDeviceCache.h>
|
Poco::File | locatePrefix (const DevicePrefix &prefix) const |
|
Poco::File | locateID (const DeviceID &id) const |
|
bool | decodeName (const std::string &name, DeviceID &id) const |
| Parse file name and try to decode it as it is a device ID. The result is given in the referenced parameter id. No exceptions should be thrown. More...
|
|
void | drop (const DeviceID &id) const |
| Remove file $cacheDir/$prefix/$id from the filesystem if it does exist. No exceptions should be thrown.
|
|
void | write (const DeviceID &id) const |
| Create file $cacheDir/$prefix/$id in the filesystem if it does not exist. No exceptions should be thrown.
|
|
FilesystemDeviceCache implements DeviceCache by creating and removing files inside a filesystem directory. Each paired device has a file named by its ID created. Devices are categorized by the ID prefix.
The cache is created under the directory specified by property cacheDir
. If such path does not exist, it is created when on demand.
The FilesystemDeviceCache uses global locking (Poco::NamedLock) for each set of ID of the same prefix. Such lock is named after the prefix.
bool FilesystemDeviceCache::decodeName |
( |
const std::string & |
name, |
|
|
DeviceID & |
id |
|
) |
| const |
|
protected |
Parse file name and try to decode it as it is a device ID. The result is given in the referenced parameter id. No exceptions should be thrown.
- Returns
- true if the decoding was successful
File FilesystemDeviceCache::locateID |
( |
const DeviceID & |
id | ) |
const |
|
protected |
- Returns
- Poco::File pointing to the file representing the given ID
File FilesystemDeviceCache::locatePrefix |
( |
const DevicePrefix & |
prefix | ) |
const |
|
protected |
- Returns
- Poco::File pointing to the directory where IDs of the given prefix are stored.
void BeeeOn::FilesystemDeviceCache::markPaired |
( |
const DevicePrefix & |
prefix, |
|
|
const std::set< DeviceID > & |
devices |
|
) |
| |
|
overridevirtual |
Synchronize the contents of $cacheDir/$prefix
with the given set of devices.
Existing files $cacheDir/$prefix/$id
are preserved if they are present in the given set of devices, otherwise they are deleted. Missing files $cacheDir/$prefix/$id
that are contained inside the given set of devices are created.
The operation is atomic from the application point of view. It is however not guaranteed that the state of the cache is consistent with the given set of devices when a serious failure occures.
Implements BeeeOn::DeviceCache.
bool FilesystemDeviceCache::paired |
( |
const DeviceID & |
device | ) |
const |
|
overridevirtual |
- Returns
- set of file names found in
$cacheDir/$prefix
that are represent valid device IDs
Implements BeeeOn::DeviceCache.
The documentation for this class was generated from the following files:
- /var/lib/jenkins/workspace/beeeon-gateway-master/src/core/FilesystemDeviceCache.h
- /var/lib/jenkins/workspace/beeeon-gateway-master/src/core/FilesystemDeviceCache.cpp