annotate transform/TransformDescription.h @ 1879:652c5360e682

Ensure transforms are populated before instantiateDefaultPluginFor runs - otherwise if we have prior knowledge of a transform id, we can find ourselves trying to instantiate it before the plugin factory has heard of it and e.g. knows which server to use
author Chris Cannam
date Thu, 25 Jun 2020 12:20:06 +0100
parents 6f626cfdba51
children
rev   line source
Chris@329 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@329 2
Chris@329 3 /*
Chris@329 4 Sonic Visualiser
Chris@329 5 An audio file viewer and annotation editor.
Chris@329 6 Centre for Digital Music, Queen Mary, University of London.
Chris@329 7 This file copyright 2006-2007 Chris Cannam and QMUL.
Chris@329 8
Chris@329 9 This program is free software; you can redistribute it and/or
Chris@329 10 modify it under the terms of the GNU General Public License as
Chris@329 11 published by the Free Software Foundation; either version 2 of the
Chris@329 12 License, or (at your option) any later version. See the file
Chris@329 13 COPYING included with this distribution for more information.
Chris@329 14 */
Chris@329 15
Chris@1546 16 #ifndef SV_TRANSFORM_DESCRIPTION_H
Chris@1546 17 #define SV_TRANSFORM_DESCRIPTION_H
Chris@329 18
Chris@329 19 #include "Transform.h"
Chris@329 20
Chris@1845 21 #include "plugin/Provider.h"
Chris@1845 22
Chris@329 23 #include <QString>
Chris@329 24
Chris@329 25 #include <vector>
Chris@329 26
Chris@329 27 /**
Chris@329 28 * Metadata associated with a transform.
Chris@329 29 *
Chris@329 30 * The transform ID is the same as that used in the Transform class.
Chris@329 31 * It is intended to be computer-referenceable and unique within the
Chris@329 32 * application.
Chris@329 33 *
Chris@329 34 * The name is intended to be human readable. In principle it doesn't
Chris@329 35 * have to be unique, but the factory that creates these objects
Chris@329 36 * should add suffixes to ensure that it is, all the same (just to
Chris@329 37 * avoid user confusion).
Chris@329 38 *
Chris@329 39 * The friendly name is a shorter version of the name.
Chris@329 40 *
Chris@329 41 * The type is also intended to be user-readable, for use in menus.
Chris@350 42 *
Chris@350 43 * To obtain these objects, use
Chris@350 44 * TransformFactory::getAllTransformDescriptions and
Chris@350 45 * TransformFactory::getTransformDescription.
Chris@329 46 */
Chris@329 47
Chris@329 48 struct TransformDescription
Chris@329 49 {
Chris@487 50 enum Type {
Chris@487 51 Analysis, // e.g. vamp plugin output
Chris@487 52 Effects, // e.g. ladspa plugin with audio in and out
Chris@487 53 EffectsData, // e.g. control output of ladspa plugin
Chris@487 54 Generator, // e.g. audio out of ladspa plugin with no audio in
Chris@487 55 UnknownType
Chris@487 56 };
Chris@487 57
Chris@976 58 TransformDescription() :
Chris@976 59 type(UnknownType), configurable(false) { }
Chris@487 60 TransformDescription(Type _type, QString _category,
Chris@329 61 TransformId _identifier, QString _name,
Chris@329 62 QString _friendlyName, QString _description,
Chris@443 63 QString _longDescription,
Chris@329 64 QString _maker, QString _units, bool _configurable) :
Chris@329 65 type(_type), category(_category),
Chris@329 66 identifier(_identifier), name(_name),
Chris@329 67 friendlyName(_friendlyName), description(_description),
Chris@443 68 longDescription(_longDescription),
Chris@329 69 maker(_maker), units(_units), configurable(_configurable) { }
Chris@329 70
Chris@487 71 Type type;
Chris@329 72 QString category; // e.g. time > onsets
Chris@329 73 TransformId identifier; // e.g. vamp:vamp-aubio:aubioonset
Chris@329 74 QString name; // plugin's name if 1 output, else "name: output"
Chris@329 75 QString friendlyName; // short text for layer name
Chris@329 76 QString description; // sentence describing transform
Chris@443 77 QString longDescription; // description "using" plugin name "by" maker
Chris@329 78 QString maker;
Chris@1845 79 Provider provider;
Chris@329 80 QString units;
Chris@329 81 bool configurable;
Chris@1546 82
Chris@1546 83 // User-visible strings (name, maker etc) should be sorted in a
Chris@1546 84 // locale-aware way
Chris@1546 85 static bool compareUserStrings(QString s1, QString s2) {
Chris@1546 86 return QString::localeAwareCompare(s1, s2) < 0;
Chris@1546 87 };
Chris@329 88
Chris@329 89 bool operator<(const TransformDescription &od) const {
Chris@1546 90 if (name == od.name) {
Chris@1546 91 return identifier < od.identifier;
Chris@1546 92 } else {
Chris@1546 93 return compareUserStrings(name, od.name);
Chris@1546 94 }
Chris@329 95 };
Chris@329 96 };
Chris@329 97
Chris@329 98 typedef std::vector<TransformDescription> TransformList;
Chris@329 99
Chris@329 100 #endif