Plug-In Storage


Chunks or Parameters?

There are two ways to store the current state of a Plug-In: either trough the parameter interfaces or as an opaque memory block (chunk). The host first queries the Plug-In for IPersistentChunk interface. If it is not implemented, the values of all parameters are saved.

Chunk storage allows to save additional data (besides the parameter state) which is specific to the Plug-In. Please note, that if you decide to use chunk storage, you have to take care of saving and loading parameter states on your own!


IPersistentChunk

Inheritance: FUnknown <- IPersistentChunk
Include File:  iplugstorage.h

IPersistentChunk is used to store the current Plug-In state to a memory block which the host application then can transfer to a persistent storage. This is used for storing Plug-In presets.

Methods:


IPersistentChunk::getUID

tresult PLUGIN_API getUID (char* uid)

Copies a 16 Byte Globally Unique Identifier to uid. The UID is used to associate a stored memory block with the Plug-In.


IPersistentChunk::setChunk

tresult PLUGIN_API setChunk (char* chunk, long size)

Called by the host application to restore the Plug-In state from a preset.


IPersistentChunk::getChunk

tresult PLUGIN_API getChunk (char* chunk, long* size)

Called by the host application to create a preset from the current Plug-In state.

Remarks:

This method is called twice! At first the chunk parameter is NULL, on return size has to be set to the maximum size required for storing the Plug-In state. The host then can allocate the required memory amount and calls IPersistentChunk::getChunk again to actually save the state to chunk (see following host example).

IPersistentChunk* plug; // a valid Plug-In reference

long size;
if(plug->getChunk (0, &size) == kResultOk && size > 0)
{
	char* chunk = new char[size];
	plug->getChunk (chunk, &size);
	...
	delete [] chunk;
}



Last Modified: