diff options
author | David Robillard <d@drobilla.net> | 2012-01-03 23:21:27 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-01-03 23:21:27 +0000 |
commit | 2f71e8570bcd37ad681bde7d51c433701a0028ab (patch) | |
tree | 177704b6d8f9ea454fb92034e20978ee5bf351ac | |
parent | d1e9dbbba3b4bb91506ad0dab1f7a0e833ac8d36 (diff) | |
download | lilv-2f71e8570bcd37ad681bde7d51c433701a0028ab.tar.gz lilv-2f71e8570bcd37ad681bde7d51c433701a0028ab.tar.bz2 lilv-2f71e8570bcd37ad681bde7d51c433701a0028ab.zip |
Add lilv_state_get_num_properties().
Rearrange state code.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3912 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | lilv/lilv.h | 137 | ||||
-rw-r--r-- | src/state.c | 71 |
2 files changed, 112 insertions, 96 deletions
diff --git a/lilv/lilv.h b/lilv/lilv.h index c664855..8509b2e 100644 --- a/lilv/lilv.h +++ b/lilv/lilv.h @@ -1100,42 +1100,6 @@ lilv_port_get_scale_points(const LilvPlugin* plugin, */ /** - Free @c state. -*/ -LILV_API -void -lilv_state_free(LilvState* state); - -/** - Return true iff @c a is equivalent to @c b. -*/ -LILV_API -bool -lilv_state_equals(const LilvState* a, const LilvState* b); - -/** - Get the URI of the plugin @c state applies to. -*/ -LILV_API -const LilvNode* -lilv_state_get_plugin_uri(const LilvState* state); - -/** - Get the label of @c state. -*/ -LILV_API -const char* -lilv_state_get_label(const LilvState* state); - -/** - Set the label of @c state. -*/ -LILV_API -void -lilv_state_set_label(LilvState* state, - const char* label); - -/** Load a state snapshot from @c world's RDF model. @param subject The subject of the state description (e.g. a preset URI). @return A new LilvState which must be freed with lilv_state_free(). @@ -1167,32 +1131,6 @@ lilv_state_new_from_file(LilvWorld* world, const char* path); /** - Save state to a file. - @param unmap URID unmapper. - @param state State to save. - @param uri URI of state, may be NULL. - @param path Path of file to save state to, may be NULL. - @param manifest_path Path of manifest file to add entry to, may be NULL. - - The format of state on disk is compatible with that defined in the LV2 - preset extension, i.e. this function may be used to save presets which can - be loaded by any host. If @c path is NULL, then the default user preset - bundle (~/.lv2/presets.lv2) is used. In this case, the label of @c state - MUST be set since it is used to generate a filename. - - If @c uri is NULL, the state will be saved without an absolute URI (but - the bundle will still work correctly as a preset bundle). -*/ -LILV_API -int -lilv_state_save(LilvWorld* world, - LV2_URID_Unmap* unmap, - const LilvState* state, - const char* uri, - const char* path, - const char* manifest_path); - -/** Function to get a port value. @return A node the caller (lilv) takes ownership of and must free. */ @@ -1229,6 +1167,49 @@ lilv_state_new_from_instance(const LilvPlugin* plugin, const LV2_Feature *const * features); /** + Free @c state. +*/ +LILV_API +void +lilv_state_free(LilvState* state); + +/** + Return true iff @c a is equivalent to @c b. +*/ +LILV_API +bool +lilv_state_equals(const LilvState* a, const LilvState* b); + +/** + Return the number of properties in @c state. +*/ +LILV_API +unsigned +lilv_state_get_num_properties(const LilvState* state); + +/** + Get the URI of the plugin @c state applies to. +*/ +LILV_API +const LilvNode* +lilv_state_get_plugin_uri(const LilvState* state); + +/** + Get the label of @c state. +*/ +LILV_API +const char* +lilv_state_get_label(const LilvState* state); + +/** + Set the label of @c state. +*/ +LILV_API +void +lilv_state_set_label(LilvState* state, + const char* label); + +/** Function to set a port value. */ typedef void (*LilvSetPortValueFunc)(const char* port_symbol, @@ -1249,8 +1230,10 @@ typedef void (*LilvSetPortValueFunc)(const char* port_symbol, port values itself (using lilv_state_get_port_value) in order to completely restore @c state. - This function is in the "instantiation" threading class, i.e. it MUST NOT be - called simultaneously with any function on the same plugin instance. + If the state has properties, this function is in the "instantiation" + threading class, i.e. it MUST NOT be called simultaneously with any function + on the same plugin instance. If the state has no properties, only port + values are set via @c set_value. See <a href="http://lv2plug.in/ns/ext/state/state.h">state.h</a> from the LV2 State extension for details on the @c flags and @c features parameters. @@ -1265,6 +1248,32 @@ lilv_state_restore(const LilvState* state, const LV2_Feature *const * features); /** + Save state to a file. + @param unmap URID unmapper. + @param state State to save. + @param uri URI of state, may be NULL. + @param path Path of file to save state to, may be NULL. + @param manifest_path Path of manifest file to add entry to, may be NULL. + + The format of state on disk is compatible with that defined in the LV2 + preset extension, i.e. this function may be used to save presets which can + be loaded by any host. If @c path is NULL, then the default user preset + bundle (~/.lv2/presets.lv2) is used. In this case, the label of @c state + MUST be set since it is used to generate a filename. + + If @c uri is NULL, the state will be saved without an absolute URI (but + the bundle will still work correctly as a preset bundle). +*/ +LILV_API +int +lilv_state_save(LilvWorld* world, + LV2_URID_Unmap* unmap, + const LilvState* state, + const char* uri, + const char* path, + const char* manifest_path); + +/** @} @name Scale Point @{ diff --git a/src/state.c b/src/state.c index 7d35f19..c747937 100644 --- a/src/state.c +++ b/src/state.c @@ -81,13 +81,6 @@ value_cmp(const void* a, const void* b) return strcmp(pa->symbol, pb->symbol); } -LILV_API -const LilvNode* -lilv_state_get_plugin_uri(const LilvState* state) -{ - return state->plugin_uri; -} - static PortValue* append_port_value(LilvState* state, const char* port_symbol, @@ -101,25 +94,6 @@ append_port_value(LilvState* state, return pv; } -LILV_API -const char* -lilv_state_get_label(const LilvState* state) -{ - return state->label; -} - -LILV_API -void -lilv_state_set_label(LilvState* state, - const char* label) -{ - if (state->label) { - free(state->label); - } - - state->label = label ? lilv_strdup(label) : NULL; -} - #ifdef HAVE_LV2_STATE static int store_callback(void* handle, @@ -857,6 +831,19 @@ lilv_state_save(LilvWorld* world, } LILV_API +void +lilv_state_free(LilvState* state) +{ + if (state) { + lilv_node_free(state->plugin_uri); + free(state->props); + free(state->values); + free(state->label); + free(state); + } +} + +LILV_API bool lilv_state_equals(const LilvState* a, const LilvState* b) { @@ -895,14 +882,34 @@ lilv_state_equals(const LilvState* a, const LilvState* b) } LILV_API +unsigned +lilv_state_get_num_properties(const LilvState* state) +{ + return state->num_props; +} + +LILV_API +const LilvNode* +lilv_state_get_plugin_uri(const LilvState* state) +{ + return state->plugin_uri; +} + +LILV_API +const char* +lilv_state_get_label(const LilvState* state) +{ + return state->label; +} + +LILV_API void -lilv_state_free(LilvState* state) +lilv_state_set_label(LilvState* state, + const char* label) { - if (state) { - lilv_node_free(state->plugin_uri); - free(state->props); - free(state->values); + if (state->label) { free(state->label); - free(state); } + + state->label = label ? lilv_strdup(label) : NULL; } |