Last active
August 29, 2015 14:15
-
-
Save falkTX/31b0b6955a60bff9501c to your computer and use it in GitHub Desktop.
lv2 c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------------------------------------------------------------------ | |
// State | |
template<class FeatureStruct> | |
struct Feature | |
{ | |
// pointer to feature struct | |
const FeatureStruct* self; | |
// wherever host supports this feature | |
bool valid; | |
// constructor | |
Feature(const LV2_Feature* const* features, const char* const uri) | |
: self(nullptr), | |
valid(false) | |
{ | |
for (int i = 0; features[i] != nullptr; ++i) | |
{ | |
if (std::strcmp(features[i]->URI, uri) != 0) | |
continue; | |
self = (const FeatureStruct*)features[i]->data; | |
valid = true; | |
break; | |
} | |
} | |
// destructor (needs to be declared for virtual classes) | |
virtual ~Feature() {} | |
}; | |
// ------------------------------------------------------------------------------------------------------ | |
// State | |
struct State_Make_Path : Feature<LV2_State_Make_Path> | |
{ | |
// constructor | |
State_Make_Path(const LV2_Feature* const* features) | |
: Feature<LV2_State_Make_Path>(features, LV2_URID__map) {} | |
// docs for state make_path here | |
char* makePath(const char* path) | |
{ | |
LV2_CHECK_FEATURE_RETURN(stateMakePath, nullptr); | |
return self->path(self->handle, path); | |
} | |
}; | |
// ------------------------------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment