vtkPVPluginLoader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkPVPluginLoader.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 =========================================================================*/
32 #ifndef vtkPVPluginLoader_h
33 #define vtkPVPluginLoader_h
34 
35 #include "vtkObject.h"
36 #include "vtkRemotingCoreModule.h" //needed for exports
37 
38 #include <functional> // for std::function
39 
40 class vtkPVPlugin;
41 
43 {
44 public:
45  static vtkPVPluginLoader* New();
46  vtkTypeMacro(vtkPVPluginLoader, vtkObject);
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
52  bool LoadPluginByName(const char* name);
53 
57  bool LoadPlugin(const char* filename) { return this->LoadPluginInternal(filename, false); }
58  bool LoadPluginSilently(const char* filename) { return this->LoadPluginInternal(filename, true); }
59 
65  void LoadPluginConfigurationXMLFromString(const char* xmlcontents);
66 
70  void LoadPluginsFromPluginSearchPath();
71 
87  void LoadPluginsFromPluginConfigFile();
88 
92  void LoadPluginsFromPath(const char* path);
93 
95 
99  vtkGetStringMacro(FileName);
101 
103 
107  vtkGetStringMacro(PluginName);
109 
111 
115  vtkGetStringMacro(PluginVersion);
117 
119 
123  vtkGetStringMacro(ErrorString);
125 
127 
132  vtkGetStringMacro(SearchPaths);
134 
136 
139  vtkGetMacro(Loaded, bool);
141 
143 
145  using PluginLoaderCallback = std::function<bool(const char*)>;
146  static int RegisterLoadPluginCallback(PluginLoaderCallback callback);
147  static void UnregisterLoadPluginCallback(int id);
149 
155  static void PluginLibraryUnloaded(const char* pluginname);
156 
157 protected:
159  ~vtkPVPluginLoader() override;
160 
161  bool LoadPluginInternal(const char* filename, bool no_errors);
162 
167  bool LoadPluginInternal(vtkPVPlugin* plugin);
168 
169  vtkSetStringMacro(ErrorString);
170  vtkSetStringMacro(PluginName);
171  vtkSetStringMacro(PluginVersion);
172  vtkSetStringMacro(FileName);
173  vtkSetStringMacro(SearchPaths);
174 
175  char* ErrorString;
176  char* PluginName;
178  char* FileName;
179  char* SearchPaths;
180  bool Loaded;
181 
182 private:
183  vtkPVPluginLoader(const vtkPVPluginLoader&) = delete;
184  void operator=(const vtkPVPluginLoader&) = delete;
185  static bool CallPluginLoaderCallbacks(const char* nameOrFile);
186 };
187 
188 // Implementation of Schwartz counter idiom to ensure that the plugin library
189 // unloading doesn't happen before the ParaView application is finalized.
191 {
192 public:
195 } vtkPVPluginLoaderCleanerInitializerInstance; // object here in header.
196 
197 #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:52
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 &)