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