diff options
Diffstat (limited to 'src/LV2Features.cpp')
-rw-r--r-- | src/LV2Features.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp index cd03cccd..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,11 +14,13 @@ 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> namespace ingen { @@ -29,17 +31,23 @@ 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 SPtr<Feature>& feature) +LV2Features::add_feature(const std::shared_ptr<Feature>& feature) { _features.push_back(feature); } LV2Features::FeatureArray::FeatureArray(FeatureVector& features) - : _features(features) + : _features(features) + , _array{static_cast<LV2_Feature**>( + calloc(features.size() + 1, sizeof(LV2_Feature*)))} { - _array = (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(); } @@ -57,20 +65,17 @@ 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; }); } -SPtr<LV2Features::FeatureArray> +std::shared_ptr<LV2Features::FeatureArray> LV2Features::lv2_features(World& world, Node* node) const { FeatureArray::FeatureVector vec; for (const auto& f : _features) { - SPtr<LV2_Feature> fptr = f->feature(world, node); + const std::shared_ptr<LV2_Feature> fptr = f->feature(world, node); if (fptr) { vec.push_back(fptr); } |