Guiliani  Version 2.5 revision 7293 (documentation build 13)
CGUIImageCache Class Referenceabstract

Image cache base class. More...

#include <GUIImageCache.h>

Inheritance diagram for CGUIImageCache:

Public Member Functions

eC_UInt GetCacheSizeLimit () const
 
virtual eC_UInt GetCurrentMemoryUsage () const =0
 
virtual eC_UInt GetImageSize (const ImageResource_t &eImageID) const =0
 
virtual eC_Bool ReadCacheSettingsFromFile (const eC_String &kPath)=0
 
eC_Bool SetCacheSizeLimit (eC_UInt uiCacheSizeLimit)
 
virtual void SetFreeReplacementPolicy (CGUIImageCacheReplacementPolicy *pPolicy)
 
void SetReadResolutionAppendix (const eC_String &kAppendString)
 
virtual void SetUsedReplacementPolicy (CGUIImageCacheReplacementPolicy *pPolicy)
 

Static Public Member Functions

static void CreateInstance (eC_UInt uiSize=100 *1024 *1024, ReplacementPolicyType_t eUsed=IC_REPLACEMENT_POLICY_LRU, ReplacementPolicyType_t eFree=IC_REPLACEMENT_POLICY_LRU)
 
static void DeleteInstance ()
 Deletes the only instance of this class.
 
static CGUIImageCacheGetInstance ()
 

Protected Member Functions

virtual ~CGUIImageCache ()
 Destructor.
 
virtual void CopyCacheContents (CGUIImageCacheReplacementPolicy *pOldPolicy, CGUIImageCacheReplacementPolicy *pNewPolicy)=0
 
virtual eC_Bool FreeSpace (eC_UInt uiSpaceToFree)=0
 
virtual eC_Bool LoadImg (const eC_String &kPath, const ImageResource_t &eImageID)=0
 
virtual void MarkAsFree (const ImageResource_t &eImageID)=0
 
virtual void MarkAsUsed (const ImageResource_t &eImageID)=0
 
virtual void NotifyImageAccessInternal (const ImageResource_t &eImageID)=0
 
virtual eC_Bool PreloadImg (const eC_String &psPath, const ImageResource_t &eImageID)=0
 
virtual eC_Bool UnloadSpecificImage (const ImageResource_t &eImageID)=0
 

Static Protected Member Functions

static void NotifyImageAccess (const ImageResource_t &eImageID)
 

Protected Attributes

eC_String m_kAppendString
 Extension to the resolution for config reading.
 
CGUIImageCacheReplacementManagerm_pFreeListManager
 Pointer to the current free list manager.
 
CGUIImageCacheReplacementPolicym_pFreeReplacementPolicy
 Pointer to the current free list replacement policy.
 
CGUIImageCacheReplacementManagerm_pUsedListManager
 Pointer to the current used list manager.
 
CGUIImageCacheReplacementPolicym_pUsedReplacementPolicy
 Pointer to the current used list replacement policy.
 
eC_UInt m_uiCacheSizeLimit
 Maximum amount of memory used by images.
 

Static Protected Attributes

static CGUIImageCachems_pInstance
 Pointer to singleton instance.
 

Friends

class CGfxWrap
 The graphics wrapper calls NotifyImageAccess. More...
 
class CGUIBackgroundImageLoaderThread
 
class CGUIResourceManager
 

Detailed Description

Image cache base class.

Member Function Documentation

◆ CopyCacheContents()

virtual void CGUIImageCache::CopyCacheContents ( CGUIImageCacheReplacementPolicy pOldPolicy,
CGUIImageCacheReplacementPolicy pNewPolicy 
)
protectedpure virtual

Copies the cache contents of one replacement policy to the other. This is needed for changing replacement policies at runtime. Used as a hook in the template methods SetFreeReplacgementPolicy and SetUsedReplacementPolicy.

Parameters
pOldPolicyold replacement policy object
pNewPolicynew replacement policy object

Implemented in CGUIImageCacheImpl.

◆ CreateInstance()

static void CGUIImageCache::CreateInstance ( eC_UInt  uiSize = 100 *1024 *1024,
ReplacementPolicyType_t  eUsed = IC_REPLACEMENT_POLICY_LRU,
ReplacementPolicyType_t  eFree = IC_REPLACEMENT_POLICY_LRU 
)
static

Creates the only instance of this class.

Parameters
uiSizeThe initial size of the cache in bytes. Default is 100MB.
eUsedPolicy for used images
eFreePolicy for free images

◆ FreeSpace()

virtual eC_Bool CGUIImageCache::FreeSpace ( eC_UInt  uiSpaceToFree)
protectedpure virtual

Deletes images from the cache until its size is reduced by uiBytes.

Parameters
uiSpaceToFreethe amount of memory to be freed
Returns
True if the full amount of memory could be freed. Freeing space can fail if not enough images are allowed to be unloaded. In case of failure the maximum possible amount of space is freed.

Implemented in CGUIImageCacheImpl.

◆ GetCacheSizeLimit()

eC_UInt CGUIImageCache::GetCacheSizeLimit ( ) const
inline

Returns the size limit for the image cache.

Returns
the maximum allowed size of the cache in bytes

◆ GetCurrentMemoryUsage()

virtual eC_UInt CGUIImageCache::GetCurrentMemoryUsage ( ) const
pure virtual

Determines the amount of memory used by the cached items.

Returns
used size in bytes

Implemented in CGUIImageCacheImpl.

◆ GetImageSize()

virtual eC_UInt CGUIImageCache::GetImageSize ( const ImageResource_t eImageID) const
pure virtual

Get the size of an image resource in memory.

Parameters
eImageIDID of the image.
Returns
Size of the image resource when loaded into memory

Implemented in CGUIImageCacheImpl.

◆ GetInstance()

static CGUIImageCache * CGUIImageCache::GetInstance ( )
inlinestatic

Retrieves the only instance of this class.

Returns
pointer to the only instance

◆ LoadImg()

virtual eC_Bool CGUIImageCache::LoadImg ( const eC_String &  kPath,
const ImageResource_t eImageID 
)
protectedpure virtual

Tries to load an image and adds it to the cache. Needed space is freed before adding, if necessary.

Parameters
kPaththe path to the image file. Used for determining the size and for loading the image.
eImageIDthe image's ID
Returns
True if the image was successfully loaded. Loading can fail if not enough space for the image can be freed.

Implemented in CGUIImageCacheImpl.

◆ MarkAsFree()

virtual void CGUIImageCache::MarkAsFree ( const ImageResource_t eImageID)
protectedpure virtual

Moves an (already loaded) image to the list of cached (but unused) images. The image is moved from the used list to the free list.

Parameters
eImageIDthe image's ID

Implemented in CGUIImageCacheImpl.

◆ MarkAsUsed()

virtual void CGUIImageCache::MarkAsUsed ( const ImageResource_t eImageID)
protectedpure virtual

Marks an (already loaded) image as used. The image is moved from the free list to the used list.

Parameters
eImageIDthe image's ID

Implemented in CGUIImageCacheImpl.

◆ NotifyImageAccess()

static void CGUIImageCache::NotifyImageAccess ( const ImageResource_t eImageID)
inlinestaticprotected

Notifies the cache about an access (e.g. blitting,...) to an image.

Parameters
eImageIDthe image that was accessed.

◆ NotifyImageAccessInternal()

virtual void CGUIImageCache::NotifyImageAccessInternal ( const ImageResource_t eImageID)
protectedpure virtual

Notifies the cache about an access (e.g. blitting,...) to an image.

Parameters
eImageIDthe image that was accessed.

Implemented in CGUIImageCacheImpl.

◆ PreloadImg()

virtual eC_Bool CGUIImageCache::PreloadImg ( const eC_String &  psPath,
const ImageResource_t eImageID 
)
protectedpure virtual

Special version of LoadImage for preloading images at start-up. Once the cache is full, needed space is not freed.

Parameters
psPaththe path to the image file used for determining the size and for the actual loading
eImageIDthe image's ID
Returns
True if the image was successfully loaded. Loading fails if the cache is full.

Implemented in CGUIImageCacheImpl.

◆ ReadCacheSettingsFromFile()

virtual eC_Bool CGUIImageCache::ReadCacheSettingsFromFile ( const eC_String &  kPath)
pure virtual

Reads the cache settings from a file. GUIStreamReader has to be initialized.

Parameters
kPathto the destination file.
Returns
True if the configuration was read successfully.
See also
CGUIStreamReader

Implemented in CGUIImageCacheImpl.

◆ SetCacheSizeLimit()

eC_Bool CGUIImageCache::SetCacheSizeLimit ( eC_UInt  uiCacheSizeLimit)

Sets the size limit for the image cache.

Parameters
uiCacheSizeLimitthe new maximum allowed size of the cache in bytes
Returns
True if new size limit could be set. Setting of size limit can fail if
  • not enough are allowed to be unloaded to decrease cache size or
  • not enough memory left to increase cache size. In case of failure the size limit is set to the lowest (or highest, respectively) possible value.

◆ SetFreeReplacementPolicy()

virtual void CGUIImageCache::SetFreeReplacementPolicy ( CGUIImageCacheReplacementPolicy pPolicy)
virtual

Set the replacement policy for the image cache. If a previous policy exists, this method deletes it. Calling this when the cache already contains elements may result in undefined behavior. It is therefore advisable to only call this method once, at startup.

Parameters
pPolicythe replacement policy
Deprecated:
Function call may result in undefined behaviour, use CreateInstance-parameters instead

◆ SetReadResolutionAppendix()

void CGUIImageCache::SetReadResolutionAppendix ( const eC_String &  kAppendString)
inline

Tells the image cache to append a string to the resolution when reading its configuration. The method ReadCacheSettingsFromFile() decides with configuration entry it reads by querying the screen resolution from the graphics wrapper and appending this string. Needs to be called before replacement policies are initialized.

Parameters
kAppendStringthe String to be appended to the resolution while reading the configuration.

◆ SetUsedReplacementPolicy()

virtual void CGUIImageCache::SetUsedReplacementPolicy ( CGUIImageCacheReplacementPolicy pPolicy)
virtual

Set the replacement policy for the image cache. If a previous policy exists, this method deletes it. Calling this when the cache already contains elements may result in undefined behavior. It is therefore advisable to only call this method once, at startup.

Parameters
pPolicythe replacement policy
Deprecated:
Function call may result in undefined behaviour, use CreateInstance-parameters instead

◆ UnloadSpecificImage()

virtual eC_Bool CGUIImageCache::UnloadSpecificImage ( const ImageResource_t eImageID)
protectedpure virtual

Unloads a specific image and removes it from the free list.

Parameters
eImageIDthe image's ID
Returns
True if the image was successfully unloaded, False if it was not in memory in the first place.

Implemented in CGUIImageCacheImpl.

Friends And Related Function Documentation

◆ CGfxWrap

friend class CGfxWrap
friend

The graphics wrapper calls NotifyImageAccess.

◆ CGUIBackgroundImageLoaderThread

friend class CGUIBackgroundImageLoaderThread
friend

◆ CGUIResourceManager

friend class CGUIResourceManager
friend

To access methods involved with loading and unloading of images, the Resource Manager must be a friend class.


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