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 =========================================================================*/
31 #ifndef vtkPVPlugin_h
32 #define vtkPVPlugin_h
33 
34 #include "vtkObject.h"
35 #include "vtkPVConfig.h" // needed for PARAVIEW_VERSION
36 #include "vtkRemotingCoreModule.h" //needed for exports
37 #include <string>
38 #include <vector>
39 
40 #ifdef _WIN32
41 // __cdecl gives an unmangled name
42 #define C_DECL __cdecl
43 #define C_EXPORT extern "C" __declspec(dllexport)
44 #elif defined(__GNUC__)
45 #define C_DECL
46 #define C_EXPORT extern "C" __attribute__((visibility("default")))
47 #else
48 #define C_DECL
49 #define C_EXPORT extern "C"
50 #endif
51 
53 {
54 public:
55  vtkPVPlugin();
56  virtual ~vtkPVPlugin();
57 
58  const char* GetFileName() { return this->FileName; }
59 
63  virtual const char* GetPluginName() = 0;
64 
68  virtual const char* GetPluginVersionString() = 0;
69 
73  virtual bool GetRequiredOnServer() = 0;
74 
78  virtual bool GetRequiredOnClient() = 0;
79 
83  virtual const char* GetRequiredPlugins() = 0;
84 
88  virtual const char* GetDescription() = 0;
89 
93  virtual const char* GetEULA() = 0;
94 
100  virtual void GetBinaryResources(std::vector<std::string>& resources);
101 
103 
116  static bool ImportPlugin(vtkPVPlugin* plugin);
117 
121  typedef bool (*EULAConfirmationCallback)(vtkPVPlugin*);
122 
124 
127  static void SetEULAConfirmationCallback(EULAConfirmationCallback callback);
128  static EULAConfirmationCallback GetEULAConfirmationCallback();
130 
131 protected:
137  void SetFileName(const char* filename);
138 
139 private:
146  static bool ConfirmEULA(vtkPVPlugin* plugin);
147 
148  char* FileName;
149 
150  static EULAConfirmationCallback EULAConfirmationCallbackPtr;
151  friend class vtkPVPluginLoader;
152 
153 private:
154  vtkPVPlugin(const vtkPVPlugin&) = delete;
155  void operator=(const vtkPVPlugin&) = delete;
156 };
158 
159 #ifndef __WRAP__
161 #endif
162 
163 #ifdef PARAVIEW_BUILDING_PLUGIN
164 
165 // vtkPVPluginLoader checks for existence of this function
166 // to determine if the shared-library is a paraview-server-manager plugin or
167 // not. The returned value is used to match paraview version/compiler version
168 // etc. These global functions are added only for shared builds. In static
169 // builds, plugins cannot be loaded at runtime (only at compile time) so
170 // verification is not necessary.
171 #if PARAVIEW_PLUGIN_BUILT_SHARED
172 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN) \
173  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance() { return pv_plugin_instance_##PLUGIN(); }
174 #else
175 // define empty export. When building static, we don't want to define the global
176 // functions.
177 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN)
178 #endif
179 
180 // vtkPVPluginLoader uses this function to obtain the vtkPVPlugin instance for
181 // this plugin. In a plugin, there can only be one call to this macro. When
182 // using the CMake macro ADD_PARAVIEW_PLUGIN, you don't have to worry about
183 // this, the CMake macro takes care of it.
184 #define PV_PLUGIN_EXPORT(PLUGIN, PLUGINCLASS) \
185  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance_##PLUGIN() \
186  { \
187  static PLUGINCLASS instance; \
188  return &instance; \
189  } \
190  _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN);
191 
192 // PV_PLUGIN_IMPORT_INIT and PV_PLUGIN_IMPORT are provided to make it possible
193 // to import a plugin at compile time. In static builds, the only way to use a
194 // plugin is by explicitly importing it using these macros.
195 // PV_PLUGIN_IMPORT_INIT must be typically placed at after the #include's in a
196 // cxx file, while PV_PLUGIN_IMPORT must be called at a point after all the
197 // plugin managers for the application, including the vtkSMPluginManager,
198 // have been initialized.
199 #define PV_PLUGIN_IMPORT_INIT(PLUGIN) extern "C" vtkPVPlugin* pv_plugin_instance_##PLUGIN();
200 
201 #define PV_PLUGIN_IMPORT(PLUGIN) vtkPVPlugin::ImportPlugin(pv_plugin_instance_##PLUGIN());
202 
203 #endif
204 
205 #endif // vtkPVPlugin_h
206 // VTK-HeaderTest-Exclude: vtkPVPlugin.h
#define C_DECL
Definition: vtkPVPlugin.h:48
defines the core interface for any ParaView plugin.
Definition: vtkPVPlugin.h:52
Used to load ParaView plugins.
const char * GetFileName()
Definition: vtkPVPlugin.h:58
#define VTKREMOTINGCORE_EXPORT
vtkPVPlugin *(C_DECL * pv_plugin_query_instance_fptr)()
Definition: vtkPVPlugin.h:160