Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/ladspa/ladspaloader.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 *                                                                         *
00003 *   This program is free software; you can redistribute it and/or modify  *
00004 *   it under the terms of the GNU General Public License as published by  *
00005 *   the Free Software Foundation; either version 2 of the License, or     *
00006 *   (at your option) any later version.                                   *
00007 *                                                                         *
00008 ***************************************************************************/
00009 
00010 #include <QtCore>
00011 #include <qapplication.h>
00012 #include "ladspaloader.h"
00013 
00014 LADSPALoader::LADSPALoader()
00015 {
00016     m_PluginCount = 0;
00017     
00018     QStringList plugin_paths;
00019 
00020 
00021     // load each directory
00022     for (QStringList::iterator path = plugin_paths.begin(); path != plugin_paths.end(); path++)
00023     {
00024         QDir dir(* path);
00025 
00026         qDebug() << "Looking for plugins in directory:" << dir.absolutePath();
00027     
00028         // get the list of files in the directory
00029         QFileInfoList files = dir.entryInfoList();
00030 
00031         // load each file in the directory
00032         for (QFileInfoList::iterator file = files.begin(); file != files.end(); file++)
00033         {
00034             qDebug() << "Looking at file:" << (*file).absoluteFilePath();
00035 
00036             if ((*file).isDir())
00037             {
00038                 continue;
00039             }
00040 
00041                         try {
00042                                 LADSPALibrary * library = new LADSPALibrary ((*file).absoluteFilePath());
00043 
00044                                 // add the library to the list of all libraries
00045                                 m_Libraries.append (library);
00046 
00047                                 const LADSPAPluginList * plugins = library->pluginList();
00048 
00049                                 //m_Plugins.resize(m_PluginCount + library->pluginCount());
00050 
00051                                 // add each plugin in the library to the vector of all plugins
00052                                 for (LADSPAPluginList::const_iterator plugin = plugins->begin(); plugin != plugins->end(); plugin++)
00053                                 {
00054                         m_PluginCount++;
00055                                         m_Plugins.push_back(*plugin);
00056                                 }
00057                         } catch (QString& s) {
00058                                 qDebug() << s;
00059                         }
00060         }
00061     }
00062 }
00063 
00064 LADSPALoader::~LADSPALoader()
00065 {
00066     // TODO: unload & free everything
00067 }
00068 
00069 const LADSPAPlugin * LADSPALoader::getByIndex(uint index)
00070 {
00071     if (index < m_PluginCount)
00072     {
00073         return m_Plugins[index];
00074     }
00075 
00076     return NULL;
00077 }
00078 
00079 LADSPAPlugin * LADSPALoader::getByLabel(QString label)
00080 {
00081     // TODO: trie or hash map
00082     for (unsigned int i = 0; i < m_PluginCount; i++)
00083     {
00084       if (QString::compare(m_Plugins[i]->getLabel(), label) == 0)
00085         {
00086             return m_Plugins[i];
00087         }
00088     }
00089 
00090     return NULL;
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines