RixStorage Class Reference
#include <RixInterfaces.h>
Public Member Functions | |
virtual void * | Get (const char *key)=0 |
Get the data associated with the given key, or NULL if there is none. | |
virtual void | Set (const char *key, void *data, RixCleanupFunc cleanup=NULL)=0 |
virtual void | Clear (const char *key)=0 |
virtual void | Lock ()=0 |
Lock this object. (Unnecessary unless it's used for global storage.) | |
virtual void | Unlock ()=0 |
Unlock this object. | |
Public Member Functions inherited from RixInterface | |
virtual int | GetVersion () const |
Protected Member Functions | |
RixStorage () | |
Constructor is for internal use only. | |
Protected Member Functions inherited from RixInterface | |
RixInterface (int version) | |
Interfaces should not be constructed by users. | |
virtual | ~RixInterface () |
Interfaces should not be deleted by users. | |
Additional Inherited Members | |
Protected Attributes inherited from RixInterface | |
int | m_version |
Version number of this interface. | |
Detailed Description
RixStorage allows plugins to store and share arbitrary data by associating it with an arbitrary key. For example, a shader plugin might share per-thread data as follows:
This code operates as follows:
- Get the per-thread data storage interface from the RslContext.
- Look up the key to see if the data already exists.
- If not, allocate the data and save it in per-thread storage.
- The specified cleanup function is called when the thread exits (typically at the end of a frame).
Per-thread storage is thread-safe, but all other storage must be locked, for example the per-grid storage below is locked:
Per-thread storage can also be used from the global RixContext, as in the example below:
A cleanup function has a prototype like the following:
The RixContext argument allows the cleanup function to obtain interfaces for reporting errors, etc. Note that a cleanup function for per-thread data can access the per-thread RixStorage interface (e.g. for maintaining memory usage statistics). But per-thread storage is not accessible in a cleanup function for per-frame or per-session data.
Member Function Documentation
|
pure virtual |
Clear any data associated with the given key, calling its cleanup function (if any).
|
pure virtual |
Set the data associated with the given key, along with an optional cleanup function. Any previously associated data is discarded (calling its cleanup function, if any). The key is copied.
The documentation for this class was generated from the following file: