Guiliani  Version 2.6 revision 7293 (documentation build 12)
CGUIImageCacheImpl Class Reference

Implementation of Cache for Guiliani image resources. More...

#include <GUIImageCacheImpl.h>

Inheritance diagram for CGUIImageCacheImpl:

Public Member Functions

eC_UInt GetCurrentMemoryUsage () const
 
eC_UInt GetFreeListSize () const
 
eC_UInt GetImageSize (const ImageResource_t &eImageID) const
 
eC_UInt GetUsedListSize () const
 
eC_Bool ReadCacheSettingsFromFile (const eC_String &rkPath)
 
- Public Member Functions inherited from CGUIImageCache
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)
 

Protected Member Functions

 CGUIImageCacheImpl (eC_UInt uiCacheSizeLimit, ReplacementPolicyType_t eUsed, ReplacementPolicyType_t eFree)
 
 ~CGUIImageCacheImpl ()
 Destructor.
 
void CopyCacheContents (CGUIImageCacheReplacementPolicy *pOldPolicy, CGUIImageCacheReplacementPolicy *pNewPolicy)
 
eC_Bool FreeSpace (eC_UInt uiSpaceToFree)
 
eC_Bool LoadImg (const eC_String &psPath, const ImageResource_t &eImageID)
 
void MarkAsFree (const ImageResource_t &eImageID)
 
void MarkAsUsed (const ImageResource_t &eImageID)
 
void NotifyImageAccessInternal (const ImageResource_t &eImageID)
 
eC_Bool PreloadImg (const eC_String &psPath, const ImageResource_t &eImageID)
 
eC_Bool UnloadSpecificImage (const ImageResource_t &eImageID)
 
- Protected Member Functions inherited from CGUIImageCache
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
 

Friends

class CGUIImageCache
 

Additional Inherited Members

- Static Public Member Functions inherited from CGUIImageCache
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 ()
 
- Static Protected Member Functions inherited from CGUIImageCache
static void NotifyImageAccess (const ImageResource_t &eImageID)
 
- Protected Attributes inherited from CGUIImageCache
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 inherited from CGUIImageCache
static CGUIImageCachems_pInstance
 Pointer to singleton instance.
 

Detailed Description

Implementation of Cache for Guiliani image resources.

Constructor & Destructor Documentation

◆ CGUIImageCacheImpl()

CGUIImageCacheImpl::CGUIImageCacheImpl ( eC_UInt  uiCacheSizeLimit,
ReplacementPolicyType_t  eUsed,
ReplacementPolicyType_t  eFree 
)
protected

Constructor.

Parameters
uiCacheSizeLimitThe maximum amount of memory that can be used by images.
eUsedPolicy for used images
eFreePolicy for free images

Member Function Documentation

◆ CopyCacheContents()

void CGUIImageCacheImpl::CopyCacheContents ( CGUIImageCacheReplacementPolicy pOldPolicy,
CGUIImageCacheReplacementPolicy pNewPolicy 
)
protectedvirtual

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

Implements CGUIImageCache.

◆ FreeSpace()

eC_Bool CGUIImageCacheImpl::FreeSpace ( eC_UInt  uiSpaceToFree)
protectedvirtual

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

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.

Implements CGUIImageCache.

◆ GetCurrentMemoryUsage()

eC_UInt CGUIImageCacheImpl::GetCurrentMemoryUsage ( ) const
virtual

Determines the amount of memory used by the cached images.

Returns
used size in bytes

Implements CGUIImageCache.

◆ GetFreeListSize()

eC_UInt CGUIImageCacheImpl::GetFreeListSize ( ) const

Determines the amount of memory used by the cached images.

Returns
used size in bytes

◆ GetImageSize()

eC_UInt CGUIImageCacheImpl::GetImageSize ( const ImageResource_t eImageID) const
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

Implements CGUIImageCache.

◆ GetUsedListSize()

eC_UInt CGUIImageCacheImpl::GetUsedListSize ( ) const

Determines the amount of memory used by the cached images in the used list.

Returns
used list size in bytes

◆ LoadImg()

eC_Bool CGUIImageCacheImpl::LoadImg ( const eC_String &  psPath,
const ImageResource_t eImageID 
)
protectedvirtual

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

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 can fail if not enough space for the image can be freed.

Implements CGUIImageCache.

◆ MarkAsFree()

void CGUIImageCacheImpl::MarkAsFree ( const ImageResource_t eImageID)
protectedvirtual

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

Implements CGUIImageCache.

◆ MarkAsUsed()

void CGUIImageCacheImpl::MarkAsUsed ( const ImageResource_t eImageID)
protectedvirtual

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

Parameters
eImageIDthe image's ID

Implements CGUIImageCache.

◆ NotifyImageAccessInternal()

void CGUIImageCacheImpl::NotifyImageAccessInternal ( const ImageResource_t eImageID)
protectedvirtual

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

Parameters
eImageIDthe image that was accessed.

Implements CGUIImageCache.

◆ PreloadImg()

eC_Bool CGUIImageCacheImpl::PreloadImg ( const eC_String &  psPath,
const ImageResource_t eImageID 
)
protectedvirtual

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

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.

Implements CGUIImageCache.

◆ ReadCacheSettingsFromFile()

eC_Bool CGUIImageCacheImpl::ReadCacheSettingsFromFile ( const eC_String &  rkPath)
virtual

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

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

Implements CGUIImageCache.

◆ UnloadSpecificImage()

eC_Bool CGUIImageCacheImpl::UnloadSpecificImage ( const ImageResource_t eImageID)
protectedvirtual

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.

Implements CGUIImageCache.

Friends And Related Function Documentation

◆ CGUIImageCache

friend class CGUIImageCache
friend

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