<commit_before>/* dtkPluginManager.cpp --- 
 * 
 * Author: <NAME>
 * Copyright (C) 2008 - <NAME>, Inria.
 * Created: Tue Aug  4 12:20:59 2009 (+0200)
 * Version: $Id$
 * Last-Updated: Sun Jul 18 14:57:08 2010 (+0200)
 *           By: <NAME>
 *     Update #: 126
 */

/* Commentary: 
 * 
 */

/* Change log:
 * 
 */

#include "dtkAbstractData.h"
#include "dtkPluginManager.h"

#include <dtkCore/dtkPlugin.h>
#include <dtkCore/dtkLog.h>

#define DTK_VERBOSE_LOAD false

class dtkPluginManagerPrivate
{
public:
    QString path;

    QHash<QString, QPluginLoader *> loaders;
};

dtkPluginManager *dtkPluginManager::instance(void)
{
    if(!s_instance) {
        s_instance = new dtkPluginManager;

        qRegisterMetaType<dtkAbstractData>("dtkAbstractData");
    }

    return s_instance;
}

void dtkPluginManager::initialize(void)
{
    if(d->path.isNull())
        this->readSettings();

	QString paths = "";
	
	if (!d->path.isEmpty())
		paths = d->path + ":";

	paths = paths + 
#ifdef Q_WS_WIN
	qApp->applicationDirPath() + "\\..\\plugins";
#else
#ifdef Q_WS_MAC
	qApp->applicationDirPath() + "/../PlugIns";
#else
	qApp->applicationDirPath() + "/../plugins";
#endif
#endif
	
    foreach(QString path, paths.split(":", QString::SkipEmptyParts)) {

        QDir dir(path);
        dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
        
        foreach (QFileInfo entry, dir.entryInfoList())
            loadPlugin(entry.absoluteFilePath());
    }
}

void dtkPluginManager::uninitialize(void)
{
    this->writeSettings();

    // foreach(QString path, d->loaders.keys())
    //     unloadPlugin(path);
}

void dtkPluginManager::readSettings(void)
{
    QSettings settings("inria", "dtk");<commit_msg>- uncommented the call to the unload operation when calling uninitialize.<commit_after>/* dtkPluginManager.cpp --- 
 * 
 * Author: <NAME>
 * Copyright (C) 2008 - <NAME>, Inria.
 * Created: Tue Aug  4 12:20:59 2009 (+0200)
 * Version: $Id$
 * Last-Updated: Sun Jul 18 14:57:08 2010 (+0200)
 *           By: <NAME>
 *     Update #: 126
 */

/* Commentary: 
 * 
 */

/* Change log:
 * 
 */

#include "dtkAbstractData.h"
#include "dtkPluginManager.h"

#include <dtkCore/dtkPlugin.h>
#include <dtkCore/dtkLog.h>

#define DTK_VERBOSE_LOAD false

class dtkPluginManagerPrivate
{
public:
    QString path;

    QHash<QString, QPluginLoader *> loaders;
};

dtkPluginManager *dtkPluginManager::instance(void)
{
    if(!s_instance) {
        s_instance = new dtkPluginManager;

        qRegisterMetaType<dtkAbstractData>("dtkAbstractData");
    }

    return s_instance;
}

void dtkPluginManager::initialize(void)
{
    if(d->path.isNull())
        this->readSettings();

	QString paths = "";
	
	if (!d->path.isEmpty())
		paths = d->path + ":";

	paths = paths + 
#ifdef Q_WS_WIN
	qApp->applicationDirPath() + "\\..\\plugins";
#else
#ifdef Q_WS_MAC
	qApp->applicationDirPath() + "/../PlugIns";
#else
	qApp->applicationDirPath() + "/../plugins";
#endif
#endif
	
    foreach(QString path, paths.split(":", QString::SkipEmptyParts)) {

        QDir dir(path);
        dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
        
        foreach (QFileInfo entry, dir.entryInfoList())
            loadPlugin(entry.absoluteFilePath());
    }
}

void dtkPluginManager::uninitialize(void)
{
    this->writeSettings();

    foreach(QString path, d->loaders.keys())
        unloadPlugin(path);
}

void dtkPluginManager::readSettings(void)
{
    QSettings settings("inria", "dtk");
{'fraction_non_alphanumeric': 0.15716753022452504, 'fraction_numerical': 0.021876799078871616, 'mean_word_length': 3.382093316519546, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5980081', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1186, 'n_words': 231}