StorageBooker.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef STORAGEBOOKER_H
#define STORAGEBOOKER_H
#include <QString>
#include <QStringList>
#include <QMap>
#include <QMutex>
namespace Buteo {
class StorageBooker
{
public:
StorageBooker();
~StorageBooker();
bool reserveStorage(const QString &aStorageName,
const QString &aClientId = "");
bool reserveStorages(const QStringList &aStorageNames,
const QString &aClientId = "");
unsigned releaseStorage(const QString &aStorageName);
void releaseStorages(const QStringList &aStorageNames);
bool isStorageAvailable(const QString &aStorageName,
const QString &aClientId = "") const;
bool storagesAvailable(const QStringList &aStorageNames,
const QString &aClientId = "") const;
private:
struct StorageMapItem {
QString iClientId;
unsigned iRefCount;
StorageMapItem()
: iRefCount(0)
{}
StorageMapItem(const QString &aClientId)
: iClientId(aClientId)
, iRefCount(1)
{}
};
QMap<QString, StorageMapItem> iStorageMap;
mutable QMutex iMutex;
};
}
#endif // STORAGEBOOKER_H
Buteo::StorageBooker::releaseStorage
unsigned releaseStorage(const QString &aStorageName)
Releases the given storage.
Definition StorageBooker.cpp:90
Buteo::StorageBooker::releaseStorages
void releaseStorages(const QStringList &aStorageNames)
Releases the given storages.
Definition StorageBooker.cpp:113
Buteo::StorageBooker::StorageBooker
StorageBooker()
Constructor.
Definition StorageBooker.cpp:29
Buteo::StorageBooker::reserveStorages
bool reserveStorages(const QStringList &aStorageNames, const QString &aClientId="")
Tries to reserve multiple storages for the given client.
Definition StorageBooker.cpp:70
Buteo::StorageBooker::isStorageAvailable
bool isStorageAvailable(const QString &aStorageName, const QString &aClientId="") const
Checks if the given storage is available for the given client.
Definition StorageBooker.cpp:124
Buteo::StorageBooker::reserveStorage
bool reserveStorage(const QString &aStorageName, const QString &aClientId="")
Tries to reserve one storage for the given client.
Definition StorageBooker.cpp:40
Buteo::StorageBooker::~StorageBooker
~StorageBooker()
Destructor.
Definition StorageBooker.cpp:35
Buteo::StorageBooker::storagesAvailable
bool storagesAvailable(const QStringList &aStorageNames, const QString &aClientId="") const
Checks if the given storages are available for the given client.
Definition StorageBooker.cpp:136
QMap
Definition SyncBackupAdaptor.h:41