From 3eb89e368a2531f9f2328a9787b4d7b1855f8ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 30 Nov 2009 13:22:40 +0000 Subject: [PATCH] Added TypeInterface for TypePlugins git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7685 383ad7c9-94d9-4d36-a494-682f7c89f535 --- BasePlugin/TypeInterface.hh | 68 +++++++++++++++++++++++++++++++++++++ Core/PluginLoader.cc | 24 ++++++++++--- 2 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 BasePlugin/TypeInterface.hh diff --git a/BasePlugin/TypeInterface.hh b/BasePlugin/TypeInterface.hh new file mode 100644 index 00000000..fa34c18f --- /dev/null +++ b/BasePlugin/TypeInterface.hh @@ -0,0 +1,68 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * + * www.openflipper.org * + * * + *---------------------------------------------------------------------------* + * This file is part of OpenFlipper. * + * * + * OpenFlipper is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 3 of * + * the License, or (at your option) any later version with the * + * following exceptions: * + * * + * If other files instantiate templates or use macros * + * or inline functions from this file, or you compile this file and * + * link it with other files to produce an executable, this file does * + * not by itself cause the resulting executable to be covered by the * + * GNU Lesser General Public License. This exception does not however * + * invalidate any other reasons why the executable file might be * + * covered by the GNU Lesser General Public License. * + * * + * OpenFlipper is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU LesserGeneral Public * + * License along with OpenFlipper. If not, * + * see . * + * * +\*===========================================================================*/ + +/*===========================================================================*\ + * * + * $Revision: 7676 $ * + * $Author: moebius $ * + * $Date: 2009-11-30 12:47:58 +0100 (Mo, 30. Nov 2009) $ * + * * +\*===========================================================================*/ + + +#ifndef TYPEINTERFACE_HH +#define TYPEINTERFACE_HH + +#include + + /** \brief Interface class for type definitions + * + * This interface is used to register new types in OpenFlipper. The type plugins are loaded before all other plugins. + * They have only the registerType function which registers the type to the core. The type itself has to be + * defined in the ObjectTypes subdirectory. + */ + +class TypeInterface { + + public: + + /// Destructor + virtual ~TypeInterface() {}; + + virtual bool registerType() = 0; +}; + +Q_DECLARE_INTERFACE(TypeInterface,"OpenFlipper.TypeInterface/1.0") + +#endif // TYPEINTERFACE_HH diff --git a/Core/PluginLoader.cc b/Core/PluginLoader.cc index 272660c4..29367650 100644 --- a/Core/PluginLoader.cc +++ b/Core/PluginLoader.cc @@ -34,8 +34,8 @@ /*===========================================================================*\ * * - * $Revision$ * - * $Author$ * + * $Revision$ * + * $Author$ * * $Date$ * * * \*===========================================================================*/ @@ -84,6 +84,7 @@ #include "OpenFlipper/BasePlugin/RPCInterface.hh" #include "OpenFlipper/BasePlugin/ScriptInterface.hh" #include "OpenFlipper/BasePlugin/SecurityInterface.hh" +#include "OpenFlipper/BasePlugin/TypeInterface.hh" #include "OpenFlipper/INIFile/INIFile.hh" @@ -177,19 +178,27 @@ void Core::loadPlugins() // Sort plugins to load FilePlugins first + QStringList typePlugins; QStringList filePlugins; QStringList textureControl; QStringList otherPlugins; //plugin Liste sortieren for (int i=0; i < pluginlist.size(); i++) - if (pluginlist[i].contains("Plugin-File") ) + if (pluginlist[i].contains("Plugin-Type") ) + typePlugins.push_back(pluginlist[i]); + else if (pluginlist[i].contains("Plugin-File") ) filePlugins.push_back(pluginlist[i]); else if (pluginlist[i].contains("TextureControl")) textureControl.push_back(pluginlist[i]); else otherPlugins.push_back(pluginlist[i]); - pluginlist = filePlugins << textureControl << otherPlugins; + // This is the order in which plugins have to be loaded: + // First load all type Plugins to register the dataTypes to the core + // Than load the file plugins to load objects + // Next is textureControl to control texture based properties + // Than load everything else. + pluginlist = typePlugins << filePlugins << textureControl << otherPlugins; // Remove Whitespace from beginning and end of Plugin Names for ( int i = 0 ; i < dontLoadPlugins_.size() ; ++i ) @@ -522,6 +531,13 @@ void Core::loadPlugin(QString filename, bool silent){ connect(plugin, SIGNAL(setSlotDescription(QString,QString,QStringList,QStringList)), this, SLOT(slotSetSlotDescription(QString,QString,QStringList,QStringList)) ); } + + //Check if the plugin is a typePlugin + TypeInterface* typePlugin = qobject_cast< TypeInterface * >(plugin); + if ( typePlugin ) { + // The only purpose of typePlugins is to register the types before all other Plugins are loaded + typePlugin->registerType(); + } //Check if the plugin supports Logging LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin); -- GitLab