Audacity 3.2.0
LV2FeaturesList.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file LV2FeaturesList.h
6
7 Paul Licameli split from LV2Effect.h
8
9 Audacity(R) is copyright (c) 1999-2013 Audacity Team.
10 License: GPL v2 or later. See License.txt.
11
12*********************************************************************/
13
14#ifndef __AUDACITY_LV2_FEATURES_LIST__
15#define __AUDACITY_LV2_FEATURES_LIST__
16
17#if USE_LV2
18
19#include "lv2/log/log.h"
20#include "lv2/uri-map/uri-map.h"
21
22#include "LV2Symbols.h"
23#include "LV2Preferences.h" // for DEFAULT_BLOCKSIZE
24
25// Define a reasonable default sequence size in bytes
26#define DEFAULT_SEQSIZE 8192
27
29
33public:
34 explicit LV2FeaturesListBase(const LilvPlugin &plug);
36
39
41 using FeaturePointers = std::vector<const LV2_Feature *>;
43
48 bool ValidateFeatures(const LilvNode *subject);
49
55 bool CheckFeatures(const LilvNode *subject, bool required);
56
57 const LilvPlugin &mPlug;
58 bool mNoResize{ false };
59};
60
61// Dummy "keyword" argument prevents overload resolution to the copy ctor
62struct WithBase_t{};
64
67public:
69 const LV2FeaturesListBase &baseFeatures);
71 FeaturePointers GetFeaturePointers() const override;
72 void AddFeature(const char *uri, const void *data);
74protected:
75 std::vector<LV2_Feature> mFeatures;
76};
77
79public:
80 static ComponentInterfaceSymbol GetPluginSymbol(const LilvPlugin &plug);
81
82 explicit LV2FeaturesList(const LilvPlugin &plug);
83 ~LV2FeaturesList() override;
84
86 bool InitializeFeatures();
87
88 FeaturePointers GetFeaturePointers() const override;
89
92 static bool SuppliesWorkerInterface(const LilvPlugin &plug);
93
97
98 void AddFeature(const char *uri, const void *data);
99
100 // lv2 functions require a pointer to non-const in places, but presumably
101 // have no need to mutate the members of this structure
102 LV2_URID_Map *URIDMapFeature() const
103 { return const_cast<LV2_URID_Map*>(&mURIDMapFeature); }
104
105 LV2_URID URID_Map(const char *uri) const;
106
107protected:
108 static uint32_t uri_to_id(LV2_URI_Map_Callback_Data callback_data,
109 const char *map, const char *uri);
110 static LV2_URID urid_map(LV2_URID_Map_Handle handle, const char *uri);
111 static const char *urid_unmap(LV2_URID_Unmap_Handle handle, LV2_URID urid);
112 const char *URID_Unmap(LV2_URID urid);
113
114 static int log_printf(LV2_Log_Handle handle,
115 LV2_URID type, const char *fmt, ...);
116 static int log_vprintf(LV2_Log_Handle handle,
117 LV2_URID type, const char *fmt, va_list ap);
118 int LogVPrintf(LV2_URID type, const char *fmt, va_list ap);
119
120 // These objects contain C-style virtual function tables that we fill in
121 const LV2_URI_Map_Feature mUriMapFeature{
122 this, LV2FeaturesList::uri_to_id }; // Features we support
123 const LV2_URID_Map mURIDMapFeature{ this, LV2FeaturesList::urid_map };
124 const LV2_URID_Unmap mURIDUnmapFeature{ this, LV2FeaturesList::urid_unmap };
125 const LV2_Log_Log mLogFeature{
127
129
135
136 std::vector<LV2_Feature> mFeatures;
137
139
140public:
141 const bool mOk;
142};
143
144#endif
145#endif
constexpr WithBase_t WithBase
Lilv_ptr< LilvNodes, lilv_nodes_free > LilvNodesPtr
Declare URI identifiers used in calls to the lv2 library and a mapping of them to integers.
std::unique_ptr< Type, Lilv_deleter< Type, f > > Lilv_ptr
Generate classes of smart pointers to lv2 resources.
Definition: LV2Utils.h:26
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Extends one (immutable) feature list (whose lifetime contains this one's)
virtual ~ExtendedLV2FeaturesList()
FeaturePointers GetFeaturePointers() const override
void AddFeature(const char *uri, const void *data)
const LV2FeaturesListBase & mBaseFeatures
ExtendedLV2FeaturesList(WithBase_t, const LV2FeaturesListBase &baseFeatures)
std::vector< LV2_Feature > mFeatures
LV2FeaturesListBase(const LilvPlugin &plug)
bool CheckFeatures(const LilvNode *subject, bool required)
bool ValidateFeatures(const LilvNode *subject)
const LilvPlugin & mPlug
std::vector< const LV2_Feature * > FeaturePointers
Get vector of pointers to features, whose .data() can be passed to lv2.
LV2FeaturesListBase & operator=(const LV2FeaturesListBase &)=delete
LV2FeaturesListBase(const LV2FeaturesListBase &)=delete
virtual ~LV2FeaturesListBase()
virtual FeaturePointers GetFeaturePointers() const =0
LV2_URID_Map * URIDMapFeature() const
~LV2FeaturesList() override
void AddFeature(const char *uri, const void *data)
const LV2_URID_Map mURIDMapFeature
LV2Symbols::URIDMap mURIDMap
Per-effect URID map allocates an ID for each URI on first lookup.
LV2_URID URID_Map(const char *uri) const
const LV2_Log_Log mLogFeature
static LV2_URID urid_map(LV2_URID_Map_Handle handle, const char *uri)
LV2FeaturesList(const LilvPlugin &plug)
const char * URID_Unmap(LV2_URID urid)
std::vector< LV2_Feature > mFeatures
const LV2_URI_Map_Feature mUriMapFeature
static uint32_t uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char *map, const char *uri)
const LV2_URID_Unmap mURIDUnmapFeature
const bool mSuppliesWorkerInterface
static int log_printf(LV2_Log_Handle handle, LV2_URID type, const char *fmt,...)
static const char * urid_unmap(LV2_URID_Unmap_Handle handle, LV2_URID urid)
static ComponentInterfaceSymbol GetPluginSymbol(const LilvPlugin &plug)
FeaturePointers GetFeaturePointers() const override
static int log_vprintf(LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list ap)
int LogVPrintf(LV2_URID type, const char *fmt, va_list ap)
bool SuppliesWorkerInterface() const
std::vector< MallocString<> > URIDMap
Definition: LV2Symbols.h:142