umbrello API Documentation

configurable.cpp

00001 /***************************************************************************
00002     begin                : Mon Jan 13 2003
00003     copyright            : (C) 2003 by Andrew Sutton
00004     email                : ansutton@kent.edu
00005 ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  *   copyright (C) 2004-2007                                               *
00015  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00016  ***************************************************************************/
00017 
00018 // own header
00019 #include "configurable.h"
00020 
00021 // Qt includes
00022 #include <qstringlist.h>
00023 
00024 // KDE includes
00025 #include <kdebug.h>
00026 #include <kconfig.h>
00027 
00028 // local includes
00029 #include "pluginloader.h"
00030 #include "plugin.h"
00031 
00032 using namespace Umbrello;
00033 
00034 
00035 Configurable::Configurable() :
00036         _plugins()
00037 {
00038     _plugins.setAutoDelete(false);
00039 }
00040 
00041 Configurable::~Configurable()
00042 {
00043     unloadPlugins();
00044 }
00045 
00046 bool
00047 Configurable::loadPlugins(KConfig *config,
00048                           const QString &key)
00049 {
00050     bool ret = true;
00051 
00052     QStringList names = config->readListEntry(key);
00053     for(uint i = 0; i != names.size(); i++) {
00054         const QString &name = names[i];
00055 
00056         kdDebug() << "loading plugin " << name << endl;
00057 
00058         // load the plugin
00059         Plugin *plugin = PluginLoader::instance()->loadPlugin(name);
00060 
00061         // keep the plugin
00062         if(plugin) {
00063             _plugins.append(plugin);
00064         }
00065     }
00066 
00067     return ret;
00068 }
00069 
00070 bool
00071 Configurable::unloadPlugins()
00072 {
00073     // just iterate through and dereference all the
00074     // plugins.
00075     for(uint i = 0; i != _plugins.count(); i++) {
00076         Plugin *plugin = _plugins.at(i);
00077         plugin->unload();
00078     }
00079     _plugins.clear();
00080     return true;
00081 }
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:55 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003