TuttleOFX
1
|
An helper to cache image thumbnails on your HDD. More...
#include <ThumbnailDiskCache.hpp>
Public Types | |
typedef DiskCacheTranslator::KeyType | KeyType |
typedef ::boost::shared_ptr < attribute::Image > | TImage |
Public Member Functions | |
ThumbnailDiskCache () | |
void | setRootDir (const boost::filesystem::path &rootDir) |
Set the base directory for all cached files. | |
void | setRootDir (const std::string &rootDir) |
bool | contains (const KeyType &key) const |
Check if the key exists in the cache. | |
bool | containsUpToDate (const boost::filesystem::path &imagePath) const |
Check if the imagePath has a thumbnail in the cache. | |
TImage | retrieveThumbnail (const KeyType key) const |
Retrieve an existing image directly from the cache without any check. Throw an error if the key doesn't exist. | |
TImage | retrieveThumbnail (const boost::filesystem::path &imagePath) const |
TImage | create (KeyType &key, const boost::filesystem::path &imagePath) |
Create a thumbnail for an image path and the associated key. | |
KeyType | buildKey (const boost::filesystem::path &imagePath) const |
Tranform the original image path into a cache key. | |
TImage | getThumbnail (KeyType &key, const boost::filesystem::path &imagePath) |
Get a thumbnail from an image filepath. If not in the cache, creates and adds it into the cache. | |
TImage | getThumbnail (const boost::filesystem::path &imagePath) |
TImage | getThumbnail (const std::string &imagePath) |
Static Public Attributes | |
static const std::string | s_thumbnailExtension |
static const int | s_thumbnailMaxSize |
Private Attributes | |
DiskCacheTranslator | _diskCacheTranslator |
An helper to cache image thumbnails on your HDD.
Definition at line 22 of file ThumbnailDiskCache.hpp.
Definition at line 27 of file ThumbnailDiskCache.hpp.
typedef ::boost::shared_ptr<attribute::Image> tuttle::host::ThumbnailDiskCache::TImage |
Definition at line 28 of file ThumbnailDiskCache.hpp.
tuttle::host::ThumbnailDiskCache::ThumbnailDiskCache | ( | ) | [inline] |
Definition at line 31 of file ThumbnailDiskCache.hpp.
ThumbnailDiskCache::KeyType tuttle::host::ThumbnailDiskCache::buildKey | ( | const boost::filesystem::path & | imagePath | ) | const |
Tranform the original image path into a cache key.
[in] | imagePath | The path of an image file |
Definition at line 109 of file ThumbnailDiskCache.cpp.
Referenced by containsUpToDate(), create(), getThumbnail(), and retrieveThumbnail().
bool tuttle::host::ThumbnailDiskCache::contains | ( | const KeyType & | key | ) | const [inline] |
Check if the key
exists in the cache.
Definition at line 46 of file ThumbnailDiskCache.hpp.
References _diskCacheTranslator, and tuttle::host::DiskCacheTranslator::contains().
bool tuttle::host::ThumbnailDiskCache::containsUpToDate | ( | const boost::filesystem::path & | imagePath | ) | const |
Check if the imagePath
has a thumbnail in the cache.
Definition at line 75 of file ThumbnailDiskCache.cpp.
References _diskCacheTranslator, buildKey(), tuttle::host::DiskCacheTranslator::contains(), and tuttle::host::DiskCacheTranslator::keyToAbsolutePath().
Referenced by getThumbnail().
ThumbnailDiskCache::TImage tuttle::host::ThumbnailDiskCache::create | ( | KeyType & | key, |
const boost::filesystem::path & | imagePath | ||
) |
Create a thumbnail for an image path and the associated key.
[out] | key | cache key |
[in] | imagePath | path to the full image |
imagePath
file. Definition at line 94 of file ThumbnailDiskCache.cpp.
References _diskCacheTranslator, buildKey(), tuttle::host::DiskCacheTranslator::create(), tuttle::host::loadAndGenerateThumbnail(), s_thumbnailExtension, and s_thumbnailMaxSize.
Referenced by getThumbnail().
ThumbnailDiskCache::TImage tuttle::host::ThumbnailDiskCache::getThumbnail | ( | KeyType & | key, |
const boost::filesystem::path & | imagePath | ||
) |
Get a thumbnail from an image filepath. If not in the cache, creates and adds it into the cache.
[out] | key | |
[in] | imagePath |
Definition at line 116 of file ThumbnailDiskCache.cpp.
References _diskCacheTranslator, buildKey(), containsUpToDate(), create(), tuttle::host::DiskCacheTranslator::keyToAbsolutePath(), tuttle::host::loadImage(), and s_thumbnailExtension.
TImage tuttle::host::ThumbnailDiskCache::getThumbnail | ( | const boost::filesystem::path & | imagePath | ) | [inline] |
Definition at line 93 of file ThumbnailDiskCache.hpp.
References getThumbnail().
Referenced by getThumbnail().
TImage tuttle::host::ThumbnailDiskCache::getThumbnail | ( | const std::string & | imagePath | ) | [inline] |
Definition at line 95 of file ThumbnailDiskCache.hpp.
References getThumbnail().
Referenced by getThumbnail().
ThumbnailDiskCache::TImage tuttle::host::ThumbnailDiskCache::retrieveThumbnail | ( | const KeyType | key | ) | const |
Retrieve an existing image directly from the cache without any check. Throw an error if the key doesn't exist.
[in] | key | cache key |
Definition at line 89 of file ThumbnailDiskCache.cpp.
References _diskCacheTranslator, tuttle::host::DiskCacheTranslator::keyToAbsolutePath(), tuttle::host::loadImage(), and s_thumbnailExtension.
Referenced by retrieveThumbnail().
TImage tuttle::host::ThumbnailDiskCache::retrieveThumbnail | ( | const boost::filesystem::path & | imagePath | ) | const [inline] |
Definition at line 64 of file ThumbnailDiskCache.hpp.
References buildKey(), and retrieveThumbnail().
void tuttle::host::ThumbnailDiskCache::setRootDir | ( | const boost::filesystem::path & | rootDir | ) | [inline] |
Set the base directory for all cached files.
Definition at line 37 of file ThumbnailDiskCache.hpp.
References _diskCacheTranslator, and tuttle::host::DiskCacheTranslator::setRootDir().
void tuttle::host::ThumbnailDiskCache::setRootDir | ( | const std::string & | rootDir | ) | [inline] |
Definition at line 38 of file ThumbnailDiskCache.hpp.
References setRootDir().
Referenced by setRootDir().
Definition at line 98 of file ThumbnailDiskCache.hpp.
Referenced by contains(), containsUpToDate(), create(), getThumbnail(), retrieveThumbnail(), and setRootDir().
const std::string tuttle::host::ThumbnailDiskCache::s_thumbnailExtension [static] |
Definition at line 25 of file ThumbnailDiskCache.hpp.
Referenced by create(), getThumbnail(), and retrieveThumbnail().
const int tuttle::host::ThumbnailDiskCache::s_thumbnailMaxSize [static] |
Definition at line 26 of file ThumbnailDiskCache.hpp.
Referenced by create().