ArcGIS Procedural Runtime  3.2.10650
List of all members | Public Types | Public Member Functions | Static Protected Member Functions
prt::Cache Class Referenceabstract

#include <Cache.h>

Inheritance diagram for prt::Cache:
[legend]

Public Types

enum  PersistentBlobType {
  CACHE_TYPE_IMAGE_METADATA,
  CACHE_TYPE_PIXELDATA
}
 

Public Member Functions

virtual void flushAll ()=0
 
virtual void flushContentType (ContentType type)=0
 
virtual void flushEntry (ContentType type, const wchar_t *key)=0
 
virtual const void * getPersistentBlob (PersistentBlobType type, const wchar_t *key, size_t *size) const =0
 
virtual const void * getTransientBlob (ContentType type, const wchar_t *key) const =0
 
virtual const void * insertAndGetTransientBlob (ContentType type, const wchar_t *key, const void *ptr)=0
 
virtual void insertPersistentBlobAndLock (PersistentBlobType type, const wchar_t *key, const void *data, size_t size)=0
 
virtual void releasePersistentBlob (PersistentBlobType type, const wchar_t *key)=0
 
virtual void releaseTransientBlob (ContentType type, const wchar_t *key)=0
 
virtual bool tryLockPersistentBlobs (ContentType type, const wchar_t *key)=0
 
virtual void unlockPersistentBlob (PersistentBlobType type, const wchar_t *key)=0
 

Static Protected Member Functions

static void deleteTransientBlob (const void *ptr)
 

Detailed Description

The Cache interface is a callback interface which can be implemented by the client.

Procedural Runtime's internal databackend, which resolves URIs to texture/geometry/cgb/material resources, uses this interface to insert and lookup resolved resources.

A cache entry is identified with a unique string (key), typically an URI. There are two major types of cache entries:

Currently, persistent blobs are only implemented for textures. Persistent blobs can be locked and reserved: Locked means the Cache knows the content (and it's guaranteed that a call to getPersistentBlob() succeeds). Reserved means the Cache has the content in memory (and a pointer associated to it).

A number of cache implementations is provided in CacheObject.

See also
CacheObject, prtx::DataBackend

Member Enumeration Documentation

◆ PersistentBlobType

Types of persistent blobs.

Enumerator
CACHE_TYPE_IMAGE_METADATA 
  uint32_t  Version             // 3
  uint32_t  MD5Hash[4]          // md5 hash of associated pixeldata
  uint32_t  Width               // width of associated pixeldata
  uint32_t  Height              // height of associated pixedata
  uint32_t  Format              // GREY8 = 1, GREY16 = 2, RGB8 = 3, RGBA8 = 4, FLOAT32 = 5
  double    Offset[3]           // georef: offset per channel (default: 0)
  double    Scale[3]            // georef: scale per channel  (default: 1)
  double    NoDataValue[3]      // georef: no data value markers per channel (default: MAX_DOUBLE)
  char      Unit[32]            // georef: semicolon separated strings per channel (default: empty)
  double    GeoTransform[6]     // georef: see GDALDataset::GetGeoTransform() function of GDAL (default: [0 1 0 0 0 1])
  char      ProjectionRef[1024] // georef: "Well-known text" string describing the spatial reference system (default: empty)
CACHE_TYPE_PIXELDATA 

The decoded pixeldata, size = width*height*channels.

Member Function Documentation

◆ deleteTransientBlob()

static void prt::Cache::deleteTransientBlob ( const void *  ptr)
staticprotected

Call this to tell Procedural Runtime that the Cache's reference to a transient resource was internally deleted from the cache. This is typically called on flushing an entry or in the Cache's destructor.

Parameters
ptrthe transient blob to release.

◆ flushAll()

virtual void prt::Cache::flushAll ( )
pure virtual

Releases all transient blobs stored in the cache. If a transient blob is not still referenced anywhere else in the Procedural Runtime and references permanent blobs in the cache, the permanent blobs are released from the cache. Is typically called from the client and must be thread-safe.

See also
flushContentType(), flushEntry()

◆ flushContentType()

virtual void prt::Cache::flushContentType ( ContentType  type)
pure virtual

Releases all transient blobs of a certain ContentType. If a transient blob is not still referenced anywhere else in the Procedural Runtime and references permanent blobs in the cache, the permanent blobs are released from the cache. Is typically called from the client and must be thread-safe.

See also
flushAll(), flushEntry()
Parameters
typeType of the resource.

◆ flushEntry()

virtual void prt::Cache::flushEntry ( ContentType  type,
const wchar_t *  key 
)
pure virtual

Releases one specific transient blob from the cache. If a transient blob is not still referenced anywhere else in the Procedural Runtime and references permanent blobs in the cache, the permanent blobs are released from the cache. Is typically called from the client and must be thread-safe.

See also
flushAll(), flushContentType()
Parameters
typeType of the resource.
keyUnique string to identify the resource.

◆ getPersistentBlob()

virtual const void* prt::Cache::getPersistentBlob ( PersistentBlobType  type,
const wchar_t *  key,
size_t *  size 
) const
pure virtual

Gets the pointer to a (locked) persistent blob plus its size. The pointer is guaranteed to stay valid ("reserved") until releasePersistentBlob() is called.

If (type, key) does not refer to a previously locked blob the behaviour is undefined.

Parameters
typeType of the resource.
keyUnique string to identify the resource.
[out]sizePointer to return the blob size in bytes.
Returns
Pointer to the persistent blob.

◆ getTransientBlob()

virtual const void* prt::Cache::getTransientBlob ( ContentType  type,
const wchar_t *  key 
) const
pure virtual

If a pointer is returned: is guaranteed to stay valid until releaseTransientBlob() is called. releaseTransientBlob() must be called when the pointer is not used anymore.

Parameters
typeType of the resource.
keyUnique string to identify the resource.
Returns
The transient resource if known, 0 otherwise.

◆ insertAndGetTransientBlob()

virtual const void* prt::Cache::insertAndGetTransientBlob ( ContentType  type,
const wchar_t *  key,
const void *  ptr 
)
pure virtual

Inserts a transient blob and returns an equivalent transient blob. This can, but doesn't need to, be the inserted blob. The returned blob is guaranteed to stay valid until releaseTransientBlob() is called. releaseTransientBlob() must be called when the returned pointer is not used anymore. If the return value is different than the passed-in ptr, ptr was not inserted into and will not be used by the cache.

Parameters
typeType of the resource.
keyUnique string to identify the resource.
ptrPointer to a transient resource,
Returns
ptr or another, previously inserted pointer to a transient resource with identical permanent blob layout.

◆ insertPersistentBlobAndLock()

virtual void prt::Cache::insertPersistentBlobAndLock ( PersistentBlobType  type,
const wchar_t *  key,
const void *  data,
size_t  size 
)
pure virtual

Inserts a persistent data blob connected to a key and locks it.

Parameters
typeType of the resource.
keyUnique string to identify the resource.
dataPointer to data to insert.
sizeSize of data to insert in bytes.

◆ releasePersistentBlob()

virtual void prt::Cache::releasePersistentBlob ( PersistentBlobType  type,
const wchar_t *  key 
)
pure virtual

Releases the pointer assigned to a persistent blob.

Parameters
typeType of the resource.
keyUnique string to identify the resource.

◆ releaseTransientBlob()

virtual void prt::Cache::releaseTransientBlob ( ContentType  type,
const wchar_t *  key 
)
pure virtual

Releases a previously locked transient blob.

Parameters
typeType of the resource.
keyUnique string to identify the resource.

◆ tryLockPersistentBlobs()

virtual bool prt::Cache::tryLockPersistentBlobs ( ContentType  type,
const wchar_t *  key 
)
pure virtual

Tries to lock all persistent blobs associated with a (transient) key. If the layout + the permanent blobs are known to the cache, they are locked (i.e. prevented from being deleted from permanent storage).

Parameters
typeType of the resource.
keyUnique string to identify the resource.
Returns
true if the permanent blobs are known, else false.

◆ unlockPersistentBlob()

virtual void prt::Cache::unlockPersistentBlob ( PersistentBlobType  type,
const wchar_t *  key 
)
pure virtual

Unlocks a persistent blob. Unlocked blobs can be deleted from persistent storage, reserved pointers stay valid however.

Parameters
typeType of the resource.
keyUnique string to identify the resource.

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