|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TCACHERESOURCEPOOL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TCACHERESOURCEPOOL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcacheresource.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qstring></qstring>
|
|
Toshihiro Shimizu |
890ddd |
#include <qsettings></qsettings>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmutex></qmutex>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TFX_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class THDCacheResourcePool;
|
|
Toshihiro Shimizu |
890ddd |
class TCacheResource;
|
|
Toshihiro Shimizu |
890ddd |
class TFilePath;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TCacheResourcePool : public QObject {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
THDCacheResourcePool *m_hdPool;
|
|
Shinya Kitaoka |
120a6e |
TFilePath m_path;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
typedef std::map<std::string, *="" tcacheresource=""> MemResources;</std::string,>
|
|
Shinya Kitaoka |
120a6e |
MemResources m_memResources;
|
|
Shinya Kitaoka |
120a6e |
QMutex m_memMutex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
unsigned int m_searchCount;
|
|
Shinya Kitaoka |
120a6e |
bool m_foundIterator;
|
|
Shinya Kitaoka |
120a6e |
MemResources::iterator m_searchIterator;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TCacheResourcePool();
|
|
Shinya Kitaoka |
120a6e |
~TCacheResourcePool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
// General functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static TCacheResourcePool *instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setPath(QString cacheRoot, QString projectName, QString sceneName);
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &getPath() const;
|
|
Shinya Kitaoka |
120a6e |
void reset();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void beginCachedSearch();
|
|
Shinya Kitaoka |
120a6e |
void endCachedSearch();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
// Pool management functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void flushResources();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
unsigned int getCurrentSize() const;
|
|
Shinya Kitaoka |
120a6e |
unsigned int getSizeAccessedAfterDays(int days) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void clear();
|
|
Shinya Kitaoka |
120a6e |
void clear(QString cacheRoot, QString projectName, QString sceneName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void clearKeyword(const std::string &keyword);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addReference(TCacheResourceP resource, QString flag);
|
|
Shinya Kitaoka |
120a6e |
void releaseReference(TCacheResourceP resource, QString flag);
|
|
Shinya Kitaoka |
120a6e |
void releaseReferences(QString flag);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void clearFxResources(std::wstring fxId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void clearAccessedUpToSize(int MB);
|
|
Shinya Kitaoka |
120a6e |
void clearAccessedAfterDays(int days);
|
|
Shinya Kitaoka |
120a6e |
void clearAccessedAfterSessions(int sessionsCount);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Automatic management functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setMaximumSize(int MB);
|
|
Shinya Kitaoka |
120a6e |
int getMaximumSize() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setResourcesAccessTimeOut(int days);
|
|
Shinya Kitaoka |
120a6e |
int getResourcesAccessTimeOut() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// void setAutomaticCleanupInterval(int days, int minutes);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
// Resources interaction functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
friend class TCacheResource;
|
|
Shinya Kitaoka |
120a6e |
friend class TCacheResourceP;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TCacheResource *getResource(const std::string &name, bool createIfNone);
|
|
Shinya Kitaoka |
120a6e |
void releaseResource(TCacheResource *resource);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void invalidateAll();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
// HD Pool functions
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isHDActive();
|
|
Shinya Kitaoka |
120a6e |
void startBacking(TCacheResource *resource);
|
|
Shinya Kitaoka |
120a6e |
void saveResourceInfos(TCacheResource *resource);
|
|
Shinya Kitaoka |
120a6e |
void touchBackingPath(TCacheResource *resource);
|
|
Shinya Kitaoka |
120a6e |
QString getPoolRoot(QString cacheRoot, QString projectName,
|
|
Shinya Kitaoka |
120a6e |
QString sceneName);
|
|
Shinya Kitaoka |
120a6e |
void clearResource(QString path);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TCACHERESOURCEPOOL_INCLUDED
|