• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

DjVuFileCache Class Reference

DjVuFileCache# is a simple list of {DjVuFile} instances. More...

#include <DjVuFileCache.h>

Inheritance diagram for DjVuFileCache:

Inheritance graph
[legend]

List of all members.


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

void DjVuFileCache::add_file ( const GP< DjVuFile > &  file  ) 

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]

Clears the cache.

All items will be deleted.

Definition at line 260 of file DjVuFileCache.h.

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  ) 

Removes file file# from the cache.

Definition at line 229 of file DjVuFileCache.cpp.

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.

void DjVuFileCache::file_added ( const GP< DjVuFile > &  file  )  [protected, virtual]

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.

void DjVuFileCache::file_cleared ( const GP< DjVuFile > &  file  )  [protected, virtual]

This function is called when after the cache decides to get rid of the file.

Definition at line 264 of file DjVuFileCache.cpp.

void DjVuFileCache::file_deleted ( const GP< DjVuFile > &  file  )  [protected, virtual]

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]

Returns the maximum allowed size of the cache.

Definition at line 272 of file DjVuFileCache.h.

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:
  • DjVuFileCache.h
  • DjVuFileCache.cpp

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal