Buteo Synchronization Framework: Buteo::StorageBooker Class Reference

Buteo Synchronization Framework

Classes | Public Member Functions | List of all members
Buteo::StorageBooker Class Reference

A helper class for managing storage reservations. More...

`#include <StorageBooker.h>`

## Public Member Functions
| StorageBooker ()
| Constructor.
| ~StorageBooker ()
| Destructor.
bool | reserveStorage (const QString &aStorageName, const QString &aClientId="")
| Tries to reserve one storage for the given client. More...
bool | reserveStorages (const QStringList &aStorageNames, const QString &aClientId="")
| Tries to reserve multiple storages for the given client. More...
unsigned | releaseStorage (const QString &aStorageName)
| Releases the given storage. More...
void | releaseStorages (const QStringList &aStorageNames)
| Releases the given storages. More...
bool | isStorageAvailable (const QString &aStorageName, const QString &aClientId="") const
| Checks if the given storage is available for the given client. More...
bool | storagesAvailable (const QStringList &aStorageNames, const QString &aClientId="") const
| Checks if the given storages are available for the given client. More...

## Detailed Description

A helper class for managing storage reservations.

## Member Function Documentation

## ◆ isStorageAvailable()

bool StorageBooker::isStorageAvailable | ( | const QString & | aStorageName,
|  | const QString & | aClientId = `""`
| ) |  | const

Checks if the given storage is available for the given client.

The storage is available if there are no reservations for it or if the storage is already reserved for the same client. If the storage is available, it can be reserved for the client by calling reserve.

Parameters

  aStorageName | Name of the requested storage.
  aClientId | ID of the requesting client.

Returns
  Is the storage available.

## ◆ releaseStorage()

unsigned StorageBooker::releaseStorage | ( | const QString & | aStorageName | ) |

Releases the given storage.

Parameters

  aStorageName | Name of the storage to release.

Returns
  Number of remaining references to the storage. If this is zero, other clients can now reserve the storage.

## ◆ releaseStorages()

void StorageBooker::releaseStorages | ( | const QStringList & | aStorageNames | ) |

Releases the given storages.

Parameters

  aStorageNames | Names of the storages to release.

## ◆ reserveStorage()

bool StorageBooker::reserveStorage | ( | const QString & | aStorageName,
|  | const QString & | aClientId = `""`
| ) |  |

Tries to reserve one storage for the given client.

If the reserve is successfull, the caller must call release when it does not need the storage anymore. The same client can call reserve multiple times. Internal reference counter is increased in that case. For each reserve there must be a release call later. Other clients calling reserve for the same storage will fail, while the storage is reserved to some other client.

Parameters

  aStorageName | Name of the requested storage.
  aClientId | ID of the requesting client.

Returns
  Success indicator.

## ◆ reserveStorages()

bool StorageBooker::reserveStorages | ( | const QStringList & | aStorageNames,
|  | const QString & | aClientId = `""`
| ) |  |

Tries to reserve multiple storages for the given client.

If the reserve is successfull, the caller must call release for each storage when it does not need the storages anymore. The reserve is successfull only if all given storages are available. If the reserve fails, no storages are reserved.

Parameters

  aStorageNames | Names of the storages to reserve.
  aClientId | ID of the requesting client.

Returns
  Success indicator.

## ◆ storagesAvailable()

bool StorageBooker::storagesAvailable | ( | const QStringList & | aStorageNames,
|  | const QString & | aClientId = `""`
| ) |  | const

Checks if the given storages are available for the given client.

Parameters

  aStorageNames | Names of the requested storages.
  aClientId | ID of the requesting client.

Returns
  Are the storages available.

The documentation for this class was generated from the following files:

- StorageBooker.h
- StorageBooker.cpp