summaryrefslogtreecommitdiffstats
path: root/src/LV2Features.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/LV2Features.cpp')
-rw-r--r--src/LV2Features.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index ebce8780..73cc9382 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-2024 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -14,10 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/LV2Features.hpp"
+#include <ingen/LV2Features.hpp>
-#include "lv2/core/lv2.h"
+#include <lv2/core/lv2.h>
+#include <algorithm>
#include <cstdlib>
#include <memory>
@@ -30,6 +31,12 @@ LV2Features::Feature::free_feature(LV2_Feature* feature)
free(feature);
}
+std::shared_ptr<LV2_Feature>
+LV2Features::EmptyFeature::feature(World& world, Node* block)
+{
+ return std::make_shared<LV2_Feature>(LV2_Feature{_uri, nullptr});
+}
+
void
LV2Features::add_feature(const std::shared_ptr<Feature>& feature)
{
@@ -37,12 +44,10 @@ LV2Features::add_feature(const std::shared_ptr<Feature>& feature)
}
LV2Features::FeatureArray::FeatureArray(FeatureVector& features)
- : _features(features)
+ : _features(features)
+ , _array{static_cast<LV2_Feature**>(
+ calloc(features.size() + 1, sizeof(LV2_Feature*)))}
{
- _array = static_cast<LV2_Feature**>(
- malloc(sizeof(LV2_Feature*) * (features.size() + 1)));
-
- _array[features.size()] = nullptr;
for (size_t i = 0; i < features.size(); ++i) {
_array[i] = features[i].get();
}
@@ -60,12 +65,9 @@ LV2Features::is_supported(const std::string& uri) const
return true;
}
- for (const auto& f : _features) {
- if (f->uri() == uri) {
- return true;
- }
- }
- return false;
+ return std::any_of(_features.begin(),
+ _features.end(),
+ [&uri](const auto& f) { return f->uri() == uri; });
}
std::shared_ptr<LV2Features::FeatureArray>
@@ -73,7 +75,7 @@ LV2Features::lv2_features(World& world, Node* node) const
{
FeatureArray::FeatureVector vec;
for (const auto& f : _features) {
- std::shared_ptr<LV2_Feature> fptr = f->feature(world, node);
+ const std::shared_ptr<LV2_Feature> fptr = f->feature(world, node);
if (fptr) {
vec.push_back(fptr);
}