LV2  1.0.13
Data Structures | Macros | Typedefs | Enumerations
state.h File Reference

C API for the LV2 State extension http://lv2plug.in/ns/ext/state. More...

Data Structures

struct  LV2_State_Interface
 LV2 Plugin State Interface. More...
 
struct  LV2_State_Map_Path
 Feature data for state:mapPath (LV2_STATE__mapPath). More...
 
struct  LV2_State_Make_Path
 Feature data for state:makePath (LV2_STATE__makePath). More...
 

Macros

#define LV2_STATE_URI   "http://lv2plug.in/ns/ext/state"
 
#define LV2_STATE_PREFIX   LV2_STATE_URI "#"
 
#define LV2_STATE__State   LV2_STATE_PREFIX "State"
 
#define LV2_STATE__interface   LV2_STATE_PREFIX "interface"
 
#define LV2_STATE__loadDefaultState   LV2_STATE_PREFIX "loadDefaultState"
 
#define LV2_STATE__makePath   LV2_STATE_PREFIX "makePath"
 
#define LV2_STATE__mapPath   LV2_STATE_PREFIX "mapPath"
 
#define LV2_STATE__state   LV2_STATE_PREFIX "state"
 

Typedefs

typedef void * LV2_State_Handle
 
typedef void * LV2_State_Map_Path_Handle
 
typedef void * LV2_State_Make_Path_Handle
 
typedef LV2_State_Status(* LV2_State_Store_Function )(LV2_State_Handle handle, uint32_t key, const void *value, size_t size, uint32_t type, uint32_t flags)
 A host-provided function to store a property. More...
 
typedef const void *(* LV2_State_Retrieve_Function )(LV2_State_Handle handle, uint32_t key, size_t *size, uint32_t *type, uint32_t *flags)
 A host-provided function to retrieve a property. More...
 

Enumerations

enum  LV2_State_Flags { LV2_STATE_IS_POD = 1, LV2_STATE_IS_PORTABLE = 1 << 1, LV2_STATE_IS_NATIVE = 1 << 2 }
 Flags describing value characteristics. More...
 
enum  LV2_State_Status {
  LV2_STATE_SUCCESS = 0, LV2_STATE_ERR_UNKNOWN = 1, LV2_STATE_ERR_BAD_TYPE = 2, LV2_STATE_ERR_BAD_FLAGS = 3,
  LV2_STATE_ERR_NO_FEATURE = 4, LV2_STATE_ERR_NO_PROPERTY = 5
}
 A status code for state functions. More...
 

Detailed Description

C API for the LV2 State extension http://lv2plug.in/ns/ext/state.

Macro Definition Documentation

#define LV2_STATE_URI   "http://lv2plug.in/ns/ext/state"
#define LV2_STATE_PREFIX   LV2_STATE_URI "#"
#define LV2_STATE__State   LV2_STATE_PREFIX "State"
#define LV2_STATE__interface   LV2_STATE_PREFIX "interface"
#define LV2_STATE__loadDefaultState   LV2_STATE_PREFIX "loadDefaultState"
#define LV2_STATE__makePath   LV2_STATE_PREFIX "makePath"
#define LV2_STATE__mapPath   LV2_STATE_PREFIX "mapPath"
#define LV2_STATE__state   LV2_STATE_PREFIX "state"

Typedef Documentation

typedef void* LV2_State_Handle
typedef LV2_State_Status(* LV2_State_Store_Function)(LV2_State_Handle handle, uint32_t key, const void *value, size_t size, uint32_t type, uint32_t flags)

A host-provided function to store a property.

Parameters
handleMust be the handle passed to LV2_State_Interface.save().
keyThe key to store value under (URID).
valuePointer to the value to be stored.
sizeThe size of value in bytes.
typeThe type of value (URID).
flagsLV2_State_Flags for value.
Returns
0 on success, otherwise a non-zero error code.

The host passes a callback of this type to LV2_State_Interface.save(). This callback is called repeatedly by the plugin to store all the properties that describe its current state.

DO NOT INVENT NONSENSE URI SCHEMES FOR THE KEY. Best is to use keys from existing vocabularies. If nothing appropriate is available, use http URIs that point to somewhere you can host documents so documentation can be made resolvable (e.g. a child of the plugin or project URI). If this is not possible, invent a URN scheme, e.g. urn:myproj:whatever. The plugin MUST NOT pass an invalid URI key.

The host MAY fail to store a property for whatever reason, but SHOULD store any property that is LV2_STATE_IS_POD and LV2_STATE_IS_PORTABLE. Implementations SHOULD use the types from the LV2 Atom extension (http://lv2plug.in/ns/ext/atom) wherever possible. The plugin SHOULD attempt to fall-back and avoid the error if possible.

Note that size MUST be > 0, and value MUST point to a valid region of memory size bytes long (this is required to make restore unambiguous).

The plugin MUST NOT attempt to use this function outside of the LV2_State_Interface.restore() context.

typedef const void*(* LV2_State_Retrieve_Function)(LV2_State_Handle handle, uint32_t key, size_t *size, uint32_t *type, uint32_t *flags)

A host-provided function to retrieve a property.

Parameters
handleMust be the handle passed to LV2_State_Interface.restore().
keyThe key of the property to retrieve (URID).
size(Output) If non-NULL, set to the size of the restored value.
type(Output) If non-NULL, set to the type of the restored value.
flags(Output) If non-NULL, set to the flags for the restored value.
Returns
A pointer to the restored value (object), or NULL if no value has been stored under key.

A callback of this type is passed by the host to LV2_State_Interface.restore(). This callback is called repeatedly by the plugin to retrieve any properties it requires to restore its state.

The returned value MUST remain valid until LV2_State_Interface.restore() returns. The plugin MUST NOT attempt to use this function, or any value returned from it, outside of the LV2_State_Interface.restore() context.

Enumeration Type Documentation

Flags describing value characteristics.

These flags are used along with the value's type URI to determine how to (de-)serialise the value data, or whether it is even possible to do so.

Enumerator
LV2_STATE_IS_POD 

Plain Old Data.

Values with this flag contain no pointers or references to other areas of memory. It is safe to copy POD values with a simple memcpy and store them for the duration of the process. A POD value is not necessarily safe to trasmit between processes or machines (e.g. filenames are POD), see LV2_STATE_IS_PORTABLE for details.

Implementations MUST NOT attempt to copy or serialise a non-POD value if they do not understand its type (and thus know how to correctly do so).

LV2_STATE_IS_PORTABLE 

Portable (architecture independent) data.

Values with this flag are in a format that is usable on any architecture. A portable value saved on one machine can be restored on another machine regardless of architecture. The format of portable values MUST NOT depend on architecture-specific properties like endianness or alignment. Portable values MUST NOT contain filenames.

LV2_STATE_IS_NATIVE 

Native data.

This flag is used by the host to indicate that the saved data is only going to be used locally in the currently running process (e.g. for instance duplication or snapshots), so the plugin should use the most efficient representation possible and not worry about serialisation and portability.

A status code for state functions.

Enumerator
LV2_STATE_SUCCESS 

Completed successfully.

LV2_STATE_ERR_UNKNOWN 

Unknown error.

LV2_STATE_ERR_BAD_TYPE 

Failed due to unsupported type.

LV2_STATE_ERR_BAD_FLAGS 

Failed due to unsupported flags.

LV2_STATE_ERR_NO_FEATURE 

Failed due to missing features.

LV2_STATE_ERR_NO_PROPERTY 

Failed due to missing property.