vtkPVPlugin.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkPVPlugin_h
20 #define vtkPVPlugin_h
21 
22 #include "vtkRemotingCoreModule.h" //needed for exports
23 #include <string> // for std::string
24 #include <vector> // for std::vector
25 
26 #ifdef _WIN32
27 // __cdecl gives an unmangled name
28 #define C_DECL __cdecl
29 #define C_EXPORT extern "C" __declspec(dllexport)
30 #elif defined(__GNUC__)
31 #define C_DECL
32 #define C_EXPORT extern "C" __attribute__((visibility("default")))
33 #else
34 #define C_DECL
35 #define C_EXPORT extern "C"
36 #endif
37 
39 {
40 public:
41  vtkPVPlugin();
42  virtual ~vtkPVPlugin();
43 
44  const char* GetFileName() { return this->FileName; }
45 
49  virtual const char* GetPluginName() = 0;
50 
54  virtual const char* GetPluginVersionString() = 0;
55 
59  virtual bool GetRequiredOnServer() = 0;
60 
64  virtual bool GetRequiredOnClient() = 0;
65 
69  virtual const char* GetRequiredPlugins() = 0;
70 
74  virtual const char* GetDescription() = 0;
75 
79  virtual const char* GetEULA() = 0;
80 
86  virtual void GetBinaryResources(std::vector<std::string>& resources);
87 
89 
102  static bool ImportPlugin(vtkPVPlugin* plugin);
103 
107  typedef bool (*EULAConfirmationCallback)(vtkPVPlugin*);
108 
110 
113  static void SetEULAConfirmationCallback(EULAConfirmationCallback callback);
114  static EULAConfirmationCallback GetEULAConfirmationCallback();
116 
121  typedef bool (*OnLoadCheckCallback)();
122 
124 
127  void SetOnLoadCheckCallbackFunction(OnLoadCheckCallback callback);
128  OnLoadCheckCallback GetOnLoadCheckCallbackFunction() const;
130 
131 protected:
137  void SetFileName(const char* filename);
138 
139 private:
146  static bool ConfirmEULA(vtkPVPlugin* plugin);
147 
148  bool OnLoadCheckCallbackExecute();
149 
150  char* FileName;
151 
152  OnLoadCheckCallback OnLoadCheckCallbackPtr;
153 
154  static EULAConfirmationCallback EULAConfirmationCallbackPtr;
155  friend class vtkPVPluginLoader;
156 
157  vtkPVPlugin(const vtkPVPlugin&) = delete;
158  void operator=(const vtkPVPlugin&) = delete;
159 };
161 
162 #ifndef __WRAP__
164 #endif
165 
166 #ifdef PARAVIEW_BUILDING_PLUGIN
167 
168 // vtkPVPluginLoader checks for existence of this function
169 // to determine if the shared-library is a paraview-server-manager plugin or
170 // not. The returned value is used to match paraview version/compiler version
171 // etc. These global functions are added only for shared builds. In static
172 // builds, plugins cannot be loaded at runtime (only at compile time) so
173 // verification is not necessary.
174 #if PARAVIEW_PLUGIN_BUILT_SHARED
175 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN) \
176  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance() \
177  { \
178  return pv_plugin_instance_##PLUGIN(); \
179  }
180 #else
181 // define empty export. When building static, we don't want to define the global
182 // functions.
183 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN)
184 #endif
185 
186 // vtkPVPluginLoader uses this function to obtain the vtkPVPlugin instance for
187 // this plugin. In a plugin, there can only be one call to this macro. When
188 // using the CMake macro ADD_PARAVIEW_PLUGIN, you don't have to worry about
189 // this, the CMake macro takes care of it.
190 #define PV_PLUGIN_EXPORT(PLUGIN, PLUGINCLASS) \
191  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance_##PLUGIN() \
192  { \
193  static PLUGINCLASS instance; \
194  return &instance; \
195  } \
196  _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN);
197 
198 // PV_PLUGIN_IMPORT_INIT and PV_PLUGIN_IMPORT are provided to make it possible
199 // to import a plugin at compile time. In static builds, the only way to use a
200 // plugin is by explicitly importing it using these macros.
201 // PV_PLUGIN_IMPORT_INIT must be typically placed at after the #include's in a
202 // cxx file, while PV_PLUGIN_IMPORT must be called at a point after all the
203 // plugin managers for the application, including the vtkSMPluginManager,
204 // have been initialized.
205 #define PV_PLUGIN_IMPORT_INIT(PLUGIN) extern "C" vtkPVPlugin* pv_plugin_instance_##PLUGIN();
206 
207 #define PV_PLUGIN_IMPORT(PLUGIN) vtkPVPlugin::ImportPlugin(pv_plugin_instance_##PLUGIN());
208 
209 #endif
210 
211 #endif // vtkPVPlugin_h
212 // VTK-HeaderTest-Exclude: vtkPVPlugin.h
#define C_DECL
Definition: vtkPVPlugin.h:34
defines the core interface for any ParaView plugin.
Definition: vtkPVPlugin.h:38
Used to load ParaView plugins.
const char * GetFileName()
Definition: vtkPVPlugin.h:44
#define VTKREMOTINGCORE_EXPORT
vtkPVPlugin *(C_DECL * pv_plugin_query_instance_fptr)()
Definition: vtkPVPlugin.h:163