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 "vtkRemotingCoreModule.h" //needed for exports
25 
26 #include <functional> // for std::function
27 
28 class vtkPVPlugin;
29 
31 {
32 public:
33  static vtkPVPluginLoader* New();
34  vtkTypeMacro(vtkPVPluginLoader, vtkObject);
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  bool LoadPluginByName(const char* name, bool acceptDelayed = true);
41 
45  bool LoadPlugin(const char* filename) { return this->LoadPluginInternal(filename, false); }
46  bool LoadPluginSilently(const char* filename) { return this->LoadPluginInternal(filename, true); }
47 
53  bool LoadDelayedLoadPlugin(
54  const std::string& name, const std::vector<std::string>& xmls, const std::string& filename);
55 
57 
61  void LoadPluginConfigurationXMLFromString(const char* xmlcontents);
62  void LoadPluginConfigurationXML(const char* configurationFile);
64 
68  void LoadPluginsFromPluginSearchPath();
69 
85  void LoadPluginsFromPluginConfigFile();
86 
90  void LoadPluginsFromPath(const char* path);
91 
93 
97  vtkGetStringMacro(FileName);
99 
101 
105  vtkGetStringMacro(PluginName);
107 
109 
113  vtkGetStringMacro(PluginVersion);
115 
117 
121  vtkGetStringMacro(ErrorString);
123 
125 
130  vtkGetStringMacro(SearchPaths);
132 
134 
137  vtkGetMacro(Loaded, bool);
139 
141 
143  using PluginLoaderCallback = std::function<bool(const char*)>;
144  static int RegisterLoadPluginCallback(PluginLoaderCallback callback);
145  static void UnregisterLoadPluginCallback(int id);
147 
153  static void PluginLibraryUnloaded(const char* pluginname);
154 
155 protected:
157  ~vtkPVPluginLoader() override;
158 
159  bool LoadPluginInternal(const char* filename, bool no_errors);
160 
165  bool LoadPluginInternal(vtkPVPlugin* plugin);
166 
171  bool IsLoaded(const char* filename, bool acceptDelayed = false);
172 
173  vtkSetStringMacro(ErrorString);
174  vtkSetStringMacro(PluginName);
175  vtkSetStringMacro(PluginVersion);
176  vtkSetStringMacro(FileName);
177  vtkSetStringMacro(SearchPaths);
178 
179  char* ErrorString;
180  char* PluginName;
182  char* FileName;
183  char* SearchPaths;
184  bool Loaded;
185 
186 private:
187  vtkPVPluginLoader(const vtkPVPluginLoader&) = delete;
188  void operator=(const vtkPVPluginLoader&) = delete;
189  static bool CallPluginLoaderCallbacks(const char* nameOrFile);
190 };
191 
192 // Implementation of Schwartz counter idiom to ensure that the plugin library
193 // unloading doesn't happen before the ParaView application is finalized.
195 {
196 public:
199 } vtkPVPluginLoaderCleanerInitializerInstance; // object here in header.
200 
201 #endif
bool LoadPluginSilently(const char *filename)
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
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 &)