Alf::ResourcePool Class Reference

class Alf::ResourcePool

Resoure pool is responsible of controlling commonly used image resources in an application. The resources will be indentified by tags, which are not case sensitive.

   // create image resources
   resourcePool->createLogicalImageResource( "qgn_indi_find_glass" );
   resourcePool->setInitialSize( "qgn_indi_find_glass", XYMetric( 64, 64 ) );
   resourcePool->setAspectRatio( "qgn_indi_find_glass", ResourcePool::aspectRatioPreserved );

   resourcePool->createImageResource(
       "my_face",
       pic0001.jpg );

   // utilize the resource
   imageVisual->setImage( 
       resourcePool->getImageResource( "qgn_indi_find_glass" ) );

   sharpImageVisual->setImage( 
       resourcePool->getImageResource( "my_face" ),
       XYMetric( 256, 256 ) );

   // when the resource in not used anymore, the resource can be deleted
   resourcePool->deleteImageResource( "qgn_indi_find_glass" );
   resourcePool->deleteImageResource( "my_face" );
alfresourcepool.lib
Since
S60 v5.0.1
Public Member Functions
ResourcePool(CAlfTextureManager &, ResourcePool *)
~ResourcePool()
OSN_IMPORT voidcreateFileImageResource(const Utf8 *, const UString &, TAlfTextureFlags)
OSN_IMPORT voidcreateLogicalImageResource(const Utf8 *)
OSN_IMPORT voidcreateThemeImageResource(const Utf8 *, const UString &)
OSN_IMPORT voiddeleteImageResource(const Utf8 *)
OSN_IMPORT TAlfImagegetImageResource(const Utf8 *)
OSN_IMPORT TAlfImagegetImageResource(const Utf8 *, const TAlfXYMetric &)
OSN_IMPORT boolhasImageResource(const Utf8 *)
OSN_IMPORT voidsetAspectRatio(const Utf8 *, AspectRatio)
OSN_IMPORT voidsetInitialSize(const Utf8 *, const TAlfXYMetric &)
Public Member Enumerations
enumAspectRatio { aspectRatioPreserved = 0, aspectRatioPreservedAndUnusedSpaceRemoved = 1, aspectRatioNotPreserved = 2, aspectRatioPreservedSlice = 3 }
Private Attributes
auto_ptr< ResourcePoolImpl >mResourcePoolImpl

Constructor & Destructor Documentation

ResourcePool(CAlfTextureManager &, ResourcePool *)

OSN_IMPORTResourcePool(CAlfTextureManager &aTextureManager,
ResourcePool *aParentPool = NULL
)

Constructs a resource pool

Parameters

CAlfTextureManager & aTextureManagerUsed texture manager.
ResourcePool * aParentPool = NULLChained parent pool (optional) - not supported currently

~ResourcePool()

OSN_IMPORT~ResourcePool()

Destructor

Member Functions Documentation

createFileImageResource(const Utf8 *, const UString &, TAlfTextureFlags)

OSN_IMPORT voidcreateFileImageResource(const Utf8 *aTag,
const UString &aFileName,
TAlfTextureFlagsaFlag = EAlfTextureFlagLoadAnimAsImage
)

Creates an image resource based on a file name. The aFileName can be a full path with the drive letter or it can be relative path to the texture manager defaul path

TextureManager::setImagePath()

Parameters

const Utf8 * aTagResource tag.
const UString & aFileNameFile name.
TAlfTextureFlags aFlag = EAlfTextureFlagLoadAnimAsImageHow to convert the bitmap to texture default all fileimages will be treated as nonanimated

createLogicalImageResource(const Utf8 *)

OSN_IMPORT voidcreateLogicalImageResource(const Utf8 *aTag)

Creates an image resource based on a logical name. The name will be also used as the image resource tag because the logical name is unique in the system.

The logical name should be format "qgn_xxx_xxx" i.e. as stated in the S60 reference icons document.

Note:

The KAknsIIDQgnXxxXxx format works for a while but it will be deprecated -> use the qgn_xxx_xxx format.

Exceptions
invalid_argument

if the tag cannot be matched with any logical name

Parameters

const Utf8 * aTagResource tag. NULL terminated 8-bit string

createThemeImageResource(const Utf8 *, const UString &)

OSN_IMPORT voidcreateThemeImageResource(const Utf8 *aTag,
const UString &aThemeDefinition
)

Creates an image resource based on a theme definition. This definition may concists of several different theme systems.

Currently supported formats: #1 S60 Skin; s60;mifFilePath;mifImageIndex;mifMaskIndex;majorID;minorId

s60: literal "s60", which specifies that the following item definition is based on the S60 Skin system mifFilePath: literal into the multibitmap file (mif/mbm). Can be empty. mifImageIndex:unsigned integer which is the index to the mifFilePath. Only used if mifFilePath is given. mifMaskIndex: unsigned integer which is the mask index to the mifFilePath. Only used if mifFilePath is given. majorID: unsigned integer or hexadecimal starting with 0x of the Major skin ID. Can be empty. minorId: unsigned integer or hexadecimal starting with 0x of the Minor skin ID. Only used if majorID is given.

examples: "s60;;;;268457670;76" // 0x100056c6;0x4c -> KAknsIIDQgnIndiFindGlass "s60;c:\myFile.mif;1;2;;" "s60;myMbmFile.mbm;435;;2342345;234" // If skin ID not found, use mbm file with index 435 (no mask)

Exceptions
invalid_argument

theme definition is not supported.

Parameters

const Utf8 * aTagResource tag.
const UString & aThemeDefinitionDefinition of the theme element.

deleteImageResource(const Utf8 *)

OSN_IMPORT voiddeleteImageResource(const Utf8 *aTag)

Deletes image resource

Parameters

const Utf8 * aTagResource tag.

getImageResource(const Utf8 *)

OSN_IMPORT TAlfImagegetImageResource(const Utf8 *aTag)

Finds a image resource with the given tag. The initial size or system default size is used.

If the given resource is not found, the Image::hasTexture() returns false.

Exceptions
invalid_argument

if the resource is found but cannot be instantiated

Parameters

const Utf8 * aTagResource tag.

getImageResource(const Utf8 *, const TAlfXYMetric &)

OSN_IMPORT TAlfImagegetImageResource(const Utf8 *aTag,
const TAlfXYMetric &aSizeHint
)

Finds a image resouce with the given tag. The size hint may be used to find/re-rasterize the image resource.

If the given resource is not found, the Image::hasTexture() returns false.

Exceptions
invalid_argument

if the resource is found but cannot be instantiated

Parameters

const Utf8 * aTagResource tag.
const TAlfXYMetric & aSizeHintRasteration size hint (only Pixel and RelativeToDisplay supported)

hasImageResource(const Utf8 *)

OSN_IMPORT boolhasImageResource(const Utf8 *aTag)const

Checks if the given resource identifier exists.

Parameters

const Utf8 * aTagResource tag.

setAspectRatio(const Utf8 *, AspectRatio)

OSN_IMPORT voidsetAspectRatio(const Utf8 *aTag,
AspectRatioaAspectRatio
)

Sets aspect ratio mode. This affects to the aspect ratio of the loaded image resource. The new setting will take place when the image resource is loaded.

Note:

Currently only SVG icons are supported. For file image loading, the aspect ratio is preserved.

The blitting of the image resource can still scale and change the aspect ratio of the drawn image.

ImageVisual::setScaleMode

Parameters

const Utf8 * aTagResource tag.
AspectRatio aAspectRatioUsed aspect ratio.

setInitialSize(const Utf8 *, const TAlfXYMetric &)

OSN_IMPORT voidsetInitialSize(const Utf8 *aTag,
const TAlfXYMetric &aInitialSizeHint
)

Sets initial/default loading size for the image resource. The given size is only a hint and the resource pool may used it or ignore it. Without the initial size hint, the image will be rasterized to size determined by the resource pool. The initial size hint can be overridden with the appropriate getImageResource() function.

Parameters

const Utf8 * aTagResource tag.
const TAlfXYMetric & aInitialSizeHintInitial/default size hint (only Pixel and RelativeToDisplay supported)

Member Enumerations Documentation

Enum AspectRatio

Enumerators

aspectRatioPreserved = 0
aspectRatioPreservedAndUnusedSpaceRemoved = 1
aspectRatioNotPreserved = 2
aspectRatioPreservedSlice = 3

Member Data Documentation

auto_ptr< ResourcePoolImpl > mResourcePoolImpl

auto_ptr< ResourcePoolImpl >mResourcePoolImpl[private]