23 #ifndef LVTK_LV2_STATE_HPP
24 #define LVTK_LV2_STATE_HPP
27 #include <lv2/lv2plug.in/ns/ext/state/state.h>
85 StateRetrieve(LV2_State_Retrieve_Function srfunc, LV2_State_Handle handle)
86 : p_handle(handle), p_srfunc(srfunc) { }
97 uint32_t *type = NULL,
98 uint32_t *flags = NULL)
const
100 return p_srfunc(p_handle, key, size, type, flags);
104 LV2_State_Handle p_handle;
105 LV2_State_Retrieve_Function p_srfunc;
115 StateStore (LV2_State_Store_Function ssfunc, LV2_State_Handle handle)
116 : p_handle(handle), p_ssfunc(ssfunc) { }
130 uint32_t flags = 0)
const
132 return (
StateStatus) p_ssfunc (p_handle, key, value, size, type, flags);
136 LV2_State_Handle p_handle;
137 LV2_State_Store_Function p_ssfunc;
146 template <
bool Required = true>
149 template <
class Derived>
150 struct I : Extension<Required>
153 I() : p_make_path (NULL) { }
166 handle_make_feature(
void* instance,
FeatureData data)
168 Derived* d =
reinterpret_cast<Derived*
>(instance);
171 reinterpret_cast<LV2_State_Make_Path*
> (data);
178 this->m_ok = (p_make_path != NULL);
184 std::clog<<
" [State] Validation "
185 <<(this->m_ok ?
"succeeded" :
"failed")<<
"."
194 extension_data (
const char* uri)
196 if (!std::strcmp (uri, LV2_STATE__interface))
198 static LV2_State_Interface state = { &I<Derived>::_save,
199 &I<Derived>::_restore };
210 save (StateStore &store, uint32_t flags,
217 restore (StateRetrieve &retrieve, uint32_t flags,
226 SAVEME - Map Path is
for the State
interface methods only.
229 abstract_path (
const char* absolute_path);
232 absolute_path(
const char* abstract_path)
234 return p_map_path->absolute_path (p_map_path->handle, abstract_path);
251 assert (p_make_path != NULL);
252 return p_make_path->path (p_make_path->handle, path);
258 LV2_State_Make_Path * p_make_path;
261 static LV2_State_Status _save(LV2_Handle instance,
262 LV2_State_Store_Function store,
263 LV2_State_Handle handle,
265 const LV2_Feature *
const * features)
267 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
272 for (
int i = 0; features[i]; ++i) {
273 feature_set.push_back (features[i]);
276 return (LV2_State_Status)plugin->save(ss, flags, feature_set);
280 static LV2_State_Status
_restore(LV2_Handle instance,
281 LV2_State_Retrieve_Function retrieve,
282 LV2_State_Handle handle,
284 const LV2_Feature *
const * features)
286 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
293 for (
int i = 0; features[i]; ++i) {
294 feature_set.push_back (features[i]);
297 return (LV2_State_Status)plugin->restore(sr, flags, feature_set);