vtkPVPluginLoader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkPVPluginLoader_h
21 #define vtkPVPluginLoader_h
22 
23 #include "vtkObject.h"
24 #include "vtkParaViewDeprecation.h" // for deprecation macro
25 #include "vtkRemotingCoreModule.h" //needed for exports
26 
27 #include <functional> // for std::function
28 
29 class vtkPVPlugin;
30 
32 {
33 public:
34  static vtkPVPluginLoader* New();
35  vtkTypeMacro(vtkPVPluginLoader, vtkObject);
36  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
41  bool LoadPluginByName(const char* name, bool acceptDelayed = true);
42 
46  bool LoadPlugin(const char* filename) { return this->LoadPluginInternal(filename, false); }
47  bool LoadPluginSilently(const char* filename) { return this->LoadPluginInternal(filename, true); }
48 
54  PARAVIEW_DEPRECATED_IN_5_14_0("Use LoadDelayedLoadPlugin instead")
55  bool LoadDelayedLoadPlugin(
56  const std::string& name, const std::vector<std::string>& xmls, const std::string& filename);
57 
63  bool LoadDelayedLoadPlugin(const std::string& name, const std::vector<std::string>& xmls,
64  const std::string& filename, const std::string& version, const std::string& description);
65 
67 
71  void LoadPluginConfigurationXMLFromString(const char* xmlcontents);
72  void LoadPluginConfigurationXML(const char* configurationFile);
74 
78  void LoadPluginsFromPluginSearchPath();
79 
95  void LoadPluginsFromPluginConfigFile();
96 
100  void LoadPluginsFromPath(const char* path);
101 
103 
107  vtkGetStringMacro(FileName);
109 
111 
115  vtkGetStringMacro(PluginName);
117 
119 
123  vtkGetStringMacro(PluginVersion);
125 
127 
131  vtkGetStringMacro(ErrorString);
133 
135 
140  vtkGetStringMacro(SearchPaths);
142 
144 
147  vtkGetMacro(Loaded, bool);
149 
151 
153  using PluginLoaderCallback = std::function<bool(const char*)>;
154  static int RegisterLoadPluginCallback(PluginLoaderCallback callback);
155  static void UnregisterLoadPluginCallback(int id);
157 
163  static void PluginLibraryUnloaded(const char* pluginname);
164 
165 protected:
167  ~vtkPVPluginLoader() override;
168 
169  bool LoadPluginInternal(const char* filename, bool no_errors);
170 
175  bool LoadPluginInternal(vtkPVPlugin* plugin);
176 
181  bool IsLoaded(const char* filename, bool acceptDelayed = false);
182 
183  vtkSetStringMacro(ErrorString);
184  vtkSetStringMacro(PluginName);
185  vtkSetStringMacro(PluginVersion);
186  vtkSetStringMacro(FileName);
187  vtkSetStringMacro(SearchPaths);
188 
189  char* ErrorString;
190  char* PluginName;
192  char* FileName;
193  char* SearchPaths;
194  bool Loaded;
195 
196 private:
197  vtkPVPluginLoader(const vtkPVPluginLoader&) = delete;
198  void operator=(const vtkPVPluginLoader&) = delete;
199  static bool CallPluginLoaderCallbacks(const char* nameOrFile);
200 };
201 
202 // Implementation of Schwartz counter idiom to ensure that the plugin library
203 // unloading doesn't happen before the ParaView application is finalized.
205 {
206 public:
209 } vtkPVPluginLoaderCleanerInitializerInstance; // object here in header.
210 
211 #endif
description
bool LoadPluginSilently(const char *filename)
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
#define PARAVIEW_DEPRECATED_IN_5_14_0(reason)
version
defines the core interface for any ParaView plugin.
Definition: vtkPVPlugin.h:38
Used to load ParaView plugins.
name
static class VTKREMOTINGCORE_EXPORT vtkPVPluginLoaderCleanerInitializer vtkPVPluginLoaderCleanerInitializerInstance
std::function< bool(const char *)> PluginLoaderCallback
#define VTKREMOTINGCORE_EXPORT
bool LoadPlugin(const char *filename)
Tries to the load the plugin given the path to the plugin file.
static vtkObject * New()
void operator=(const vtkObjectBase &)