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);
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  void LoadPluginConfigurationXMLFromString(const char* xmlcontents);
54 
58  void LoadPluginsFromPluginSearchPath();
59 
75  void LoadPluginsFromPluginConfigFile();
76 
80  void LoadPluginsFromPath(const char* path);
81 
83 
87  vtkGetStringMacro(FileName);
89 
91 
95  vtkGetStringMacro(PluginName);
97 
99 
103  vtkGetStringMacro(PluginVersion);
105 
107 
111  vtkGetStringMacro(ErrorString);
113 
115 
120  vtkGetStringMacro(SearchPaths);
122 
124 
127  vtkGetMacro(Loaded, bool);
129 
131 
133  using PluginLoaderCallback = std::function<bool(const char*)>;
134  static int RegisterLoadPluginCallback(PluginLoaderCallback callback);
135  static void UnregisterLoadPluginCallback(int id);
137 
143  static void PluginLibraryUnloaded(const char* pluginname);
144 
145 protected:
147  ~vtkPVPluginLoader() override;
148 
149  bool LoadPluginInternal(const char* filename, bool no_errors);
150 
155  bool LoadPluginInternal(vtkPVPlugin* plugin);
156 
157  vtkSetStringMacro(ErrorString);
158  vtkSetStringMacro(PluginName);
159  vtkSetStringMacro(PluginVersion);
160  vtkSetStringMacro(FileName);
161  vtkSetStringMacro(SearchPaths);
162 
163  char* ErrorString;
164  char* PluginName;
166  char* FileName;
167  char* SearchPaths;
168  bool Loaded;
169 
170 private:
171  vtkPVPluginLoader(const vtkPVPluginLoader&) = delete;
172  void operator=(const vtkPVPluginLoader&) = delete;
173  static bool CallPluginLoaderCallbacks(const char* nameOrFile);
174 };
175 
176 // Implementation of Schwartz counter idiom to ensure that the plugin library
177 // unloading doesn't happen before the ParaView application is finalized.
179 {
180 public:
183 } vtkPVPluginLoaderCleanerInitializerInstance; // object here in header.
184 
185 #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.
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 &)