Commit 57aea244 authored by Lukas Appelhans's avatar Lukas Appelhans

Backend documentation

parent d7f9af8f
......@@ -25,12 +25,46 @@ class Database;
class Hook;
class BackendPrivate;
/**
* \class Backend Akabei/Backend
*
* \brief Base class of AkabeiCore.
*
* \c Backend is the base class for all operations going on in AkabeiCore. Before starting
* any transaction or query it needs to be initialized.
* Said queries are run asynchronously.
*
* \code
* QUuid queryUuid;
* void query()
* {
* Akabei::Backend::instance()->initialize();
* connect(Akabei::Backend::instance(), SIGNAL(queryPackagesCompleted(QUuid, QList<Akabei::Package*>)), SLOT(queryCompleted(QUuid, QList<Akabei::Package*>)));
* queryUuid = Akabei::Backend::instance()->searchPackages(bla);
* }
*
* void queryCompleted(QUuid uuid, QList<Akabei::Package*> packages)
* {
* if (uuid == queryUuid) {
* //Do stuff
* }
* }
* \endcode
*
* If you want to do install/remove/upgrade a package without manually handling all the operations, you should
* use \c AkabeiClient/Backend. This is recommended, as the user should always have the same operations run during
* e.g. an install operation on a system.
*/
class AKABEICORESHARED_EXPORT Backend : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Backend)
Q_DECLARE_PRIVATE(Backend)
public:
/**
* \enum Status
* Describes the status the Backend current is in.
*/
enum Status {
StatusBare = 0,
StatusInitializing = 1,
......@@ -39,37 +73,126 @@ class AKABEICORESHARED_EXPORT Backend : public QObject
StatusOnTransaction = 4,
StatusBroken = 5
};
/**
* @returns the backend singleton
*/
static Backend *instance();
virtual ~Backend();
/**
* @returns the status of the backend
*/
Status status() const;
/**
* @returns the local database, which is the database which contains all the installed packages.
* To check whether a package is installed on the system, one needs to query this database whether
* it contains the package.
*/
Database *localDatabase();
/**
* @returns a list of remote databases which are current initialized
*/
QList<Database*> databases();
/**
* Queries akabei for all packages and emits \c queryPackagesCompleted.
* @returns the \c QUuid associated with the query
* @see queryPackagesCompleted()
*/
QUuid packages();
/**
* Searches all packages which contain the given token in either their description or name and emits \c queryPackagesCompleted.
* @param token the string to be queried for
* @see queryPackagesCompleted()
*/
QUuid searchPackages(const QString &token);
/**
* Queries akabei for all groups and emits \c queryGroupsCompleted.
* @returns the \c QUuid associated with the query
* @see queryGroupsCompleted()
*/
QUuid groups();
/**
* Searches all groups which contain the given token in either their description or name and emits \c queryGroupsCompleted.
* @param token the string to be queried for
* @see queryGroupsCompleted()
*/
QUuid searchGroups(const QString &token);
/**
* Performs a simple SQL-Query on all databases and emits \c queryPackagesCompleted.
* @returns the \c QUuid associated with the query
* @see queryPackagesCompleted()
*/
QUuid queryPackages(const QString &sql);
/**
* Performs a simple SQL-Query on all databases and emits \c queryPackagesCompleted.
* @returns the \c QUuid associated with the query
* @see queryGroupsCompleted()
*/
QUuid queryGroups(const QString &sql);
/**
* @returns the global OperationRunner used for all transactions
*/
OperationRunner *operationRunner();
/**
* Loads a package from a ".pkg.tar.xz"-file.
* @param path the path of the package-file
*/
Package *loadPackageFromFile(const QString &path);
/**
* Loads a delta from a ".delta.tar.xz"-file.
* @param path the path of the delta-file
*/
Delta *loadDeltaFromFile(const QString &path);
/**
* Loads a group from a textfile.
* @param path the path of the file containing the group information
*/
Group *loadGroupFromFile(const QString &path);
/**
* Loads a hook from a textfile.
* @param path the path of the file containing the hook information
*/
Hook *loadHookFromFile(const QString &path, QList<Package*> pkgs);
/**
* Loads a database from a ".db"-file.
* @param path the path of the database-file
*/
Database *loadDatabaseFromFile(const QString &path);
public Q_SLOTS:
/**
* This method initializes the database. This needs to be run before any query or transaction
* is performed.
*/
void initialize();
Q_SIGNALS:
/**
* The status of the backend changed.
* @param status the new status
*/
void statusChanged(Akabei::Backend::Status status);
/**
* A package query got completed.
* @param id the \c QUuid associated with the query
* @param result the result of the query, in this case a list of Akabei::Packages
*/
void queryPackagesCompleted(const QUuid &id, const QList<Akabei::Package*> &result);
/**
* A group query got completed.
* @param id the \c QUuid associated with the query
* @param result the result of the query, in this case a list of Akabei::Groups
*/
void queryGroupsCompleted(const QUuid &id, const QList<Akabei::Group*> &result);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment