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 "vtkPVVersion.h" // needed for PARAVIEW_VERSION
23 #include "vtkRemotingCoreModule.h" //needed for exports
24 #include <string> // for std::string
25 #include <vector> // for std::vector
26 
27 #ifdef _WIN32
28 // __cdecl gives an unmangled name
29 #define C_DECL __cdecl
30 #define C_EXPORT extern "C" __declspec(dllexport)
31 #elif defined(__GNUC__)
32 #define C_DECL
33 #define C_EXPORT extern "C" __attribute__((visibility("default")))
34 #else
35 #define C_DECL
36 #define C_EXPORT extern "C"
37 #endif
38 
40 {
41 public:
42  vtkPVPlugin();
43  virtual ~vtkPVPlugin();
44 
45  const char* GetFileName() { return this->FileName; }
46 
50  virtual const char* GetPluginName() = 0;
51 
55  virtual const char* GetPluginVersionString() = 0;
56 
60  virtual bool GetRequiredOnServer() = 0;
61 
65  virtual bool GetRequiredOnClient() = 0;
66 
70  virtual const char* GetRequiredPlugins() = 0;
71 
75  virtual const char* GetDescription() = 0;
76 
80  virtual const char* GetEULA() = 0;
81 
87  virtual void GetBinaryResources(std::vector<std::string>& resources);
88 
90 
103  static bool ImportPlugin(vtkPVPlugin* plugin);
104 
108  typedef bool (*EULAConfirmationCallback)(vtkPVPlugin*);
109 
111 
114  static void SetEULAConfirmationCallback(EULAConfirmationCallback callback);
115  static EULAConfirmationCallback GetEULAConfirmationCallback();
117 
118 protected:
124  void SetFileName(const char* filename);
125 
126 private:
133  static bool ConfirmEULA(vtkPVPlugin* plugin);
134 
135  char* FileName;
136 
137  static EULAConfirmationCallback EULAConfirmationCallbackPtr;
138  friend class vtkPVPluginLoader;
139 
140  vtkPVPlugin(const vtkPVPlugin&) = delete;
141  void operator=(const vtkPVPlugin&) = delete;
142 };
144 
145 #ifndef __WRAP__
147 #endif
148 
149 #ifdef PARAVIEW_BUILDING_PLUGIN
150 
151 // vtkPVPluginLoader checks for existence of this function
152 // to determine if the shared-library is a paraview-server-manager plugin or
153 // not. The returned value is used to match paraview version/compiler version
154 // etc. These global functions are added only for shared builds. In static
155 // builds, plugins cannot be loaded at runtime (only at compile time) so
156 // verification is not necessary.
157 #if PARAVIEW_PLUGIN_BUILT_SHARED
158 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN) \
159  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance() { return pv_plugin_instance_##PLUGIN(); }
160 #else
161 // define empty export. When building static, we don't want to define the global
162 // functions.
163 #define _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN)
164 #endif
165 
166 // vtkPVPluginLoader uses this function to obtain the vtkPVPlugin instance for
167 // this plugin. In a plugin, there can only be one call to this macro. When
168 // using the CMake macro ADD_PARAVIEW_PLUGIN, you don't have to worry about
169 // this, the CMake macro takes care of it.
170 #define PV_PLUGIN_EXPORT(PLUGIN, PLUGINCLASS) \
171  C_EXPORT vtkPVPlugin* C_DECL pv_plugin_instance_##PLUGIN() \
172  { \
173  static PLUGINCLASS instance; \
174  return &instance; \
175  } \
176  _PV_PLUGIN_GLOBAL_FUNCTIONS(PLUGIN);
177 
178 // PV_PLUGIN_IMPORT_INIT and PV_PLUGIN_IMPORT are provided to make it possible
179 // to import a plugin at compile time. In static builds, the only way to use a
180 // plugin is by explicitly importing it using these macros.
181 // PV_PLUGIN_IMPORT_INIT must be typically placed at after the #include's in a
182 // cxx file, while PV_PLUGIN_IMPORT must be called at a point after all the
183 // plugin managers for the application, including the vtkSMPluginManager,
184 // have been initialized.
185 #define PV_PLUGIN_IMPORT_INIT(PLUGIN) extern "C" vtkPVPlugin* pv_plugin_instance_##PLUGIN();
186 
187 #define PV_PLUGIN_IMPORT(PLUGIN) vtkPVPlugin::ImportPlugin(pv_plugin_instance_##PLUGIN());
188 
189 #endif
190 
191 #endif // vtkPVPlugin_h
192 // VTK-HeaderTest-Exclude: vtkPVPlugin.h
#define C_DECL
Definition: vtkPVPlugin.h:35
defines the core interface for any ParaView plugin.
Definition: vtkPVPlugin.h:39
Used to load ParaView plugins.
const char * GetFileName()
Definition: vtkPVPlugin.h:45
#define VTKREMOTINGCORE_EXPORT
vtkPVPlugin *(C_DECL * pv_plugin_query_instance_fptr)()
Definition: vtkPVPlugin.h:146