Redesign how interface instantiation works

Transferring some argument pack is much easier than trying to
deserialize into an existing object when you also have to transfer more
information than just that object.
This commit is contained in:
Robbert van der Helm
2020-12-08 17:33:51 +01:00
parent f4a5aa91fb
commit 5eb1fe2de2
7 changed files with 100 additions and 42 deletions
+22 -7
View File
@@ -16,14 +16,19 @@
#include "component.h"
YaComponent::YaComponent(){FUNKNOWN_CTOR}
YaComponent::YaComponent(
Steinberg::IPtr<Steinberg::Vst::IComponent> component) {
FUNKNOWN_CTOR
YaComponent::Arguments::Arguments(
Steinberg::IPtr<Steinberg::Vst::IComponent> component,
size_t instance_id)
: instance_id(instance_id) {
// `IComponent::getControllerClassId`
component->getControllerClassId(edit_controller_cid);
Steinberg::TUID cid;
if (component->getControllerClassId(cid) == Steinberg::kResultOk) {
edit_controller_cid = std::to_array(cid);
}
}
YaComponent::YaComponent(const Arguments&& args) : arguments(std::move(args)) {
FUNKNOWN_CTOR
// Everything else is handled directly through callbacks to minimize the
// potential for errors
@@ -49,3 +54,13 @@ tresult PLUGIN_API YaComponent::queryInterface(Steinberg::FIDString _iid,
*obj = nullptr;
return Steinberg::kNoInterface;
}
tresult PLUGIN_API YaComponent::getControllerClassId(Steinberg::TUID classId) {
if (arguments.edit_controller_cid) {
std::copy(arguments.edit_controller_cid->begin(),
arguments.edit_controller_cid->end(), classId);
return Steinberg::kResultOk;
} else {
return Steinberg::kNotImplemented;
}
}