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 
117 protected:
123  void SetFileName(const char* filename);
124 
125 private:
132  static bool ConfirmEULA(vtkPVPlugin* plugin);
133 
134  char* FileName;
135 
136  static EULAConfirmationCallback EULAConfirmationCallbackPtr;
137  friend class vtkPVPluginLoader;
138 
139  vtkPVPlugin(const vtkPVPlugin&) = delete;
140  void operator=(const vtkPVPlugin&) = delete;
141 };
143 
144 #ifndef __WRAP__
146 #endif
147 
148 #ifdef PARAVIEW_BUILDING_PLUGIN
149 
150 // vtkPVPluginLoader checks for existence of this function
151 // to determine if the shared-library is a paraview-server-manager plugin or
152 // not. The returned value is used to match paraview version/compiler version
153 // etc. These global functions are added only for shared builds. In static
154 // builds, plugins cannot be loaded at runtime (only at compile time) so
155 // verification is not necessary.
156 #if PARAVIEW_PLUGIN_BUILT_SHARED
157 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN) \
158  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance() { return pv_plugin_instance_##PLUGIN(); }
159 #else
160 // define empty export. When building static, we don't want to define the global
161 // functions.
162 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN)
163 #endif
164 
165 // vtkPVPluginLoader uses this function to obtain the vtkPVPlugin instance for
166 // this plugin. In a plugin, there can only be one call to this macro. When
167 // using the CMake macro ADD_PARAVIEW_PLUGIN, you don't have to worry about
168 // this, the CMake macro takes care of it.
169 #define PV_PLUGIN_EXPORT(PLUGIN, PLUGINCLASS) \
170  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance_##PLUGIN() \
171  { \
172  static PLUGINCLASS instance; \
173  return &instance; \
174  } \
175  _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN);
176 
177 // PV_PLUGIN_IMPORT_INIT and PV_PLUGIN_IMPORT are provided to make it possible
178 // to import a plugin at compile time. In static builds, the only way to use a
179 // plugin is by explicitly importing it using these macros.
180 // PV_PLUGIN_IMPORT_INIT must be typically placed at after the #include's in a
181 // cxx file, while PV_PLUGIN_IMPORT must be called at a point after all the
182 // plugin managers for the application, including the vtkSMPluginManager,
183 // have been initialized.
184 #define PV_PLUGIN_IMPORT_INIT(PLUGIN) extern "C" vtkPVPlugin* pv_plugin_instance_##PLUGIN();
185 
186 #define PV_PLUGIN_IMPORT(PLUGIN) vtkPVPlugin::ImportPlugin(pv_plugin_instance_##PLUGIN());
187 
188 #endif
189 
190 #endif // vtkPVPlugin_h
191 // 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:145