GenericDataCache Class | Qt Installer Framework Manual

- Qt Installer Framework Manual
- GenericDataCache

# GenericDataCache Class

(QInstaller::GenericDataCache)

The GenericDataCache is a template class for a checksum based storage of items on disk. More...

Header: | #include <GenericDataCache>
Inherited By: | QInstaller::MetadataCache

- List of all members, including inherited members

## Public Types

enum | RegisterMode { Copy, Move }

## Public Functions

| GenericDataCache()
| GenericDataCache(const QString &path, const QString &type, const QString &version)
virtual | ~GenericDataCache()
bool | clear()
QString | errorString() const
bool | initialize()
bool | isValid() const
T * | itemByChecksum(const QByteArray &checksum) const
T * | itemByPath(const QString &path) const
QList<T *> | items() const
QList<T *> | obsoleteItems() const
QString | path() const
bool | registerItem(T *item, bool replace = false, QInstaller::GenericDataCache::RegisterMode mode = Copy)
bool | removeItem(const QByteArray &checksum)
void | setPath(const QString &path)
void | setType(const QString &type)
void | setVersion(const QString &version)
bool | sync()

## Detailed Description

The GenericDataCache is a template class for a checksum based storage of items on disk.

GenericDataCache<T> manages a cache storage for a set path(), which contains a subdirectory for each registered item. An item of type `T` should implement methods declared in the CacheableItem interface. The GenericDataCache<T> class can still be explicitly specialized to use the derived type as a template argument, to allow retrieving items as the derived type without casting.

Each cache has a manifest file in its root directory, which lists the version and wrapped type of the cache, and all its items. The file is updated automatically when the cache object is destructed, or it can be updated periodically by calling sync().

## Member Type Documentation

### enum GenericDataCache::RegisterMode

This enum holds the possible values for modes of registering items to cache.

Constant | Value | Description
--- | --- | ---
`QInstaller::GenericDataCache::Copy` | `0` | The contents of the item are copied to the cache.
`QInstaller::GenericDataCache::Move` | `1` | The contents of the item are move to the cache.

## Member Function Documentation

### GenericDataCache::GenericDataCache()

Default constructs an instance of GenericDataCache.

### GenericDataCache::GenericDataCache(const QString &path, const QString &type, const QString &version)

Default constructs an instance of GenericDataCache.

### `[virtual]` GenericDataCache::~GenericDataCache()

Destroys the instance of GenericDataCache. The destructor is virtual.

### bool GenericDataCache::clear()

### QString GenericDataCache::errorString() const

### bool GenericDataCache::initialize()

### bool GenericDataCache::isValid() const

### T *GenericDataCache::itemByChecksum(const QByteArray &checksum) const

### T *GenericDataCache::itemByPath(const QString &path) const

### QList<T *> GenericDataCache::items() const

### QList<T *> GenericDataCache::obsoleteItems() const

### QString GenericDataCache::path() const

See also setPath().

### bool GenericDataCache::registerItem(T *item, bool replace = false, QInstaller::GenericDataCache::RegisterMode mode = Copy)

### bool GenericDataCache::removeItem(const QByteArray &checksum)

### void GenericDataCache::setPath(const QString &path)

See also path().

### void GenericDataCache::setType(const QString &type)

### void GenericDataCache::setVersion(const QString &version)

### bool GenericDataCache::sync()