Revision 5ca225ed
Von Christian Ehringfeld vor mehr als 8 Jahren hinzugefügt
| src/cache.h | ||
|---|---|---|
|
#define CACHE_H
|
||
|
#include <QHash>
|
||
|
#include <QWeakPointer>
|
||
|
#include <QMutex>
|
||
|
#include <QSharedPointer>
|
||
|
#include "entityinstancefactory.h"
|
||
|
#include "entity.h"
|
||
| ... | ... | |
|
template<class T> QSharedPointer<Entity> get(qint64 id) {
|
||
|
Entity *e = EntityInstanceFactory::createInstance<T>();
|
||
|
if (e) {
|
||
|
return this->get(id, QString(EntityHelper::getClassname(e)));
|
||
|
auto r = this->get(id, QString(EntityHelper::getClassname(e)));
|
||
|
delete e;
|
||
|
return r;
|
||
|
}
|
||
|
return QSharedPointer<Entity>();
|
||
|
}
|
||
| ... | ... | |
|
QString generateKey(qint64 id, const QString &classname) const;
|
||
|
private:
|
||
|
QHash<QString, QWeakPointer<Entity>> cache;
|
||
|
QMutex mutex;
|
||
|
};
|
||
|
}
|
||
|
|
||
Auch abrufbar als: Unified diff
improvement