mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Implement IPluginFactory::getClassInfo
This commit is contained in:
@@ -26,12 +26,24 @@ YaPluginFactory::YaPluginFactory(
|
|||||||
// TODO: We should only copy the interfaces that we support. This should use
|
// TODO: We should only copy the interfaces that we support. This should use
|
||||||
// the same list as that used in `createInstance()`.
|
// the same list as that used in `createInstance()`.
|
||||||
known_iids.insert(factory->iid);
|
known_iids.insert(factory->iid);
|
||||||
|
|
||||||
if (Steinberg::PFactoryInfo info;
|
if (Steinberg::PFactoryInfo info;
|
||||||
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
factory->getFactoryInfo(&info) == Steinberg::kResultOk) {
|
||||||
factory_info = info;
|
factory_info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_classes = factory->countClasses();
|
num_classes = factory->countClasses();
|
||||||
|
|
||||||
|
// TODO: At this point we don't know what this class is and thus we can't
|
||||||
|
// filter unsupported classes, right?
|
||||||
|
class_infos_1.resize(num_classes);
|
||||||
|
for (int i = 0; i < num_classes; i++) {
|
||||||
|
Steinberg::PClassInfo info;
|
||||||
|
if (factory->getClassInfo(i, &info) == Steinberg::kResultOk) {
|
||||||
|
class_infos_1[i] = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto factory2 = Steinberg::FUnknownPtr<Steinberg::IPluginFactory2>(factory);
|
auto factory2 = Steinberg::FUnknownPtr<Steinberg::IPluginFactory2>(factory);
|
||||||
if (!factory2) {
|
if (!factory2) {
|
||||||
return;
|
return;
|
||||||
@@ -93,11 +105,18 @@ int32 PLUGIN_API YaPluginFactory::countClasses() {
|
|||||||
return num_classes;
|
return num_classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API YaPluginFactory::getClassInfo(Steinberg::int32 index,
|
||||||
YaPluginFactory::getClassInfo(Steinberg::int32 /*index*/,
|
Steinberg::PClassInfo* info) {
|
||||||
Steinberg::PClassInfo* /*info*/) {
|
if (index >= static_cast<int32>(class_infos_1.size())) {
|
||||||
// TODO: Implement
|
return Steinberg::kInvalidArgument;
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
if (class_infos_1[index]) {
|
||||||
|
*info = *class_infos_1[index];
|
||||||
|
return Steinberg::kResultOk;
|
||||||
|
} else {
|
||||||
|
return Steinberg::kResultFalse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
|
|||||||
@@ -86,10 +86,22 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
*/
|
*/
|
||||||
std::set<Steinberg::FUID> known_iids;
|
std::set<Steinberg::FUID> known_iids;
|
||||||
|
|
||||||
// For `IPluginFactory::getFactoryInfo`
|
/**
|
||||||
|
* For `IPluginFactory::getFactoryInfo`.
|
||||||
|
*/
|
||||||
std::optional<Steinberg::PFactoryInfo> factory_info;
|
std::optional<Steinberg::PFactoryInfo> factory_info;
|
||||||
// For `IPluginFactory::countClasses`
|
/**
|
||||||
|
* For `IPluginFactory::countClasses`.
|
||||||
|
*/
|
||||||
int num_classes;
|
int num_classes;
|
||||||
|
/**
|
||||||
|
* For `IPluginFactory::getClassInfo`. We need to store all four class info
|
||||||
|
* versions if the plugin can provide them since we don't know which version
|
||||||
|
* of the interface the host will use. Will be `std::nullopt` if the plugin
|
||||||
|
* doesn't return a class info.
|
||||||
|
*/
|
||||||
|
std::vector<std::optional<Steinberg::PClassInfo>> class_infos_1;
|
||||||
|
// TODO: Callback interface for `createInstance()`
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
@@ -97,9 +109,12 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
[](S& s, Steinberg::FUID& iid) {
|
[](S& s, Steinberg::FUID& iid) {
|
||||||
s.ext(iid, bitsery::ext::FUID{});
|
s.ext(iid, bitsery::ext::FUID{});
|
||||||
});
|
});
|
||||||
s.ext(factory_info, bitsery::ext::StdOptional{},
|
s.ext(factory_info, bitsery::ext::StdOptional{});
|
||||||
[](S& s, Steinberg::PFactoryInfo& info) { s.object(info); });
|
|
||||||
s.value4b(num_classes);
|
s.value4b(num_classes);
|
||||||
|
s.container(class_infos_1, 2048,
|
||||||
|
[](S& s, std::optional<Steinberg::PClassInfo>& info) {
|
||||||
|
s.ext(info, bitsery::ext::StdOptional{});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,6 +123,14 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
|||||||
// Serialization functions have to live in the same namespace as the objects
|
// Serialization functions have to live in the same namespace as the objects
|
||||||
// they're serializing
|
// they're serializing
|
||||||
namespace Steinberg {
|
namespace Steinberg {
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s, PClassInfo& class_info) {
|
||||||
|
s.container1b(class_info.cid);
|
||||||
|
s.value4b(class_info.cardinality);
|
||||||
|
s.text1b(class_info.category);
|
||||||
|
s.text1b(class_info.name);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s, PFactoryInfo& factory_info) {
|
void serialize(S& s, PFactoryInfo& factory_info) {
|
||||||
s.text1b(factory_info.vendor);
|
s.text1b(factory_info.vendor);
|
||||||
|
|||||||
Reference in New Issue
Block a user