Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
LV2FeaturesList Class Reference

#include <LV2FeaturesList.h>

Inheritance diagram for LV2FeaturesList:
[legend]
Collaboration diagram for LV2FeaturesList:
[legend]

Public Member Functions

 LV2FeaturesList (const LilvPlugin &plug)
 
 ~LV2FeaturesList () override
 
bool InitializeFeatures ()
 
FeaturePointers GetFeaturePointers () const override
 
bool SuppliesWorkerInterface () const
 
void AddFeature (const char *uri, const void *data)
 
LV2_URID_Map * URIDMapFeature () const
 
LV2_URID URID_Map (const char *uri) const
 
- Public Member Functions inherited from LV2FeaturesListBase
 LV2FeaturesListBase (const LilvPlugin &plug)
 
virtual ~LV2FeaturesListBase ()
 
 LV2FeaturesListBase (const LV2FeaturesListBase &)=delete
 
LV2FeaturesListBaseoperator= (const LV2FeaturesListBase &)=delete
 
virtual FeaturePointers GetFeaturePointers () const =0
 
bool ValidateFeatures (const LilvNode *subject)
 
bool CheckFeatures (const LilvNode *subject, bool required)
 

Static Public Member Functions

static ComponentInterfaceSymbol GetPluginSymbol (const LilvPlugin &plug)
 
static bool SuppliesWorkerInterface (const LilvPlugin &plug)
 

Public Attributes

const bool mOk
 
- Public Attributes inherited from LV2FeaturesListBase
const LilvPlugin & mPlug
 
bool mNoResize { false }
 

Protected Member Functions

const char * URID_Unmap (LV2_URID urid)
 
int LogVPrintf (LV2_URID type, const char *fmt, va_list ap)
 

Static Protected Member Functions

static uint32_t uri_to_id (LV2_URI_Map_Callback_Data callback_data, const char *map, const char *uri)
 
static LV2_URID urid_map (LV2_URID_Map_Handle handle, const char *uri)
 
static const char * urid_unmap (LV2_URID_Unmap_Handle handle, LV2_URID urid)
 
static int log_printf (LV2_Log_Handle handle, LV2_URID type, const char *fmt,...)
 
static int log_vprintf (LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list ap)
 

Protected Attributes

const LV2_URI_Map_Feature mUriMapFeature
 
const LV2_URID_Map mURIDMapFeature { this, LV2FeaturesList::urid_map }
 
const LV2_URID_Unmap mURIDUnmapFeature { this, LV2FeaturesList::urid_unmap }
 
const LV2_Log_Log mLogFeature
 
LV2Symbols::URIDMap mURIDMap
 Per-effect URID map allocates an ID for each URI on first lookup. More...
 
std::vector< LV2_Feature > mFeatures
 
const bool mSuppliesWorkerInterface
 

Additional Inherited Members

- Public Types inherited from LV2FeaturesListBase
using FeaturePointers = std::vector< const LV2_Feature * >
 Get vector of pointers to features, whose .data() can be passed to lv2. More...
 

Detailed Description

Definition at line 78 of file LV2FeaturesList.h.

Constructor & Destructor Documentation

◆ LV2FeaturesList()

LV2FeaturesList::LV2FeaturesList ( const LilvPlugin &  plug)
explicit

Definition at line 71 of file LV2FeaturesList.cpp.

◆ ~LV2FeaturesList()

LV2FeaturesList::~LV2FeaturesList ( )
overridedefault

Member Function Documentation

◆ AddFeature()

void LV2FeaturesList::AddFeature ( const char *  uri,
const void *  data 
)

Definition at line 111 of file LV2FeaturesList.cpp.

112{
113 // This casting to const is innocent
114 // We pass our "virtual function tables" or array of options, which the
115 // library presumably will not change
116 mFeatures.emplace_back(LV2_Feature{ uri, const_cast<void*>(data) });
117}
std::vector< LV2_Feature > mFeatures

References mFeatures.

Referenced by InitializeFeatures().

Here is the caller graph for this function:

◆ GetFeaturePointers()

auto LV2FeaturesList::GetFeaturePointers ( ) const
overridevirtual

Implements LV2FeaturesListBase.

Definition at line 119 of file LV2FeaturesList.cpp.

120{
121 FeaturePointers result;
122 for (auto &feature : mFeatures)
123 result.push_back(&feature);
124 result.push_back(nullptr);
125 return result;
126}
std::vector< const LV2_Feature * > FeaturePointers
Get vector of pointers to features, whose .data() can be passed to lv2.

References mFeatures.

◆ GetPluginSymbol()

ComponentInterfaceSymbol LV2FeaturesList::GetPluginSymbol ( const LilvPlugin &  plug)
static

Definition at line 62 of file LV2FeaturesList.cpp.

63{
64 return LilvStringMove(lilv_plugin_get_name(&plug));
65}
wxString LilvStringMove(LilvNode *node)
Definition: LV2Utils.h:45

References LilvStringMove().

Referenced by LV2Effect::GetSymbol(), and LogVPrintf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeFeatures()

bool LV2FeaturesList::InitializeFeatures ( )
Returns
success

Definition at line 78 of file LV2FeaturesList.cpp.

79{
80 // Construct null-terminated array of "features" describing our capabilities
81 // to lv2, and validate
82 AddFeature(LV2_UI__noUserResize, nullptr);
83 AddFeature(LV2_UI__fixedSize, nullptr);
84 AddFeature(LV2_UI__idleInterface, nullptr);
86 AddFeature(LV2_BUF_SIZE__boundedBlockLength, nullptr);
87 AddFeature(LV2_BUF_SIZE__fixedBlockLength, nullptr);
88 AddFeature(LV2_URI_MAP_URI, &mUriMapFeature);
89 AddFeature(LV2_URID__map, &mURIDMapFeature);
90 AddFeature(LV2_URID__unmap, &mURIDUnmapFeature);
91 AddFeature(LV2_LOG__log, &mLogFeature);
92 // Some plugins specify this as a feature
94 return true;
95}
#define LV2_UI__makeResident
Definition: LV2Symbols.h:30
void AddFeature(const char *uri, const void *data)
const LV2_URID_Map mURIDMapFeature
const LV2_Log_Log mLogFeature
const LV2_URI_Map_Feature mUriMapFeature
const LV2_URID_Unmap mURIDUnmapFeature
#define LV2_EXTERNAL_UI__Widget

References AddFeature(), LV2_EXTERNAL_UI__Widget, LV2_UI__makeResident, mLogFeature, mURIDMapFeature, mURIDUnmapFeature, and mUriMapFeature.

Here is the call graph for this function:

◆ log_printf()

int LV2FeaturesList::log_printf ( LV2_Log_Handle  handle,
LV2_URID  type,
const char *  fmt,
  ... 
)
staticprotected

Definition at line 220 of file LV2FeaturesList.cpp.

222{
223 va_list ap;
224 int len;
225
226 va_start(ap, fmt);
227 len = static_cast<LV2FeaturesList *>(handle)->LogVPrintf(type, fmt, ap);
228 va_end(ap);
229
230 return len;
231}
int LogVPrintf(LV2_URID type, const char *fmt, va_list ap)

References LogVPrintf().

Here is the call graph for this function:

◆ log_vprintf()

int LV2FeaturesList::log_vprintf ( LV2_Log_Handle  handle,
LV2_URID  type,
const char *  fmt,
va_list  ap 
)
staticprotected

Definition at line 234 of file LV2FeaturesList.cpp.

236{
237 return static_cast<LV2FeaturesList *>(handle)->LogVPrintf(type, fmt, ap);
238}

References LogVPrintf().

Here is the call graph for this function:

◆ LogVPrintf()

int LV2FeaturesList::LogVPrintf ( LV2_URID  type,
const char *  fmt,
va_list  ap 
)
protected

Definition at line 240 of file LV2FeaturesList.cpp.

241{
242 using namespace LV2Symbols;
243 long level = wxLOG_Error;
244 if (type == urid_Error)
245 level = wxLOG_Error;
246 else if (type == urid_Note)
247 level = wxLOG_Info;
248 else if (type == urid_Trace)
249 level = wxLOG_Trace;
250 else if (type == urid_Warning)
251 level = wxLOG_Warning;
252 else
253 level = wxLOG_Message;
254 int len = wxCRT_VsnprintfA(nullptr, 0, fmt, ap);
255 auto msg = std::make_unique<char[]>(len + 1);
256 wxCRT_VsnprintfA(msg.get(), len, fmt, ap);
257 wxString text(msg.get());
258 wxLogGeneric(level,
259 wxT("%s: %s"), GetPluginSymbol(mPlug).Msgid().Translation(), text);
260 return len;
261}
const LilvPlugin & mPlug
static ComponentInterfaceSymbol GetPluginSymbol(const LilvPlugin &plug)

References GetPluginSymbol(), and LV2FeaturesListBase::mPlug.

Referenced by log_printf(), and log_vprintf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SuppliesWorkerInterface() [1/2]

bool LV2FeaturesList::SuppliesWorkerInterface ( ) const
inline
Returns
whether our host should reciprocally supply the LV2_Worker_Schedule interface to the plug-in

Definition at line 96 of file LV2FeaturesList.h.

References mSuppliesWorkerInterface.

◆ SuppliesWorkerInterface() [2/2]

bool LV2FeaturesList::SuppliesWorkerInterface ( const LilvPlugin &  plug)
static
Returns
whether our host should reciprocally supply the LV2_Worker_Schedule interface to the plug-in

Definition at line 97 of file LV2FeaturesList.cpp.

98{
99 bool result = false;
100 if (LilvNodesPtr extdata{ lilv_plugin_get_extension_data(&plug) }) {
101 LILV_FOREACH(nodes, i, extdata.get()) {
102 const auto node = lilv_nodes_get(extdata.get(), i);
103 const auto uri = lilv_node_as_string(node);
104 if (strcmp(uri, LV2_WORKER__interface) == 0)
105 result = true;
106 }
107 }
108 return result;
109}
Lilv_ptr< LilvNodes, lilv_nodes_free > LilvNodesPtr

◆ uri_to_id()

uint32_t LV2FeaturesList::uri_to_id ( LV2_URI_Map_Callback_Data  callback_data,
const char *  map,
const char *  uri 
)
staticprotected

Definition at line 172 of file LV2FeaturesList.cpp.

174{
175 return static_cast<LV2FeaturesList *>(callback_data)->URID_Map(uri);
176}
LV2_URID URID_Map(const char *uri) const

References URID_Map().

Here is the call graph for this function:

◆ URID_Map()

LV2_URID LV2FeaturesList::URID_Map ( const char *  uri) const

Definition at line 184 of file LV2FeaturesList.cpp.

185{
186 using namespace LV2Symbols;
187 // Map global URIs to lower indices
188 auto urid = Lookup_URI(gURIDMap, uri, false);
189 if (urid > 0)
190 return urid;
191 // Map local URIs to higher indices
192 urid = Lookup_URI(mURIDMap, uri);
193 if (urid > 0)
194 return urid + gURIDMap.size();
195 return 0;
196}
LV2Symbols::URIDMap mURIDMap
Per-effect URID map allocates an ID for each URI on first lookup.
LV2_URID Lookup_URI(URIDMap &map, const char *uri, bool add)
Definition: LV2Symbols.cpp:76
URIDMap gURIDMap
Declare the global map of positive integers to URIs.
Definition: LV2Symbols.cpp:34

References LV2Symbols::gURIDMap, LV2Symbols::Lookup_URI(), and mURIDMap.

Referenced by uri_to_id(), and urid_map().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urid_map()

LV2_URID LV2FeaturesList::urid_map ( LV2_URID_Map_Handle  handle,
const char *  uri 
)
staticprotected

Definition at line 179 of file LV2FeaturesList.cpp.

180{
181 return static_cast<LV2FeaturesList *>(handle)->URID_Map(uri);
182}

References URID_Map().

Here is the call graph for this function:

◆ URID_Unmap()

const char * LV2FeaturesList::URID_Unmap ( LV2_URID  urid)
protected

Definition at line 204 of file LV2FeaturesList.cpp.

205{
206 using namespace LV2Symbols;
207 if (urid > 0) {
208 // Unmap lower indices to global URIs
209 if (urid <= static_cast<LV2_URID>(gURIDMap.size()))
210 return mURIDMap[urid - 1].get();
211 // Unmap higher indices to local URIs
212 urid -= gURIDMap.size();
213 if (urid <= static_cast<LV2_URID>(mURIDMap.size()))
214 return mURIDMap[urid - 1].get();
215 }
216 return nullptr;
217}

References LV2Symbols::gURIDMap, and mURIDMap.

Referenced by urid_unmap().

Here is the caller graph for this function:

◆ urid_unmap()

const char * LV2FeaturesList::urid_unmap ( LV2_URID_Unmap_Handle  handle,
LV2_URID  urid 
)
staticprotected

Definition at line 199 of file LV2FeaturesList.cpp.

200{
201 return static_cast<LV2FeaturesList *>(handle)->URID_Unmap(urid);
202}
const char * URID_Unmap(LV2_URID urid)

References URID_Unmap().

Here is the call graph for this function:

◆ URIDMapFeature()

LV2_URID_Map * LV2FeaturesList::URIDMapFeature ( ) const
inline

Definition at line 102 of file LV2FeaturesList.h.

103 { return const_cast<LV2_URID_Map*>(&mURIDMapFeature); }

References mURIDMapFeature.

Referenced by LV2Effect::LoadFactoryPreset(), and LV2Instance::LV2Instance().

Here is the caller graph for this function:

Member Data Documentation

◆ mFeatures

std::vector<LV2_Feature> LV2FeaturesList::mFeatures
protected

Definition at line 136 of file LV2FeaturesList.h.

Referenced by AddFeature(), and GetFeaturePointers().

◆ mLogFeature

const LV2_Log_Log LV2FeaturesList::mLogFeature
protected
Initial value:
{
static int log_printf(LV2_Log_Handle handle, LV2_URID type, const char *fmt,...)
static int log_vprintf(LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list ap)

Definition at line 125 of file LV2FeaturesList.h.

Referenced by InitializeFeatures().

◆ mOk

const bool LV2FeaturesList::mOk

Definition at line 141 of file LV2FeaturesList.h.

Referenced by LV2Effect::InitializePlugin().

◆ mSuppliesWorkerInterface

const bool LV2FeaturesList::mSuppliesWorkerInterface
protected

Definition at line 138 of file LV2FeaturesList.h.

Referenced by SuppliesWorkerInterface().

◆ mURIDMap

LV2Symbols::URIDMap LV2FeaturesList::mURIDMap
mutableprotected

Per-effect URID map allocates an ID for each URI on first lookup.

This is some state shared among all instances of an effect, but logically const as a mapping, assuming all reverse lookups of any urid (integer) are done only after at least one lookup of the related uri (string)

Definition at line 134 of file LV2FeaturesList.h.

Referenced by URID_Map(), and URID_Unmap().

◆ mURIDMapFeature

const LV2_URID_Map LV2FeaturesList::mURIDMapFeature { this, LV2FeaturesList::urid_map }
protected

Definition at line 123 of file LV2FeaturesList.h.

Referenced by InitializeFeatures(), and URIDMapFeature().

◆ mURIDUnmapFeature

const LV2_URID_Unmap LV2FeaturesList::mURIDUnmapFeature { this, LV2FeaturesList::urid_unmap }
protected

Definition at line 124 of file LV2FeaturesList.h.

Referenced by InitializeFeatures().

◆ mUriMapFeature

const LV2_URI_Map_Feature LV2FeaturesList::mUriMapFeature
protected
Initial value:
{
static uint32_t uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char *map, const char *uri)

Definition at line 121 of file LV2FeaturesList.h.

Referenced by InitializeFeatures().


The documentation for this class was generated from the following files: