ParaView
vtkPVPlugin.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkPVPlugin.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
29 #ifndef vtkPVPlugin_h
30 #define vtkPVPlugin_h
31 
32 #include "vtkObject.h"
33 #include "vtkPVClientServerCoreCoreModule.h" //needed for exports
34 #include "vtkPVConfig.h" // needed for PARAVIEW_VERSION and CMAKE_CXX_COMPILER_ID
35 #include <string>
36 #include <vector>
37 
38 #ifdef _WIN32
39 // __cdecl gives an unmangled name
40 #define C_DECL __cdecl
41 #define C_EXPORT extern "C" __declspec(dllexport)
42 #elif defined(__GNUC__)
43 #define C_DECL
44 #define C_EXPORT extern "C" __attribute__((visibility("default")))
45 #else
46 #define C_DECL
47 #define C_EXPORT extern "C"
48 #endif
49 
50 class VTKPVCLIENTSERVERCORECORE_EXPORT vtkPVPlugin
51 {
52  char* FileName;
53  void SetFileName(const char* filename);
54  friend class vtkPVPluginLoader;
55 
56 public:
57  vtkPVPlugin();
58  virtual ~vtkPVPlugin();
59 
60  const char* GetFileName() { return this->FileName; }
61 
65  virtual const char* GetPluginName() = 0;
66 
70  virtual const char* GetPluginVersionString() = 0;
71 
75  virtual bool GetRequiredOnServer() = 0;
76 
80  virtual bool GetRequiredOnClient() = 0;
81 
85  virtual const char* GetRequiredPlugins() = 0;
86 
92  virtual void GetBinaryResources(std::vector<std::string>& resources);
93 
95 
101  static void ImportPlugin(vtkPVPlugin* plugin);
102 };
104 
105 #ifndef __WRAP__
108 #endif
109 
111 #define _PV_PLUGIN_VERIFICATION_STRING "paraviewplugin|" CMAKE_CXX_COMPILER_ID "|" PARAVIEW_VERSION
112 
113 // vtkPVPluginLoader checks for existence of this function
114 // to determine if the shared-library is a paraview-server-manager plugin or
115 // not. The returned value is used to match paraview version/compiler version
116 // etc. These global functions are added only for shared builds. In static
117 // builds, plugins cannot be loaded at runtime (only at compile time) so
118 // verification is not necessary.
119 #ifdef BUILD_SHARED_LIBS
120 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN) \
121  C_EXPORT const char* C_DECL pv_plugin_query_verification_data() \
122  { \
123  return _PV_PLUGIN_VERIFICATION_STRING; \
124  } \
125  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance() { return pv_plugin_instance_##PLUGIN(); }
126 #else // BUILD_SHARED_LIBS
127 // define empty export. When building static, we don't want to define the global
128 // functions.
129 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN)
130 #endif // BUILD_SHARED_LIBS
131 
132 // vtkPVPluginLoader uses this function to obtain the vtkPVPlugin instance for
133 // this plugin. In a plugin, there can only be one call to this macro. When
134 // using the CMake macro ADD_PARAVIEW_PLUGIN, you don't have to worry about
135 // this, the CMake macro takes care of it.
136 #define PV_PLUGIN_EXPORT(PLUGIN, PLUGINCLASS) \
137  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance_##PLUGIN() \
138  { \
139  static PLUGINCLASS instance; \
140  return &instance; \
141  } \
142  _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN);
143 
144 // PV_PLUGIN_IMPORT_INIT and PV_PLUGIN_IMPORT are provided to make it possible
145 // to import a plugin at compile time. In static builds, the only way to use a
146 // plugin is by explicitly importing it using these macros.
147 // PV_PLUGIN_IMPORT_INIT must be typically placed at after the #include's in a
148 // cxx file, while PV_PLUGIN_IMPORT must be called at a point after all the
149 // plugin managers for the application, including the vtkSMPluginManager,
150 // have been initialized.
151 #define PV_PLUGIN_IMPORT_INIT(PLUGIN) extern "C" vtkPVPlugin* pv_plugin_instance_##PLUGIN();
152 
153 #define PV_PLUGIN_IMPORT(PLUGIN) vtkPVPlugin::ImportPlugin(pv_plugin_instance_##PLUGIN());
154 
155 #endif // vtkPVPlugin_h
156 // VTK-HeaderTest-Exclude: vtkPVPlugin.h
#define C_DECL
Definition: vtkPVPlugin.h:46
virtual char * GetPluginName()
Get the plugin name.
defines the core interface for any ParaView plugin.
Definition: vtkPVPlugin.h:50
Used to load ParaView plugins.
const char * GetFileName()
Definition: vtkPVPlugin.h:60
const char *(C_DECL * pv_plugin_query_verification_data_fptr)()
Definition: vtkPVPlugin.h:106
vtkPVPlugin *(C_DECL * pv_plugin_query_instance_fptr)()
Definition: vtkPVPlugin.h:107