openModeller
Version 1.5.0
|
#include <CacheManager.hh>
Public Member Functions | |
~CacheManager () | |
Static Public Member Functions | |
static void | initialize (const std::string dir="") |
static bool | isCached (const std::string id, const std::string subdir="") |
static bool | isCachedMd5 (const std::string id, const std::string subdir="") |
static void | cache (const std::string id, const std::ostringstream &content, const std::string subdir="") |
static void | cacheMd5 (const std::string id, const std::ostringstream &content, const std::string subdir="") |
static std::string | getContentLocation (const std::string id, const std::string subdir="") |
static std::string | getContentLocationMd5 (const std::string id, const std::string subdir="") |
static std::string | getContentIdMd5 (const std::string id) |
static int | eraseCache (const std::string id, const std::string subdir="") |
static int | eraseCacheMd5 (const std::string id, const std::string subdir="") |
Private Member Functions | |
CacheManager () | |
Static Private Member Functions | |
static CacheManager & | _getInstance () |
static void | _ensureInitialized () |
Private Attributes | |
std::string | _cacheDir |
Declaration of CacheManager class.
LICENSE INFORMATION
Copyright(c) 2012 by CRIA - Centro de Referencia em Informacao Ambiental
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:
http://www.gnu.org/copyleft/gpl.html This class was initially created to help handling openModeller WCS rasters. It is used by env_io/WcsProxyRaster, which receives an openModeller WCS raster identifier in the form wcs>wcs_service_url>coverage_id and uses the cache manager to convert the identifier into a safe MD5 hash string that can be used as a file name to store the WCS XML content expected by GDAL. In the future it may be used for other things, such as caching background points or caching entire rasters. TODO: write flush method (so far the cache directories tend to keep growing).
Definition at line 48 of file CacheManager.hh.
CacheManager::~CacheManager | ( | ) |
Definition at line 61 of file CacheManager.cpp.
|
private |
Definition at line 53 of file CacheManager.cpp.
|
staticprivate |
Definition at line 131 of file CacheManager.cpp.
References _cacheDir, _getInstance(), and initialize().
Referenced by cache(), getContentLocation(), and isCached().
|
staticprivate |
Definition at line 68 of file CacheManager.cpp.
Referenced by _ensureInitialized(), cache(), getContentLocation(), initialize(), and isCached().
|
static |
Cache the specified content identified by id.
id | Content identifier. |
content | Content. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 184 of file CacheManager.cpp.
References _cacheDir, _ensureInitialized(), _getInstance(), createPath(), Log::error(), and Log::instance().
Referenced by cacheMd5().
|
static |
Cache the specified content identified by id. Id is converted to an MD5 hash.
id | Content identifier. |
content | Content. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 219 of file CacheManager.cpp.
References cache(), and getContentIdMd5().
|
static |
Erases cached content identified by the specified id.
id | Content identifier. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 285 of file CacheManager.cpp.
References getContentLocation().
Referenced by eraseCacheMd5().
|
static |
Erases cached content identified by the specified id. Id is converted to an MD5 hash.
id | Content identifier. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 295 of file CacheManager.cpp.
References eraseCache(), and getContentIdMd5().
|
static |
Return the local id of cached content. Id is converted to an MD5 hash.
id | Content identifier. |
Definition at line 258 of file CacheManager.cpp.
References MD5_Final(), MD5_Init(), and MD5_Update().
Referenced by cacheMd5(), eraseCacheMd5(), getContentLocationMd5(), and isCachedMd5().
|
static |
Return the location of cached content.
id | Content identifier. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 227 of file CacheManager.cpp.
References _cacheDir, _ensureInitialized(), and _getInstance().
Referenced by eraseCache(), and getContentLocationMd5().
|
static |
Return the location of cached content. Id is converted to an MD5 hash.
id | Content identifier. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 250 of file CacheManager.cpp.
References getContentIdMd5(), and getContentLocation().
|
static |
Set the cache directory. When not specified, try the OM_CACHE_PATH environment variable. If undefined, use current_dir/cache.
dir | Cache directory |
Definition at line 77 of file CacheManager.cpp.
References _cacheDir, _getInstance(), Settings::count(), createPath(), Log::debug(), Settings::get(), getWorkingPath(), Log::instance(), and pathExists().
Referenced by _ensureInitialized().
|
static |
Indicates if the specified content identified by id is cached.
id | Content identifier. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 144 of file CacheManager.cpp.
References _cacheDir, _ensureInitialized(), _getInstance(), and createPath().
Referenced by isCachedMd5().
|
static |
Indicates if the specified content identified by id is cached. Id is converted to an MD5 hash.
id | Content identifier. |
subdir | Subdirectory inside cache dir. Optional. |
Definition at line 176 of file CacheManager.cpp.
References getContentIdMd5(), and isCached().
|
private |
Definition at line 135 of file CacheManager.hh.
Referenced by _ensureInitialized(), cache(), getContentLocation(), initialize(), and isCached().