TuttleOFX  1
tuttle::host::ThumbnailDiskCache Class Reference

An helper to cache image thumbnails on your HDD. More...

#include <ThumbnailDiskCache.hpp>

Collaboration diagram for tuttle::host::ThumbnailDiskCache:

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

Detailed Description

An helper to cache image thumbnails on your HDD.

Definition at line 22 of file ThumbnailDiskCache.hpp.


Member Typedef Documentation

Definition at line 28 of file ThumbnailDiskCache.hpp.


Constructor & Destructor Documentation

tuttle::host::ThumbnailDiskCache::ThumbnailDiskCache ( ) [inline]

Definition at line 31 of file ThumbnailDiskCache.hpp.


Member Function Documentation

ThumbnailDiskCache::KeyType tuttle::host::ThumbnailDiskCache::buildKey ( const boost::filesystem::path &  imagePath) const

Tranform the original image path into a cache key.

Parameters:
[in]imagePathThe 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.

Warning:
There is no check if the associated thumbnail is up-to-date.
See also:
containsUpToDate

Definition at line 46 of file ThumbnailDiskCache.hpp.

References _diskCacheTranslator, and tuttle::host::DiskCacheTranslator::contains().

Here is the call graph for this function:

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().

Here is the call graph for this function:

ThumbnailDiskCache::TImage tuttle::host::ThumbnailDiskCache::create ( KeyType key,
const boost::filesystem::path &  imagePath 
)

Create a thumbnail for an image path and the associated key.

Parameters:
[out]keycache key
[in]imagePathpath to the full image
Returns:
thumbnail thumbnail generated from the 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().

Here is the call graph for this function:

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.

Parameters:
[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.

Here is the call graph for this function:

TImage tuttle::host::ThumbnailDiskCache::getThumbnail ( const boost::filesystem::path &  imagePath) [inline]

Definition at line 93 of file ThumbnailDiskCache.hpp.

References getThumbnail().

Referenced by getThumbnail().

Here is the call graph for this function:

TImage tuttle::host::ThumbnailDiskCache::getThumbnail ( const std::string &  imagePath) [inline]

Definition at line 95 of file ThumbnailDiskCache.hpp.

References getThumbnail().

Referenced by getThumbnail().

Here is the call graph for this function:

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.

Parameters:
[in]keycache key

Definition at line 89 of file ThumbnailDiskCache.cpp.

References _diskCacheTranslator, tuttle::host::DiskCacheTranslator::keyToAbsolutePath(), tuttle::host::loadImage(), and s_thumbnailExtension.

Referenced by retrieveThumbnail().

Here is the call graph for this function:

TImage tuttle::host::ThumbnailDiskCache::retrieveThumbnail ( const boost::filesystem::path &  imagePath) const [inline]

Definition at line 64 of file ThumbnailDiskCache.hpp.

References buildKey(), and retrieveThumbnail().

Here is the call graph for this function:

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().

Here is the call graph for this function:

void tuttle::host::ThumbnailDiskCache::setRootDir ( const std::string &  rootDir) [inline]

Definition at line 38 of file ThumbnailDiskCache.hpp.

References setRootDir().

Referenced by setRootDir().

Here is the call graph for this function:


Field Documentation

Definition at line 25 of file ThumbnailDiskCache.hpp.

Referenced by create(), getThumbnail(), and retrieveThumbnail().

Definition at line 26 of file ThumbnailDiskCache.hpp.

Referenced by create().


The documentation for this class was generated from the following files: