From 09594cf8a322261d13aae97433900cc5530ddc7a Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit Date: Mon, 2 Jul 2012 12:56:41 -0400 Subject: [PATCH] Adding support to initialize xmls and CS streams. --- CMakeLists.txt | 1 + .../SMApplication/CMakeLists.txt | 52 +++++++++++++-- .../SMApplication}/Resources/3d_widgets.xml | 0 .../SMApplication}/Resources/filters.xml | 0 .../Resources/internal_writers.xml | 0 .../SMApplication}/Resources/pythonfilter.xml | 0 .../SMApplication}/Resources/readers.xml | 0 .../SMApplication}/Resources/rendering.xml | 0 .../SMApplication}/Resources/sources.xml | 0 .../SMApplication}/Resources/utilities.xml | 0 .../Resources/views_and_representations.xml | 0 .../SMApplication}/Resources/writers.xml | 0 .../ServerManager/SMApplication/module.cmake | 2 + .../SMApplication/vtkInitializationHelper.cxx | 38 +---------- .../SMApplication/vtkPVInitializer.h.in | 63 +++++++++++++++++++ Utilities/ProcessXML/CMakeLists.txt | 37 +++++++++++ .../ProcessXML}/ProcessXML.cxx | 0 Utilities/ProcessXML/module.cmake | 5 ++ 18 files changed, 157 insertions(+), 41 deletions(-) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/3d_widgets.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/filters.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/internal_writers.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/pythonfilter.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/readers.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/rendering.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/sources.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/utilities.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/views_and_representations.xml (100%) rename ParaViewCore/{ServerImplementation => ServerManager/SMApplication}/Resources/writers.xml (100%) create mode 100644 Utilities/ProcessXML/CMakeLists.txt rename {Common/KWCommon => Utilities/ProcessXML}/ProcessXML.cxx (100%) create mode 100644 Utilities/ProcessXML/module.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index dcea193521f..044722bc92d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,6 +294,7 @@ else() set (VTK_Group_ParaViewPython ${PARAVIEW_ENABLE_PYTHON} CACHE INTERNAL "" FORCE) set (ParaViewModulesDirs + Utilities/ProcessXML ThirdParty/protobuf ParaViewCore/ClientServerStream ParaViewCore/PythonSupport diff --git a/ParaViewCore/ServerManager/SMApplication/CMakeLists.txt b/ParaViewCore/ServerManager/SMApplication/CMakeLists.txt index 69d1650eef5..00208e87892 100644 --- a/ParaViewCore/ServerManager/SMApplication/CMakeLists.txt +++ b/ParaViewCore/ServerManager/SMApplication/CMakeLists.txt @@ -50,7 +50,7 @@ foreach (_module ${VTK_MODULES_ENABLED}) NOT VTK_MODULE_${_module}_IS_TEST AND NOT VTK_MODULE_${_module}_THIRD_PARTY AND (NOT _module STREQUAL "vtkPVServerManagerApplication") ) - message("${_module} == Adding") + #message("${_module} == Adding") set(vtk-module-init-functions "${vtk-module-init-functions}extern \"C\" void ${_module}CS_Initialize(vtkClientServerInterpreter*);\n") set(vtk-module-init-calls @@ -58,13 +58,57 @@ foreach (_module ${VTK_MODULES_ENABLED}) list(APPEND _dependencies ${_module}CS) endif() - - # TODO: We will do something similar for the XMLs too. - endforeach() # Add link-dependencies on all wrapping classes. target_link_libraries(vtkPVServerManagerApplication ${_dependencies}) + +#------------------------------------------------------------------------------ +# Setup SM xmls. +#------------------------------------------------------------------------------ +SET(resourceFiles + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/filters.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/sources.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/readers.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/utilities.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/rendering.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/views_and_representations.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/3d_widgets.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/internal_writers.xml + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/writers.xml + ) + +if (PARAVIEW_ENABLE_PYTHON) + list(APPEND resourceFiles + ${CMAKE_CURRENT_SOURCE_DIR}/Resources/pythonfilter.xml + ) +endif(PARAVIEW_ENABLE_PYTHON) +set (PARAVIEW_SERVERMANAGER_XMLS ${resourceFiles} + CACHE INTERNAL "Server Manager XMLs") + +get_target_property(kwprocessXML_location kwProcessXML LOCATION) +add_custom_target(vtkPVServerManagerApplicationXMLs + DEPENDS ${resourceFiles} kwProcessXML + #"${CMAKE_CURRENT_BINARY_DIR}/vtkParaViewIncludeModulesToSMApplication.h" + COMMAND ${kwprocessXML_location} + ${CMAKE_CURRENT_BINARY_DIR}/vtkSMGeneratedModules.h + vtkSMDefaultModules Interface GetInterfaces + ${resourceFiles} + COMMENT "generating modules") +add_dependencies(vtkPVServerManagerApplication + vtkPVServerManagerApplicationXMLs) + +set (xml_init_code "") +foreach(rf ${resourceFiles}) + string(REGEX REPLACE "^.*/(.*).(xml|pvsm)$" "\\1" moduleName "${rf}") + set (oneModule +" init_string = vtkSMDefaultModules${moduleName}GetInterfaces(); + xmls.push_back(init_string); + delete[] init_string; init_string = NULL;") + set(xml_init_code + "${xml_init_code}\n${oneModule}") +endforeach() + #------------------------------------------------------------------------------ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/vtkPVInitializer.h.in diff --git a/ParaViewCore/ServerImplementation/Resources/3d_widgets.xml b/ParaViewCore/ServerManager/SMApplication/Resources/3d_widgets.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/3d_widgets.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/3d_widgets.xml diff --git a/ParaViewCore/ServerImplementation/Resources/filters.xml b/ParaViewCore/ServerManager/SMApplication/Resources/filters.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/filters.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/filters.xml diff --git a/ParaViewCore/ServerImplementation/Resources/internal_writers.xml b/ParaViewCore/ServerManager/SMApplication/Resources/internal_writers.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/internal_writers.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/internal_writers.xml diff --git a/ParaViewCore/ServerImplementation/Resources/pythonfilter.xml b/ParaViewCore/ServerManager/SMApplication/Resources/pythonfilter.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/pythonfilter.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/pythonfilter.xml diff --git a/ParaViewCore/ServerImplementation/Resources/readers.xml b/ParaViewCore/ServerManager/SMApplication/Resources/readers.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/readers.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/readers.xml diff --git a/ParaViewCore/ServerImplementation/Resources/rendering.xml b/ParaViewCore/ServerManager/SMApplication/Resources/rendering.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/rendering.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/rendering.xml diff --git a/ParaViewCore/ServerImplementation/Resources/sources.xml b/ParaViewCore/ServerManager/SMApplication/Resources/sources.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/sources.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/sources.xml diff --git a/ParaViewCore/ServerImplementation/Resources/utilities.xml b/ParaViewCore/ServerManager/SMApplication/Resources/utilities.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/utilities.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/utilities.xml diff --git a/ParaViewCore/ServerImplementation/Resources/views_and_representations.xml b/ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/views_and_representations.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/views_and_representations.xml diff --git a/ParaViewCore/ServerImplementation/Resources/writers.xml b/ParaViewCore/ServerManager/SMApplication/Resources/writers.xml similarity index 100% rename from ParaViewCore/ServerImplementation/Resources/writers.xml rename to ParaViewCore/ServerManager/SMApplication/Resources/writers.xml diff --git a/ParaViewCore/ServerManager/SMApplication/module.cmake b/ParaViewCore/ServerManager/SMApplication/module.cmake index e580a60f533..5800c6a2c7f 100644 --- a/ParaViewCore/ServerManager/SMApplication/module.cmake +++ b/ParaViewCore/ServerManager/SMApplication/module.cmake @@ -5,4 +5,6 @@ vtk_module(vtkPVServerManagerApplication # When creating a "custom" application, simply change this to # depend on the appropriate module. vtkPVServerManagerDefault + COMPILE_DEPENDS + vtkUtilitiesProcessXML ) diff --git a/ParaViewCore/ServerManager/SMApplication/vtkInitializationHelper.cxx b/ParaViewCore/ServerManager/SMApplication/vtkInitializationHelper.cxx index b3a381ff4b4..9270fbb84b5 100644 --- a/ParaViewCore/ServerManager/SMApplication/vtkInitializationHelper.cxx +++ b/ParaViewCore/ServerManager/SMApplication/vtkInitializationHelper.cxx @@ -28,8 +28,6 @@ PURPOSE. See the above copyright notice for more information. #include #include -static void vtkInitializationHelperInit(vtkClientServerInterpreter*); - //---------------------------------------------------------------------------- void vtkInitializationHelper::Initialize(const char* executable, int type) { @@ -79,8 +77,7 @@ void vtkInitializationHelper::Initialize(int argc, char**argv, // compatible with the version of the headers we compiled against. GOOGLE_PROTOBUF_VERIFY_VERSION; - vtkClientServerInterpreterInitializer::GetInitializer()-> - RegisterCallback(&::vtkInitializationHelperInit); + PARAVIEW_INITIALIZE(); vtkProcessModule::Initialize( static_cast(type), argc, argv); @@ -132,36 +129,3 @@ void vtkInitializationHelper::Finalize() // Optional: Delete all global objects allocated by libprotobuf. google::protobuf::ShutdownProtobufLibrary(); } - -//----------------------------------------------------------------------------- -/* - * PARAVIEW_MINIMIUM if enabled, initializes only required set of classes. - * The mechanism is specified in the Servers/ServerManager/CMakeList.txt - * Otherwise the entire vtk+paraview class list will be included. - * - * @param pm IN used to pass the interpreter for every *_Initialize function. - */ -void vtkInitializationHelperInit(vtkClientServerInterpreter* interp) -{ - // defined in vtkPVInitializer.h - PARAVIEW_CSSTREAMS_INITIALIZE(interp); - -//#ifdef PARAVIEW_MINIMAL_BUILD -// vtkParaviewMinInit_Initialize(interp); -//#else -// // Initialize built-in wrapper modules. -// @vtk-module-init-calls@ -// vtkPVCommonCS_Initialize(interp); -// vtkPVVTKExtensionsCS_Initialize(interp); -// vtkPVClientServerCoreCS_Initialize(interp); -// vtkPVServerImplementationCS_Initialize(interp); -// vtkPVServerManager_Initialize(interp); -// vtkXdmfCS_Initialize(interp); -// -//# ifdef PARAVIEW_USE_VISITBRIDGE -// vtkVisItAVTAlgorithmsCS_Initialize(interp); -// vtkVisItDatabasesCS_Initialize(interp); -//# endif -//#endif - -} diff --git a/ParaViewCore/ServerManager/SMApplication/vtkPVInitializer.h.in b/ParaViewCore/ServerManager/SMApplication/vtkPVInitializer.h.in index aa82378d39a..b67f181096b 100644 --- a/ParaViewCore/ServerManager/SMApplication/vtkPVInitializer.h.in +++ b/ParaViewCore/ServerManager/SMApplication/vtkPVInitializer.h.in @@ -15,6 +15,12 @@ // THIS IS A GENERATED FILE -- DO NOT EDIT --- #ifndef __vtkPVInitializer_h #define __vtkPVInitializer_h +#include "vtkPVConfig.h" +#include "vtkSMGeneratedModules.h" // vtkPVConfig must be included before this + // file. + +#include "vtkPVPlugin.h" +#include "vtkPVServerManagerPluginInterface.h" class vtkClientServerInterpreter; @@ -24,5 +30,62 @@ void PARAVIEW_CSSTREAMS_INITIALIZE(vtkClientServerInterpreter* interp) @vtk-module-init-calls@ } +class vtkPVInitializerPlugin : public vtkPVPlugin, + public vtkPVServerManagerPluginInterface +{ + // Description: + // Returns the name for this plugin. + virtual const char* GetPluginName() + {return "vtkPVInitializerPlugin"; } + + // Description: + // Returns the version for this plugin. + virtual const char* GetPluginVersionString() { return "0.0"; } + + // Description: + // Returns true if this plugin is required on the server. + virtual bool GetRequiredOnServer() { return false; } + + // Description: + // Returns true if this plugin is required on the client. + virtual bool GetRequiredOnClient() {return false;} + + // Description: + // Returns a ';' separated list of plugin names required by this plugin. + virtual const char* GetRequiredPlugins() { return ""; } + + // Description: + // Provides access to binary resources compiled into the plugin. + // This is primarily used to compile in icons and compressed help project + // (qch) files into plugins. + virtual void GetBinaryResources(std::vector&) {} + + // Description: + // Obtain the server-manager configuration xmls, if any. + virtual void GetXMLs(std::vector &xmls) + { + (void) xmls; + char* init_string = NULL; + @xml_init_code@ + (void) init_string; + } + + // 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 vtkClientServerInterpreterInitializer::InterpreterInitializationCallback + GetInitializeInterpreterCallback() + { + return PARAVIEW_CSSTREAMS_INITIALIZE; + } +}; + +void PARAVIEW_INITIALIZE() +{ + static vtkPVInitializerPlugin instance; + vtkPVPlugin::ImportPlugin(&instance); +} + #endif // THIS IS A GENERATED FILE -- DO NOT EDIT --- diff --git a/Utilities/ProcessXML/CMakeLists.txt b/Utilities/ProcessXML/CMakeLists.txt new file mode 100644 index 00000000000..2e60e0d821c --- /dev/null +++ b/Utilities/ProcessXML/CMakeLists.txt @@ -0,0 +1,37 @@ +#========================================================================== +# +# Program: ParaView +# +# Copyright (c) 2005-2008 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. +# +#========================================================================== +vtk_module_impl() +if (NOT CMAKE_CROSSCOMPILING) + vtk_add_executable(kwProcessXML ProcessXML.cxx) + vtk_module_export("") + target_link_libraries(kwProcessXML + vtkCommonCore) +endif() diff --git a/Common/KWCommon/ProcessXML.cxx b/Utilities/ProcessXML/ProcessXML.cxx similarity index 100% rename from Common/KWCommon/ProcessXML.cxx rename to Utilities/ProcessXML/ProcessXML.cxx diff --git a/Utilities/ProcessXML/module.cmake b/Utilities/ProcessXML/module.cmake new file mode 100644 index 00000000000..136897034a1 --- /dev/null +++ b/Utilities/ProcessXML/module.cmake @@ -0,0 +1,5 @@ +vtk_module(vtkUtilitiesProcessXML + DEPENDS + vtkCommonCore + vtksys + EXCLUDE_FROM_WRAPPING)