1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 See the AUTHORS file for more details. 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as 11 published by the Free Software Foundation; either version 2 of the 12 License, or (at your option) any later version. See the file 13 COPYING included with this distribution for more information. 14 */ 15 16 #ifndef RG_PLUGIN_FACTORY_H 17 #define RG_PLUGIN_FACTORY_H 18 19 #include <QString> 20 #include <vector> 21 22 #include "MappedCommon.h" 23 24 namespace Rosegarden 25 { 26 27 class RunnablePluginInstance; 28 class MappedPluginSlot; 29 30 class PluginFactory 31 { 32 public: 33 static PluginFactory *instance(QString pluginType); 34 static PluginFactory *instanceFor(QString identifier); 35 static void enumerateAllPlugins(MappedObjectPropertyList &); 36 setSampleRate(int sampleRate)37 static void setSampleRate(int sampleRate) { m_sampleRate = sampleRate; } 38 39 /** 40 * Look up the plugin path and find the plugins in it. Called 41 * automatically after construction of a factory. 42 */ 43 virtual void discoverPlugins() = 0; 44 45 /** 46 * Return a reference to a list of all plugin identifiers that can 47 * be created by this factory. 48 */ 49 virtual const std::vector<QString> &getPluginIdentifiers() const = 0; 50 51 /** 52 * Append to the given list descriptions of all the available 53 * plugins and their ports. This is in a standard format, see 54 * the LADSPA implementation for details. 55 */ 56 virtual void enumeratePlugins(MappedObjectPropertyList &list) = 0; 57 58 /** 59 * Populate the given plugin slot with information about its 60 * plugin. This is called from the plugin slot's set method 61 * when it's been asked to set its plugin identifier. This 62 * method should also destroy and recreate the plugin slot's 63 * port child objects. 64 */ 65 virtual void populatePluginSlot(QString identifier, 66 MappedPluginSlot &slot) = 0; 67 68 /** 69 * Instantiate a plugin. 70 */ 71 virtual RunnablePluginInstance *instantiatePlugin(QString identifier, 72 int instrumentId, 73 int position, 74 unsigned int sampleRate, 75 unsigned int blockSize, 76 unsigned int channels) = 0; 77 78 protected: PluginFactory()79 PluginFactory() { } 80 virtual ~PluginFactory(); 81 82 // for call by RunnablePluginInstance dtor 83 virtual void releasePlugin(RunnablePluginInstance *, QString identifier) = 0; 84 friend class RunnablePluginInstance; 85 86 static int m_sampleRate; 87 }; 88 89 90 } 91 92 #endif 93