Public Member Functions | Private Types | Private Member Functions | Private Attributes

ctkPluginDatabase Class Reference

#include <Libs/PluginFramework/ctkPluginDatabase_p.h>

Collaboration diagram for ctkPluginDatabase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void close ()
 ctkPluginDatabase (ctkPluginStorage *storage)
QStringList findResourcesPath (long pluginId, const QString &path) const
QString getDatabasePath () const
QList< ctkPluginArchive * > getPluginArchives () const
QByteArray getPluginResource (long pluginId, const QString &res) const
ctkPluginArchiveinsertPlugin (const QUrl &location, const QString &localPath, bool createArchive=true)
bool isOpen () const
void open ()
void removeArchive (const ctkPluginArchive *pa)
void setDatabasePath (const QString &databasePath)
virtual ~ctkPluginDatabase ()

Private Types

enum  TransactionType { Read, Write }

Private Member Functions

void beginTransaction (QSqlQuery *query, TransactionType)
void checkConnection () const
bool checkTables () const
void commitTransaction (QSqlQuery *query)
void createTables ()
bool dropTables ()
void executeQuery (QSqlQuery *query, const QString &statement, const QList< QVariant > &bindValues=QList< QVariant >()) const
void rollbackTransaction (QSqlQuery *query)
void updateDB ()

Private Attributes

QString m_connectionName
QString m_databasePath
bool m_inTransaction
bool m_isDatabaseOpen
ctkPluginStoragem_PluginStorage

Detailed Description

Definition at line 34 of file ctkPluginDatabase_p.h.


Member Enumeration Documentation

Enumerator:
Read 
Write 

Definition at line 131 of file ctkPluginDatabase_p.h.


Constructor & Destructor Documentation

ctkPluginDatabase::ctkPluginDatabase ( ctkPluginStorage storage  ) 

Definition at line 62 of file ctkPluginDatabase.cpp.

ctkPluginDatabase::~ctkPluginDatabase (  )  [virtual]

Definition at line 67 of file ctkPluginDatabase.cpp.


Member Function Documentation

void ctkPluginDatabase::beginTransaction ( QSqlQuery *  query,
TransactionType  type 
) [private]

Begins a transcaction based on the type which can be Read or Write.

Exceptions:
ctkPluginDatabaseException 

Definition at line 706 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::checkConnection (  )  const [private]

Checks the database connection.

Exceptions:
ctkPluginDatabaseException 

Definition at line 691 of file ctkPluginDatabase.cpp.

bool ctkPluginDatabase::checkTables (  )  const [private]

Helper method that checks if all the expected tables exist in the database.

Returns true if they all exist and false if any of them don't

Definition at line 631 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::close (  ) 

Closes the plugin database. Throws a ctkPluginDatabaseException of type DB_CONNECTION_INVALID if the database is invalid.

Exceptions:
ctkPluginDatabaseException 

Definition at line 497 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::commitTransaction ( QSqlQuery *  query  )  [private]

Commits a transaction

Exceptions:
ctkPluginDatabaseException 

Definition at line 734 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::createTables (  )  [private]

Helper method that creates the database tables:

Exceptions:
ctkPluginDatabaseException 

Definition at line 577 of file ctkPluginDatabase.cpp.

bool ctkPluginDatabase::dropTables (  )  [private]

Definition at line 644 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::executeQuery ( QSqlQuery *  query,
const QString &  statement,
const QList< QVariant > &  bindValues = QList<QVariant>() 
) const [private]

Helper function that executes the sql query specified in statement. It is assumed that the statement uses positional placeholders and corresponding parameters are placed in the list of bindValues.

Aside: This function may be safely called standalone or within an explicit transaction. If called standalone, it's single query is implicitly wrapped in it's own transaction.

Exceptions:
ctkPluginDatabaseException 

Definition at line 437 of file ctkPluginDatabase.cpp.

QStringList ctkPluginDatabase::findResourcesPath ( long  pluginId,
const QString &  path 
) const

Get a list of resource entries under the given path.

Parameters:
pluginId The id of the plugin from which to get the entries
path A resource path relative to the plugin specific resource prefix.
Returns:
A QStringList containing the cached resource entries.
Exceptions:
ctkPluginDatabaseException 

Definition at line 385 of file ctkPluginDatabase.cpp.

QString ctkPluginDatabase::getDatabasePath (  )  const

Returns the path of the plugin database

Definition at line 525 of file ctkPluginDatabase.cpp.

QList< ctkPluginArchive * > ctkPluginDatabase::getPluginArchives (  )  const

Reads the persisted plugin data and returns a ctkPluginArchive object for each plugin which is not in state UNINSTALLED.

Exceptions:
ctkPluginDatabaseException 

Definition at line 760 of file ctkPluginDatabase.cpp.

QByteArray ctkPluginDatabase::getPluginResource ( long  pluginId,
const QString &  res 
) const

Get a Qt resource cached in the database. The resource path res must be relative to the plugin specific resource prefix, but may start with a '/'.

Parameters:
pluginId The id of the plugin from which to get the resource
res The path to the resource in the plugin
Returns:
The byte array of the cached resource
Exceptions:
ctkPluginDatabaseException 

Definition at line 552 of file ctkPluginDatabase.cpp.

ctkPluginArchive * ctkPluginDatabase::insertPlugin ( const QUrl &  location,
const QString &  localPath,
bool  createArchive = true 
)

Inserts a new plugin into the database. This method assumes that the an entry with the same location and localPath does not yet exist in the database.

Parameters:
location The URL to the plugin.
localPath The path to the plugin library on the local file system.
createArchive If true (default) a new ctkPluginArchive instance is returned.
Exceptions:
ctkPluginDatabaseException 

Definition at line 266 of file ctkPluginDatabase.cpp.

bool ctkPluginDatabase::isOpen (  )  const

Checks if the database is open

Definition at line 685 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::open (  ) 

Opens the plugin database. If the database does not yet exist, it is created using the path from getDatabasePath().

See also:
setDatabasePath(const QString&)
getDatabasePath()
ctkPluginDatabaseException
Exceptions:
ctkPluginDatabaseException 

Definition at line 72 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::removeArchive ( const ctkPluginArchive pa  ) 

Removes all persisted data related to the given ctkPluginArchive.

Exceptions:
ctkPluginDatabaseException 

Definition at line 422 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::rollbackTransaction ( QSqlQuery *  query  )  [private]

Rolls back a transaction

Exceptions:
ctkPluginDatabaseException 

Definition at line 747 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::setDatabasePath ( const QString &  databasePath  ) 

Sets the path of the service database to databasePath

Definition at line 519 of file ctkPluginDatabase.cpp.

void ctkPluginDatabase::updateDB (  )  [private]

Compares the persisted plugin modification time with the file system modification time and updates the database if the persisted data is outdated.

This should only be called once when the database is initially opened.

Definition at line 175 of file ctkPluginDatabase.cpp.


Member Data Documentation

Definition at line 200 of file ctkPluginDatabase_p.h.

Definition at line 199 of file ctkPluginDatabase_p.h.

Definition at line 202 of file ctkPluginDatabase_p.h.

Definition at line 201 of file ctkPluginDatabase_p.h.

Definition at line 203 of file ctkPluginDatabase_p.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines