PluginIdentifier.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 /*
16  This is a modified version of a source file from the
17  Rosegarden MIDI and audio sequencer and notation editor.
18  This file copyright 2000-2006 Chris Cannam and QMUL.
19 */
20 
21 #include "PluginIdentifier.h"
22 #include <iostream>
23 #include <QFileInfo>
24 
25 QString
27  QString soName,
28  QString label)
29 {
30  QString identifier = type + ":" + QFileInfo(soName).baseName() + ":" + label;
31  return identifier;
32 }
33 
34 QString
35 PluginIdentifier::canonicalise(QString identifier)
36 {
37  QString type, soName, label;
38  parseIdentifier(identifier, type, soName, label);
39  return createIdentifier(type, soName, label);
40 }
41 
42 void
44  QString &type,
45  QString &soName,
46  QString &label)
47 {
48  type = identifier.section(':', 0, 0);
49  soName = identifier.section(':', 1, 1);
50  label = identifier.section(':', 2);
51 }
52 
53 bool
54 PluginIdentifier::areIdentifiersSimilar(QString id1, QString id2)
55 {
56  QString type1, type2, soName1, soName2, label1, label2;
57 
58  parseIdentifier(id1, type1, soName1, label1);
59  parseIdentifier(id2, type2, soName2, label2);
60 
61  if (type1 != type2 || label1 != label2) return false;
62 
63  bool similar = (soName1.section('/', -1).section('.', 0, 0) ==
64  soName2.section('/', -1).section('.', 0, 0));
65 
66  return similar;
67 }
68 
69 QString
71 
72 QString
73 PluginIdentifier::RESERVED_PROJECT_DIRECTORY_KEY = "__QMUL__:__RESERVED__:ProjectDirectoryKey";
74 
static QString canonicalise(QString identifier)
static QString RESERVED_PROJECT_DIRECTORY_KEY
static void parseIdentifier(QString identifier, QString &type, QString &soName, QString &label)
static QString createIdentifier(QString type, QString soName, QString label)
static bool areIdentifiersSimilar(QString id1, QString id2)
static QString BUILTIN_PLUGIN_SONAME