Commit f251a166 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

ENH: Restructuring plugin loading framework. Instead of replying on several

gloabl functions, now we use interfaces. This makes the code a bit cleaner.

Added support for printing debugging information (using PV_PLUGIN_DEBUG
environment variable).

Added support for comparing compiler/paraview versions between the plugin and
the application in which the plugin is being loaded making it possible to give
more user friendly errors/debug information when mismatch happens.
parent b734450f
......@@ -110,11 +110,13 @@ ENDMACRO(ENCODE_FILES_AS_STRINGS)
# consisting of server manager XML and VTK classes
# sets OUTSRCS with the generated code
MACRO(ADD_SERVER_MANAGER_EXTENSION OUTSRCS Name Version XMLFile)
SET(XML_HEADER)
SET (plugin_type_servermanager TRUE)
SET(SM_PLUGIN_INCLUDES)
SET(XML_FILES)
SET(HAVE_XML 0)
SET(XML_GET_INTERFACE)
SET(PUSH_BACK_XML_INTERFACES
"#define PUSH_BACK_XML_INTERFACES(xmls)\\\n"
)
SET(XML_IFACE_PREFIX ${Name})
SET(XML_IFACE_GET_METHOD GetInterfaces)
......@@ -125,17 +127,15 @@ MACRO(ADD_SERVER_MANAGER_EXTENSION OUTSRCS Name Version XMLFile)
GET_FILENAME_COMPONENT(TMP_XML_FILE "${TMPXML}" ABSOLUTE)
GET_FILENAME_COMPONENT(XML_NAME "${TMPXML}" NAME_WE)
SET(XML_FILES ${XML_FILES} ${TMP_XML_FILE})
IF(XML_GET_INTERFACE)
SET(XML_GET_INTERFACE "${XML_GET_INTERFACE},\n ")
ELSE(XML_GET_INTERFACE)
SET(XML_GET_INTERFACE " ")
ENDIF(XML_GET_INTERFACE)
SET(XML_GET_INTERFACE "${XML_GET_INTERFACE} ${XML_IFACE_PREFIX}${XML_NAME}${XML_IFACE_GET_METHOD}()")
SET(PUSH_BACK_XML_INTERFACES
"${PUSH_BACK_XML_INTERFACES} xmls.push_back(${XML_IFACE_PREFIX}${XML_NAME}${XML_IFACE_GET_METHOD}());\\\n")
SET(HAVE_XML 1)
ENDFOREACH(TMPXML)
SET (PUSH_BACK_XML_INTERFACES "${PUSH_BACK_XML_INTERFACES}\n")
IF(HAVE_XML)
SET(XML_HEADER "${CMAKE_CURRENT_BINARY_DIR}/vtkSMXML_${Name}.h")
SET (SM_PLUGIN_INCLUDES "#include \"${XML_HEADER}\"")
ADD_CUSTOM_COMMAND(
OUTPUT "${XML_HEADER}"
......@@ -180,19 +180,12 @@ MACRO(ADD_SERVER_MANAGER_EXTENSION OUTSRCS Name Version XMLFile)
VTK_MAKE_INSTANTIATOR3(vtkSM${Name}Instantiator INST_SRCS "${REALSRCS}"
VTK_EXPORT "${CMAKE_CURRENT_BINARY_DIR}" "")
ENDIF(REALSRCS)
SET(HAVE_SRCS 1)
SET(INITIALIZE_WRAPPING 1)
ELSE(HDRS)
SET(HAVE_SRCS 0)
SET(INITIALIZE_WRAPPING 0)
ENDIF(HDRS)
CONFIGURE_FILE(
"${ParaView_SOURCE_DIR}/Servers/Common/vtkPVPluginInit.cxx.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkPVPluginInit_${Name}.cxx" @ONLY)
SET(${OUTSRCS} ${CS_SRCS} ${INST_SRCS} ${XML_HEADER}
${CMAKE_CURRENT_BINARY_DIR}/vtkPVPluginInit_${Name}.cxx
)
SET(${OUTSRCS} ${CS_SRCS} ${INST_SRCS} ${XML_HEADER})
ENDMACRO(ADD_SERVER_MANAGER_EXTENSION)
......@@ -247,12 +240,7 @@ MACRO(ADD_PYTHON_EXTENSION OUTSRCS NAME VERSION)
ENDFOREACH(PYFILE ${PYSRCFILES})
# Create source code to get Python source from the plugin.
SET(PY_INIT_SRC
"${CMAKE_CURRENT_BINARY_DIR}/vtkPVPythonPluginInit_${NAME}.cxx")
CONFIGURE_FILE(
"${ParaView_SOURCE_DIR}/Utilities/VTKPythonWrapping/vtkPVPythonPluginInit.cxx.in"
"${PY_INIT_SRC}" @ONLY)
SET (plugin_type_python TRUE)
SET(${OUTSRCS} "${PY_INIT_SRC}" "${WRAP_PY_HEADERS}")
ELSE (PARAVIEW_PROCESS_XML_EXECUTABLE)
MESSAGE("kwProcessXML not found. Plugin may not build correctly")
......@@ -790,9 +778,9 @@ ENDMACRO(ADD_PARAVIEW_TREE_LAYOUT_STRATEGY)
# module name and a list of interfaces
# ADD_PARAVIEW_GUI_EXTENSION(OUTSRCS NAME VERSION INTERFACES iface1;iface2;iface3)
MACRO(ADD_PARAVIEW_GUI_EXTENSION OUTSRCS NAME VERSION)
SET (plugin_type_gui TRUE)
SET(INTERFACE_INCLUDES)
SET(INTERFACE_INSTANCES)
SET(PUSH_BACK_PV_INTERFACES "#define PUSH_BACK_PV_INTERFACES(arg)\\\n")
SET(ARG_INTERFACES)
PV_PLUGIN_PARSE_ARGUMENTS(ARG "INTERFACES" "" ${ARGN} )
......@@ -801,27 +789,13 @@ MACRO(ADD_PARAVIEW_GUI_EXTENSION OUTSRCS NAME VERSION)
FOREACH(IFACE ${ARG_INTERFACES})
SET(TMP "#include \"${IFACE}Implementation.h\"")
SET(INTERFACE_INCLUDES "${INTERFACE_INCLUDES}\n${TMP}")
SET(TMP " this->Interfaces.append(new ${IFACE}Implementation(this));")
SET(INTERFACE_INSTANCES "${INTERFACE_INSTANCES}\n${TMP}")
SET(TMP " arg.push_back(new ${IFACE}Implementation(this));\\\n")
SET(PUSH_BACK_PV_INTERFACES "${PUSH_BACK_PV_INTERFACES}${TMP}")
ENDFOREACH(IFACE ${ARG_INTERFACES})
ELSE(ARG_INTERFACES)
SET(INTERFACE_INCLUDES)
SET(INTERFACE_INSTANCES)
ENDIF(ARG_INTERFACES)
SET (PUSH_BACK_PV_INTERFACES "${PUSH_BACK_PV_INTERFACES}\n")
CONFIGURE_FILE(${ParaView_SOURCE_DIR}/Qt/Core/pqPluginImplementation.cxx.in
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}PluginImplementation.cxx @ONLY)
CONFIGURE_FILE(${ParaView_SOURCE_DIR}/Qt/Core/pqPluginImplementation.h.in
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}PluginImplementation.h @ONLY)
GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${QT_INCLUDE_DIRS};${PARAVIEW_GUI_INCLUDE_DIRS}")
SET(PLUGIN_MOC_SRCS)
QT4_WRAP_CPP(PLUGIN_MOC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}PluginImplementation.h)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
SET(${OUTSRCS} ${PLUGIN_MOC_SRCS}
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}PluginImplementation.cxx)
SET(${OUTSRCS} ${PLUGIN_MOC_SRCS})
ENDMACRO(ADD_PARAVIEW_GUI_EXTENSION)
......@@ -985,12 +959,29 @@ MACRO(ADD_PARAVIEW_PLUGIN NAME VERSION)
${ARG_SERVER_SOURCES}
${PY_SRCS})
IF(GUI_SRCS OR SM_SRCS OR ARG_SOURCES)
IF(GUI_SRCS OR SM_SRCS OR ARG_SOURCES OR ARG_PYTHON_MODULES)
IF(PARAVIEW_PLUGINLIST_TXT)
FILE(APPEND ${PARAVIEW_PLUGINLIST_TXT} "${LIBRARY_OUTPUT_PATH}/lib${NAME}.dylib;")
ENDIF(PARAVIEW_PLUGINLIST_TXT)
ADD_LIBRARY(${NAME} SHARED ${GUI_SRCS} ${SM_SRCS} ${ARG_SOURCES})
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/CMake/pqParaViewPlugin.h.in
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}_Plugin.h @ONLY)
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/CMake/pqParaViewPlugin.cxx.in
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}_Plugin.cxx @ONLY)
SET (plugin_sources
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}_Plugin.cxx
${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}_Plugin.h
)
IF (plugin_type_gui)
QT4_WRAP_CPP(tmp ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}_Plugin.h)
SET (plugin_sources ${plugin_sources} ${tmp})
ENDIF (plugin_type_gui)
ADD_LIBRARY(${NAME} SHARED ${GUI_SRCS} ${SM_SRCS} ${ARG_SOURCES}
${plugin_sources})
IF(GUI_SRCS)
TARGET_LINK_LIBRARIES(${NAME} pqComponents)
......@@ -1003,7 +994,7 @@ MACRO(ADD_PARAVIEW_PLUGIN NAME VERSION)
# source are installed.
internal_paraview_install_plugin(${NAME})
ENDIF(GUI_SRCS OR SM_SRCS OR ARG_SOURCES)
ENDIF(GUI_SRCS OR SM_SRCS OR ARG_SOURCES OR ARG_PYTHON_MODULES)
ELSE(PARAVIEW_BUILD_SHARED_LIBS)
MESSAGE("ParaView plugins are disabled. Please build ParaView with shared libraries.")
......
/*=========================================================================
Program: ParaView
Module: pqParaViewPlugin.cxx.in
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "@PLUGIN_NAME@_Plugin.h"
#include "vtkObjectFactory.h"
#ifdef INITIALIZE_WRAPPING
# include "vtkProcessModule.h"
# include "vtkClientServerInterpreter.h"
extern "C" void @PLUGIN_NAME@_Initialize(vtkClientServerInterpreter *arlu);
#endif
@SM_PLUGIN_INCLUDES@
@INTERFACE_INCLUDES@
@PUSH_BACK_XML_INTERFACES@
@PUSH_BACK_PV_INTERFACES@
//-----------------------------------------------------------------------------
#ifdef plugin_type_servermanager
vtkProcessModule::InterpreterInitializationCallback
@PLUGIN_NAME@_Plugin::GetInitializeInterpreterCallback()
{
# ifdef INITIALIZE_WRAPPING
return @PLUGIN_NAME@_Initialize;
# endif
return NULL;
}
//-----------------------------------------------------------------------------
void @PLUGIN_NAME@_Plugin::GetXMLs(vtkstd::vector<vtkstd::string> &xmls)
{
# ifdef PUSH_BACK_XML_INTERFACES
PUSH_BACK_XML_INTERFACES(xmls);
# endif
}
#endif
//-----------------------------------------------------------------------------
#ifdef plugin_type_gui
QObjectList @PLUGIN_NAME@_Plugin::interfaces()
{
QObjectList interfaces;
#ifdef PUSH_BACK_PV_INTERFACES
PUSH_BACK_PV_INTERFACES(interfaces);
#endif
return interfaces;
}
#endif
//-----------------------------------------------------------------------------
#ifdef plugin_type_python
@WRAP_PYTHON_INCLUDES@
void @PLUGIN_NAME@_Plugin::GetPythonSourceList(vtkstd::vector<vtkstd::string>& modules,
vtkstd::vector<vtkstd::string>& sources,
vtkstd::vector<int> &package_flags)
{
const char *moduleNames[] = {
@PY_MODULE_LIST@
};
char *moduleSources[] = {
@PY_LOADER_LIST@
};
const int packageFlags[] = {
@PY_PACKAGE_FLAGS@
};
int num_modules = sizeof(moduleNames)/sizeof(const char *);
for (int cc=0; cc < num_modules; cc++)
{
modules.push_back(moduleNames[cc]);
sources.push_back(moduleSources[cc]);
package_flags.push_back(packageFlags[cc]);
// free allocated memory.
delete moduleSources[cc];
moduleSources[cc] = NULL;
}
}
#endif
//-----------------------------------------------------------------------------
// Mark this as a ParaView-ServerManager plugin.
PV_PLUGIN_EXPORT(@PLUGIN_NAME@, @PLUGIN_NAME@_Plugin)
//-----------------------------------------------------------------------------
#ifdef plugin_type_gui
// Required to mark this as a Qt plugin.
Q_EXPORT_PLUGIN2(@PLUGIN_NAME@, @PLUGIN_NAME@_Plugin)
#endif
/*=========================================================================
Program: ParaView
Module: pqParaViewPlugin.h.in
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
/// This is an auto-generated file. Please do not edit.
/// This file is used to wrap a ParaView plugin.
#cmakedefine plugin_type_python
#cmakedefine plugin_type_servermanager
#cmakedefine plugin_type_gui
/// this is set when the plugin has source headers that are wrapped.
#cmakedefine INITIALIZE_WRAPPING
#include "vtkPVPlugin.h"
#ifdef plugin_type_gui
# include "vtkPVGUIPluginInterface.h"
# include <QObject>
# include <QtPlugin>
#endif
#ifdef plugin_type_servermanager
# include "vtkPVServerManagerPluginInterface.h"
#endif
#ifdef plugin_type_python
# include "vtkPVPythonPluginInterace.h"
#endif
class @PLUGIN_NAME@_Plugin :
#ifdef plugin_type_gui
public QObject,
public vtkPVGUIPluginInterface,
#endif
public vtkPVPlugin
#ifdef plugin_type_servermanager
, public vtkPVServerManagerPluginInterface
#endif
#ifdef plugin_type_python
, public vtkPVPythonPluginInterace
#endif
{
#ifdef plugin_type_gui
Q_OBJECT
#endif
public:
// Description:
// Returns the name for this plugin.
virtual const char* GetPluginName()
{return "@PLUGIN_NAME@"; }
// Description:
// Returns the version for this plugin.
virtual const char* GetPluginVersionString()
{ return "@PLUGIN_VERSION@"; }
// Description:
// Returns true if this plugin is required on the server.
virtual bool GetRequiredOnServer()
{ return @PLUGIN_REQUIRED_ON_SERVER@; }
// Description:
// Returns true if this plugin is required on the client.
virtual bool GetRequiredOnClient()
{ return @PLUGIN_REQUIRED_ON_CLIENT@; }
// Description:
// Returns a ';' separated list of plugin names required by this plugin.
virtual const char* GetRequiredPlugins()
{
return "@PLUGIN_REQUIRED_PLUGINS@";
}
#ifdef plugin_type_servermanager
// Description:
// Obtain the server-manager configuration xmls, if any.
virtual void GetXMLs(vtkstd::vector<vtkstd::string> &xmls);
// Description:
// Returns the callback function to call to initialize the interpretor for the
// new vtk/server-manager classes added by this plugin. Returning NULL is
// perfectly valid.
virtual vtkProcessModule::InterpreterInitializationCallback
GetInitializeInterpreterCallback();
#endif
#ifdef plugin_type_gui
/// Returns the list of ParaView-Interfaces provided by this plugin.
virtual QObjectList interfaces();
#endif
#ifdef plugin_type_python
virtual void GetPythonSourceList(vtkstd::vector<vtkstd::string>& modules,
vtkstd::vector<vtkstd::string>& sources,
vtkstd::vector<int> &package_flags);
#endif
};
......@@ -47,15 +47,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkProcessModule.h"
#include "vtkPVEnvironmentInformation.h"
#include "vtkPVEnvironmentInformationHelper.h"
#include "vtkPVGUIPluginInterface.h"
#include "vtkPVPluginInformation.h"
#include "vtkPVPluginLoader.h"
#include "vtkPVPythonModule.h"
#include "vtkStringArray.h"
#include "vtkSMApplication.h"
#include "vtkSMObject.h"
#include "vtkSMPluginManager.h"
#include "vtkSMProxyManager.h"
#include "vtkSMProxy.h"
#include "vtkSMProxyManager.h"
#include "vtkStringArray.h"
#include "vtkToolkits.h"
#include "vtksys/SystemTools.hxx"
......@@ -67,7 +68,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAutoStartInterface.h"
#include "pqFileDialogModel.h"
#include "pqObjectBuilder.h"
#include "pqPlugin.h"
#include "pqServer.h"
#include "pqServerManagerModel.h"
#include "pqSettings.h"
......@@ -241,19 +241,19 @@ pqPluginManager::LoadStatus pqPluginManager::loadClientExtension(
else
{
QPluginLoader qplugin(lib);
if(qplugin.load())
if (qplugin.load())
{
QObject* pqpluginObject = qplugin.instance();
pqPlugin* pqplugin = qobject_cast<pqPlugin*>(pqpluginObject);
if(pqplugin)
vtkPVGUIPluginInterface* plugin =
dynamic_cast<vtkPVGUIPluginInterface*>(pqpluginObject);
if (plugin)
{
pqpluginObject->setParent(this); // take ownership to clean up later
success = LOADED;
// pluginInfo->SetFileName(lib.toAscii().constData());
pluginInfo->SetFileName(lib.toAscii().constData());
pluginInfo->SetLoaded(1);
this->addExtension(NULL, pluginInfo);
emit this->guiExtensionLoaded();
QObjectList ifaces = pqplugin->interfaces();
QObjectList ifaces = plugin->interfaces();
foreach(QObject* iface, ifaces)
{
this->Internal->Interfaces.append(iface);
......
/*=========================================================================
Program: ParaView
Module: vtkPVGUIPluginInterface.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef __vtkPVGUIPluginInterface_h
#define __vtkPVGUIPluginInterface_h
#include <QObjectList>
/// vtkPVGUIPluginInterface defines the interface required by GUI plugins. This
/// simply provides access to the GUI-component interfaces defined in this
/// plugin.
class vtkPVGUIPluginInterface
{
public:
virtual QObjectList interfaces() = 0;
};
#endif
......@@ -111,10 +111,10 @@ ENDIF (VTK_USE_MPI)
# Abstract and Wrap exclude
SET_SOURCE_FILES_PROPERTIES(
vtkCellIntegrator.cxx
vtkPVCreateProcessModule
vtkPVInformation
vtkProcessModuleConnection
vtkProcessModuleGUIHelper
vtkPVCreateProcessModule
vtkPVInformation
vtkRemoteConnection
vtkUndoElement
ABSTRACT
......@@ -122,12 +122,12 @@ SET_SOURCE_FILES_PROPERTIES(
SET_SOURCE_FILES_PROPERTIES(
vtkCommandOptionsXMLParser.cxx
vtkConnectionIterator.cxx
# vtkStringList.cxx
vtkPVCreateProcessModule
vtkPVOptionsXMLParser.cxx
vtkPVServerOptions.cxx
vtkPVServerSocket.cxx
vtkPVCreateProcessModule
vtkPVTestUtilities.cxx
# vtkStringList.cxx
WRAP_EXCLUDE
)
......
/*=========================================================================
Program: ParaView
Module: vtkPVPlugin.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVPlugin
// .SECTION Description
//
#ifndef __vtkPVPlugin_h
#define __vtkPVPlugin_h
#include "vtkObject.h"
#include "vtkPVConfig.h" // needed for PARAVIEW_VERSION and CMAKE_CXX_COMPILER_ID
#include <vtkstd/vector>
#include <vtkstd/string>
#ifdef _WIN32
// __cdecl gives an unmangled name
# define C_DECL __cdecl
# define C_EXPORT extern "C" __declspec(dllexport)
#else
# define C_DECL
# define C_EXPORT extern "C"
#endif
/// vtkPVPlugin defines the core interface for any ParaView plugin. A plugin
/// implementing merely this interface is pretty much useless.
class VTK_EXPORT vtkPVPlugin
{
public:
// Description:
// Returns the name for this plugin.
virtual const char* GetPluginName() = 0;
// Description:
// Returns the version for this plugin.
virtual const char* GetPluginVersionString() = 0;
// Description:
// Returns true if this plugin is required on the server.
virtual bool GetRequiredOnServer() = 0;
// Description:
// Returns true if this plugin is required on the client.
virtual bool GetRequiredOnClient() = 0;
// Description:
// Returns a ';' separated list of plugin names required by this plugin.
virtual const char* GetRequiredPlugins() = 0;
};
typedef const char* (C_DECL *pv_plugin_query_verification_data_fptr)();
typedef vtkPVPlugin* (C_DECL *pv_plugin_query_instance_fptr)();
/// TODO: add compiler version.
#define __PV_PLUGIN_VERIFICATION_STRING__ "paraviewplugin|" CMAKE_CXX_COMPILER_ID "|" PARAVIEW_VERSION
// vtkPVPluginLoader checks for existence of this function
// to determine if the shared-library is a paraview-server-manager plugin or
// not. The returned value is used to match paraview version/compiler version
// etc.
// TODO: handle static-builds -- i.e. these methods must not exist in static
// builds of ParaView.
#define __PV_PLUGIN_VERIFICATION_DATA(PLUGIN) \
C_EXPORT const char* C_DECL pv_plugin_query_verification_data()\
{ return __PV_PLUGIN_VERIFICATION_STRING__; } \
C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance() \
{ return pv_plugin_instance_##PLUGIN(); }
// vtkPVPluginLoader uses this function to obtain the vtkPVPlugin subclass for
// this plugin.
#define PV_PLUGIN_EXPORT(PLUGIN, PLUGINCLASS) \
C_EXPORT PLUGINCLASS* C_DECL pv_plugin_instance_##PLUGIN() \
{ \
static PLUGINCLASS instance;\
return &instance;\
}\
__PV_PLUGIN_VERIFICATION_DATA(PLUGIN);
// FIXME: This still needs some work to make sure all kinds of plugins work when
// compiled in statically.
//// Call this macro when linking against this plugin directly.
//#define PV_PLUGIN_IMPORT(PLUGIN) \
//{\
// vtkPVPlugin* plugin = pv_plugin_instance_##PLUGIN();\
// vtkPVPluginLoader* loader= vtkPVPluginLoader::New();\
// loader->Load(plugin);\
// loader->Delete();\
//}
#endif
This diff is collapsed.
......@@ -22,9 +22,10 @@
#include "vtkObject.h"
class vtkIntArray;
class vtkPVPlugin;
class vtkPVPluginInformation;
class vtkStringArray;
class vtkIntArray;
class VTK_EXPORT vtkPVPluginLoader : public vtkObject
{
......@@ -37,6 +38,12 @@ public:
// set/get the filename and load the plugin
void SetFileName(const char* file);
const char* GetFileName();
//BTX
// Description:
// Loads the paraview plugin.
void Load(vtkPVPlugin*);
//ETX
// Description:
// Get the Server Manager PluginInformation object
......@@ -98,6 +105,7 @@ protected:
vtkStringArray* PythonModuleNames;
vtkStringArray* PythonModuleSources;
vtkIntArray* PythonPackageFlags;
bool DebugPlugin;
private:
vtkPVPluginLoader(const vtkPVPluginLoader&); // Not implemented.
......
/*=========================================================================
Program: ParaView
Module: vtkPVPythonPluginInterace.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVPythonPluginInterace
// .SECTION Description
// vtkPVPythonPluginInterace defines the interface required by ParaView plugins
// that add python modules to ParaView.
#ifndef __vtkPVPythonPluginInterace_h
#define __vtkPVPythonPluginInterace_h
#include "vtkObject.h"
class VTK_EXPORT vtkPVPythonPluginInterace
{
public:
virtual void GetPythonSourceList(vtkstd::vector<vtkstd::string>& modules,
vtkstd::vector<vtkstd::string>& sources,
vtkstd::vector<int> &package_flags) = 0;
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkPVServerManagerPluginInterface.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVServerManagerPluginInterface
// .SECTION Description
// vtkPVServerManagerPluginInterface defines the interface needed to be
// implemented by a server-manager plugin i.e. a plugin that adds new
// filters/readers/proxies etc. to ParaView.
#ifndef __vtkPVServerManagerPluginInterface_h
#define __vtkPVServerManagerPluginInterface_h
#include "vtkProcessModule.h"
class VTK_EXPORT vtkPVServerManagerPluginInterface
{
public:
// Description:
// Obtain the server-manager configuration xmls, if any.
virtual void GetXMLs(vtkstd::vector<vtkstd::string>& vtkNotUsed(xmls)) = 0;
// Description:
// Returns the callback function to call to initialize the interpretor for the
// new vtk/server-manager classes added by this plugin. Returning NULL is
// perfectly valid.
virtual vtkProcessModule::InterpreterInitializationCallback
GetInitializeInterpreterCallback() = 0;
};
#endif
......@@ -18,6 +18,7 @@
#include "vtkIntArray.h"
#include "vtkObjectFactory.h"
#include "vtkProcessModule.h"
#include "vtkPVConfig.h"
#include "vtkPVEnvironmentInformation.h"
#include "vtkPVPluginLoader.h"
#include "vtkSmartPointer.h"
......@@ -61,7 +62,7 @@ public:
//*****************************************************************************
vtkStandardNewMacro(vtkSMPluginManager);
vtkCxxRevisionMacro(vtkSMPluginManager, "1.5");