kviewshell
DjVuFileCache Class Reference
DjVuFileCache# is a simple list of {DjVuFile} instances. More...
#include <DjVuFileCache.h>
Classes | |
class | Item |
Public Member Functions | |
void | add_file (const GP< DjVuFile > &file) |
void | clear (void) |
void | del_file (const DjVuFile *file) |
void | enable (bool en) |
int | get_max_size (void) const |
bool | is_enabled (void) const |
void | set_max_size (int max_size) |
virtual | ~DjVuFileCache (void) |
Static Public Member Functions | |
static GP< DjVuFileCache > | create (const int max_size=5 *2 *1024 *1024) |
Protected Member Functions | |
DjVuFileCache (const int max_size=5 *2 *1024 *1024) | |
virtual void | file_added (const GP< DjVuFile > &file) |
virtual void | file_cleared (const GP< DjVuFile > &file) |
virtual void | file_deleted (const GP< DjVuFile > &file) |
GPList< Item > | get_items (void) |
Protected Attributes | |
GCriticalSection | class_lock |
Detailed Description
DjVuFileCache# is a simple list of {DjVuFile} instances.It keeps track of the total size of all elements and can get rid of the oldest one once the total size becomes over some threshold. Its main purpose is to keep the added {DjVuFile} instances alive until their size exceeds some given threshold (set by {set_maximum_size}() function). The user is supposed to use {DjVuPortcaster::name_to_port}() to find a file corresponding to a given name. The cache provides no naming services
Definition at line 126 of file DjVuFileCache.h.
Constructor & Destructor Documentation
DjVuFileCache::DjVuFileCache | ( | const int | max_size = 5*2*1024*1024 |
) | [inline, protected] |
Definition at line 256 of file DjVuFileCache.h.
DjVuFileCache::~DjVuFileCache | ( | void | ) | [virtual] |
Definition at line 78 of file DjVuFileCache.cpp.
Member Function Documentation
Adds the given file to the cache.
It it's already there, its timestamp will be refreshed.
Definition at line 112 of file DjVuFileCache.cpp.
void DjVuFileCache::clear | ( | void | ) | [inline] |
GP< DjVuFileCache > DjVuFileCache::create | ( | const int | max_size = 5*2*1024*1024 |
) | [inline, static] |
Constructs the DjVuFileCache#.
- Parameters:
-
max_size Maximum allowed size of the cache in bytes.
Definition at line 280 of file DjVuFileCache.h.
void DjVuFileCache::del_file | ( | const DjVuFile * | file | ) |
void DjVuFileCache::enable | ( | bool | en | ) |
Enables or disables the cache.
See {is_enabled}() for details
- Parameters:
-
en - If {en} is TRUE, the cache will be enabled. Otherwise it will be disabled.
Definition at line 105 of file DjVuFileCache.cpp.
This function is called right after the given file has been added to the cache for management.
Definition at line 258 of file DjVuFileCache.cpp.
This function is called when after the cache decides to get rid of the file.
Definition at line 264 of file DjVuFileCache.cpp.
This function is called when the given file is no longer managed by the cache.
Definition at line 261 of file DjVuFileCache.cpp.
GPList< DjVuFileCache::Item > DjVuFileCache::get_items | ( | void | ) | [protected] |
Definition at line 250 of file DjVuFileCache.cpp.
int DjVuFileCache::get_max_size | ( | void | ) | const [inline] |
bool DjVuFileCache::is_enabled | ( | void | ) | const [inline] |
Returns TRUE# if the cache is enabled, FALSE# otherwise.
When a cache is disabled, {add_file}(), and {del_file}() do nothing. But the {maximum size} is preserved inside the class so that next time the cache is enabled, it will be configured the same way. Clearly this "enable/disable" thing is for convenience only. One could easily simulate this behavior by setting the {maximum size} of the cache to ZERO#.
Definition at line 266 of file DjVuFileCache.h.
void DjVuFileCache::set_max_size | ( | int | max_size | ) |
Sets new maximum size.
If the total size of all items in the cache is greater than max_size#, the cache will be deleting the oldest items until the size is OK.
Definition at line 91 of file DjVuFileCache.cpp.
Member Data Documentation
GCriticalSection DjVuFileCache::class_lock [protected] |
Definition at line 194 of file DjVuFileCache.h.
The documentation for this class was generated from the following files: