Commit 3eb89e36 authored by Jan Möbius's avatar Jan Möbius

Added TypeInterface for TypePlugins

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7685 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b1266775
/*===========================================================================*\
* *
* 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 <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 7676 $ *
* $Author: moebius $ *
* $Date: 2009-11-30 12:47:58 +0100 (Mo, 30. Nov 2009) $ *
* *
\*===========================================================================*/
#ifndef TYPEINTERFACE_HH
#define TYPEINTERFACE_HH
#include <OpenFlipper/common/Types.hh>
/** \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
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment