// SPDX-License-Identifier: BSD-2-Clause // This code is part of the sfizz library and is licensed under a BSD 2-clause // license. You should have receive a LICENSE.md file along with the code. // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz #pragma once #include "SfizzVstUpdates.h" template IPtr IConvertibleToMessage::convertToMessage(Vst::ComponentBase* sender) const { IPtr message = owned(sender->allocateMessage()); message->setMessageID(static_cast(this)->isA()); if (!saveToAttributes(message->getAttributes())) return nullptr; return message; } template IPtr IConvertibleToMessage::convertFromMessage(Vst::IMessage& message) { IPtr object; if (!strcmp(T::getFClassID(), message.getMessageID())) { object = owned(new T); if (!object->loadFromAttributes(message.getAttributes())) object = nullptr; } return object; }