20 #ifndef LVTK_STATE_HPP 21 #define LVTK_STATE_HPP 24 #include <lv2/lv2plug.in/ns/ext/state/state.h> 77 StateRetrieve(LV2_State_Retrieve_Function srfunc, LV2_State_Handle handle)
78 : p_handle(handle), p_srfunc(srfunc) { }
89 uint32_t *type = NULL,
90 uint32_t *flags = NULL)
const 92 return p_srfunc(p_handle, key, size, type, flags);
96 LV2_State_Handle p_handle;
97 LV2_State_Retrieve_Function p_srfunc;
105 StateStore (LV2_State_Store_Function ssfunc, LV2_State_Handle handle)
106 : p_handle(handle), p_ssfunc(ssfunc) { }
120 uint32_t flags = 0)
const 122 return (StateStatus) p_ssfunc (p_handle, key, value, size, type, flags);
126 LV2_State_Handle p_handle;
127 LV2_State_Store_Function p_ssfunc;
136 template <
bool Required = true>
139 template <
class Derived>
140 struct I : Extension<Required>
143 I() : p_make_path (NULL) { }
156 handle_make_feature(
void* instance,
FeatureData data)
158 Derived* d =
reinterpret_cast<Derived*
>(instance);
161 reinterpret_cast<LV2_State_Make_Path*
> (data);
168 this->m_ok = (p_make_path != NULL);
174 std::clog<<
" [State] Validation " 175 <<(this->m_ok ?
"succeeded" :
"failed")<<
"." 184 extension_data (
const char* uri)
186 if (!std::strcmp (uri, LV2_STATE__interface))
213 SAVEME - Map Path is
for the
State interface methods only.
216 abstract_path (
const char* absolute_path);
219 absolute_path(
const char* abstract_path)
221 return p_map_path->absolute_path (p_map_path->handle, abstract_path);
238 assert (p_make_path != NULL);
239 return p_make_path->path (p_make_path->handle, path);
245 LV2_State_Make_Path * p_make_path;
248 static LV2_State_Status _save(LV2_Handle instance,
249 LV2_State_Store_Function store,
250 LV2_State_Handle handle,
252 const LV2_Feature *
const * features)
254 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
259 for (
int i = 0; features[i]; ++i) {
260 feature_set.push_back (features[i]);
263 return (LV2_State_Status)plugin->save(ss, flags, feature_set);
267 static LV2_State_Status
_restore(LV2_Handle instance,
268 LV2_State_Retrieve_Function retrieve,
269 LV2_State_Handle handle,
271 const LV2_Feature *
const * features)
273 Derived* plugin =
reinterpret_cast<Derived*
>(instance);
280 for (
int i = 0; features[i]; ++i) {
281 feature_set.push_back (features[i]);
284 return (LV2_State_Status)plugin->restore(sr, flags, feature_set);
static void map_feature_handlers(FeatureHandlerMap &hmap)
Definition: state.hpp:147
void * FeatureData
Definition: feature.hpp:47
Definition: feature.hpp:34
char * path(const char *path)
Definition: state.hpp:236
Definition: state.hpp:137
static LV2_State_Status _restore(LV2_Handle instance, LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t flags, const LV2_Feature *const *features)
Definition: state.hpp:267
vector< const Feature * > FeatureVec
Definition: feature.hpp:44
StateFlags
Definition: state.hpp:28
Definition: state.hpp:104
StateStatus
Definition: state.hpp:64
map< string, FeatureHandler > FeatureHandlerMap
Definition: feature.hpp:57
const void * operator()(uint32_t key, size_t *size=NULL, uint32_t *type=NULL, uint32_t *flags=NULL) const
Definition: state.hpp:88
Definition: state.hpp:140