svcore  1.9
PluginIdentifier.cpp
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     
00008     This program is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU General Public License as
00010     published by the Free Software Foundation; either version 2 of the
00011     License, or (at your option) any later version.  See the file
00012     COPYING included with this distribution for more information.
00013 */
00014 
00015 /*
00016    This is a modified version of a source file from the 
00017    Rosegarden MIDI and audio sequencer and notation editor.
00018    This file copyright 2000-2006 Chris Cannam and QMUL.
00019 */
00020 
00021 #include "PluginIdentifier.h"
00022 #include <iostream>
00023 #include <QFileInfo>
00024 
00025 QString
00026 PluginIdentifier::createIdentifier(QString type,
00027                                    QString soName,
00028                                    QString label)
00029 {
00030     QString identifier = type + ":" + QFileInfo(soName).baseName() + ":" + label;
00031     return identifier;
00032 }
00033 
00034 QString
00035 PluginIdentifier::canonicalise(QString identifier)
00036 {
00037     QString type, soName, label;
00038     parseIdentifier(identifier, type, soName, label);
00039     return createIdentifier(type, soName, label);
00040 }
00041 
00042 void
00043 PluginIdentifier::parseIdentifier(QString identifier,
00044                                   QString &type,
00045                                   QString &soName,
00046                                   QString &label)
00047 {
00048     type = identifier.section(':', 0, 0);
00049     soName = identifier.section(':', 1, 1);
00050     label = identifier.section(':', 2);
00051 }
00052 
00053 bool
00054 PluginIdentifier::areIdentifiersSimilar(QString id1, QString id2)
00055 {
00056     QString type1, type2, soName1, soName2, label1, label2;
00057 
00058     parseIdentifier(id1, type1, soName1, label1);
00059     parseIdentifier(id2, type2, soName2, label2);
00060 
00061     if (type1 != type2 || label1 != label2) return false;
00062 
00063     bool similar = (soName1.section('/', -1).section('.', 0, 0) ==
00064                     soName2.section('/', -1).section('.', 0, 0));
00065 
00066     return similar;
00067 }
00068 
00069 QString
00070 PluginIdentifier::BUILTIN_PLUGIN_SONAME = "_builtin";
00071 
00072 QString
00073 PluginIdentifier::RESERVED_PROJECT_DIRECTORY_KEY = "__QMUL__:__RESERVED__:ProjectDirectoryKey";
00074