RAMSES Documentation  27.0.130
Information for RAMSES users and developers
Public Member Functions | Public Attributes | List of all members
ramses::DefaultRendererResourceCache Class Reference

The DefaultRendererResourceCache provides a simple example on how the IRendererResourceCache interface can be implemented. It is only intended as an example, as the optimal implementation would be very specific to how RAMSES is being utilized. More...

#include <DefaultRendererResourceCache.h>

Inheritance diagram for ramses::DefaultRendererResourceCache:
[legend]
Collaboration diagram for ramses::DefaultRendererResourceCache:
[legend]

Public Member Functions

 DefaultRendererResourceCache (uint32_t maxCacheSizeInBytes)
 Construct a DefaultRendererResourceCache with a given maximum size. Whenever the size limit is exceeded, items will automatically be unloaded in a FIFO-manner. More...
 
virtual ~DefaultRendererResourceCache () override
 Destructor of DefaultRendererResourceCache. More...
 
bool hasResource (rendererResourceId_t resourceId, uint32_t &size) const override
 Called by RamsesRenderer to ask for a resource with the given id. More...
 
bool getResourceData (rendererResourceId_t resourceId, uint8_t *buffer, uint32_t bufferSize) const override
 Called by RamsesRenderer to get the resource data associated with a given resource id. This method will be called immediately after hasResource(...), if the resource exists in the cache. More...
 
bool shouldResourceBeCached (rendererResourceId_t resourceId, uint32_t resourceDataSize, resourceCacheFlag_t cacheFlag, sceneId_t sceneId) const override
 Called by RamsesRenderer when a resource was not in the cache and is now available from other source. The cache is asked if it wants to store a given resource or not. This avoids the overhead of preparing the resource data in case it is not to be cached. More...
 
void storeResource (rendererResourceId_t resourceId, const uint8_t *resourceData, uint32_t resourceDataSize, resourceCacheFlag_t cacheFlag, sceneId_t sceneId) override
 Called by RamsesRenderer with the final resource for storing. This is called immediately after shouldResourceBeCached(...), if it was requested to be cached. More...
 
void saveToFile (const char *filePath) const
 Save current content of the cache to a file. More...
 
bool loadFromFile (const char *filePath)
 Load all content from a file. It is assumed that the file has been created using saveToFile(...). More...
 
 DefaultRendererResourceCache (const DefaultRendererResourceCache &other)=delete
 Deleted copy constructor. More...
 
DefaultRendererResourceCacheoperator= (const DefaultRendererResourceCache &other)=delete
 Deleted copy assignment. More...
 
- Public Member Functions inherited from ramses::IRendererResourceCache
virtual ~IRendererResourceCache ()=default
 Destructor of IRendererResourceCache. More...
 

Public Attributes

class DefaultRendererResourceCacheImpl & impl
 

Detailed Description

The DefaultRendererResourceCache provides a simple example on how the IRendererResourceCache interface can be implemented. It is only intended as an example, as the optimal implementation would be very specific to how RAMSES is being utilized.

Constructor & Destructor Documentation

◆ DefaultRendererResourceCache() [1/2]

ramses::DefaultRendererResourceCache::DefaultRendererResourceCache ( uint32_t  maxCacheSizeInBytes)
explicit

Construct a DefaultRendererResourceCache with a given maximum size. Whenever the size limit is exceeded, items will automatically be unloaded in a FIFO-manner.

Parameters
maxCacheSizeInBytesMaximum size of cache content in bytes

◆ ~DefaultRendererResourceCache()

virtual ramses::DefaultRendererResourceCache::~DefaultRendererResourceCache ( )
overridevirtual

◆ DefaultRendererResourceCache() [2/2]

ramses::DefaultRendererResourceCache::DefaultRendererResourceCache ( const DefaultRendererResourceCache other)
delete

Deleted copy constructor.

Parameters
otherunused

Member Function Documentation

◆ getResourceData()

bool ramses::DefaultRendererResourceCache::getResourceData ( rendererResourceId_t  resourceId,
uint8_t *  buffer,
uint32_t  bufferSize 
) const
overridevirtual

Called by RamsesRenderer to get the resource data associated with a given resource id. This method will be called immediately after hasResource(...), if the resource exists in the cache.

Parameters
resourceIdId for the resource.
bufferA pre-allocated buffer which the resource data will be copied into.
bufferSizeThe size of the pre-allocated buffer in bytes. It should be at least the size of the requested resource (returned by hasResource(...)).
Returns
true if the resource was copied successfully into the buffer.

Implements ramses::IRendererResourceCache.

◆ hasResource()

bool ramses::DefaultRendererResourceCache::hasResource ( rendererResourceId_t  resourceId,
uint32_t &  size 
) const
overridevirtual

Called by RamsesRenderer to ask for a resource with the given id.

Parameters
resourceIdId for the resource.
[out]sizeThe size of the found resource in bytes. This value is only relevant if the resource exists in the cache.
Returns
true if a resource with the given resource id exists in the cache.

Implements ramses::IRendererResourceCache.

◆ loadFromFile()

bool ramses::DefaultRendererResourceCache::loadFromFile ( const char *  filePath)

Load all content from a file. It is assumed that the file has been created using saveToFile(...).

Parameters
filePathThe file path to load from.
Returns
true if the load was successful.

◆ operator=()

DefaultRendererResourceCache& ramses::DefaultRendererResourceCache::operator= ( const DefaultRendererResourceCache other)
delete

Deleted copy assignment.

Parameters
otherunused
Returns
unused

◆ saveToFile()

void ramses::DefaultRendererResourceCache::saveToFile ( const char *  filePath) const

Save current content of the cache to a file.

Parameters
filePathThe file path to save to.

◆ shouldResourceBeCached()

bool ramses::DefaultRendererResourceCache::shouldResourceBeCached ( rendererResourceId_t  resourceId,
uint32_t  resourceDataSize,
resourceCacheFlag_t  cacheFlag,
sceneId_t  sceneId 
) const
overridevirtual

Called by RamsesRenderer when a resource was not in the cache and is now available from other source. The cache is asked if it wants to store a given resource or not. This avoids the overhead of preparing the resource data in case it is not to be cached.

Parameters
resourceIdId for the resource.
resourceDataSizeThe size of the resource in bytes.
cacheFlagThe cache flag associated with the resource (set on client side).
sceneIdThe id of the first scene which requested the resource. In case of multiple scenes using the same resource, only the first scene id is guaranteed to be reported.
Returns
true if the cache wants to store the resource.

Implements ramses::IRendererResourceCache.

◆ storeResource()

void ramses::DefaultRendererResourceCache::storeResource ( rendererResourceId_t  resourceId,
const uint8_t *  resourceData,
uint32_t  resourceDataSize,
resourceCacheFlag_t  cacheFlag,
sceneId_t  sceneId 
)
overridevirtual

Called by RamsesRenderer with the final resource for storing. This is called immediately after shouldResourceBeCached(...), if it was requested to be cached.

Parameters
resourceIdId for the resource.
resourceDataThe resource data which will be copied into the cache.
resourceDataSizeThe size of the resource in bytes.
cacheFlagThe cache flag associated with the resource (set on client side).
sceneIdThe id of the first scene which requested the resource. In case of multiple scenes using the same resource, only the first scene id is guaranteed to be reported.

Implements ramses::IRendererResourceCache.

Member Data Documentation

◆ impl

class DefaultRendererResourceCacheImpl& ramses::DefaultRendererResourceCache::impl

Stores internal data for implementation specifics of this class.


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