ParaView
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 =========================================================================*/
27 #ifndef vtkPVPluginLoader_h
28 #define vtkPVPluginLoader_h
29 
30 #include "vtkObject.h"
31 #include "vtkPVClientServerCoreCoreModule.h" //needed for exports
32 
33 class vtkIntArray;
34 class vtkPVPlugin;
35 class vtkStringArray;
36 class vtkPVPlugin;
37 
38 typedef bool (*vtkPluginLoadFunction)(const char*);
39 
40 class VTKPVCLIENTSERVERCORECORE_EXPORT vtkPVPluginLoader : public vtkObject
41 {
42 public:
43  static vtkPVPluginLoader* New();
44  vtkTypeMacro(vtkPVPluginLoader, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent);
46 
50  bool LoadPlugin(const char* filename) { return this->LoadPluginInternal(filename, false); }
51  bool LoadPluginSilently(const char* filename) { return this->LoadPluginInternal(filename, true); }
52 
58  void LoadPluginConfigurationXMLFromString(const char* xmlcontents);
59 
63  void LoadPluginsFromPluginSearchPath();
64 
77  void LoadPluginsFromPluginConfigFile();
78 
82  void LoadPluginsFromPath(const char* path);
83 
85 
89  vtkGetStringMacro(FileName);
91 
93 
97  vtkGetStringMacro(PluginName);
99 
101 
105  vtkGetStringMacro(PluginVersion);
107 
109 
113  vtkGetStringMacro(ErrorString);
115 
117 
122  vtkGetStringMacro(SearchPaths);
124 
126 
129  vtkGetMacro(Loaded, bool);
131 
135  static void SetStaticPluginLoadFunction(vtkPluginLoadFunction function);
136 
142  static void PluginLibraryUnloaded(const char* pluginname);
143 
144 protected:
147 
148  bool LoadPluginInternal(const char* filename, bool no_errors);
149 
154  bool LoadPlugin(const char* file, vtkPVPlugin* plugin);
155 
156  vtkSetStringMacro(ErrorString);
157  vtkSetStringMacro(PluginName);
158  vtkSetStringMacro(PluginVersion);
159  vtkSetStringMacro(FileName);
160  vtkSetStringMacro(SearchPaths);
161 
162  char* ErrorString;
163  char* PluginName;
165  char* FileName;
166  char* SearchPaths;
168  bool Loaded;
169 
170 private:
171  vtkPVPluginLoader(const vtkPVPluginLoader&) VTK_DELETE_FUNCTION;
172  void operator=(const vtkPVPluginLoader&) VTK_DELETE_FUNCTION;
173 
174  static vtkPluginLoadFunction StaticPluginLoadFunction;
175 };
176 
177 // Implementation of Schwartz counter idiom to ensure that the plugin library
178 // unloading doesn't happen before the ParaView application is finalized.
179 static class VTKPVCLIENTSERVERCORECORE_EXPORT vtkPVPluginLoaderCleanerInitializer
180 {
181 public:
184 } vtkPVPluginLoaderCleanerInitializerInstance; // object here in header.
185 
186 #endif
bool LoadPluginSilently(const char *filename)
defines the core interface for any ParaView plugin.
Definition: vtkPVPlugin.h:50
Used to load ParaView plugins.
bool(* vtkPluginLoadFunction)(const char *)
static class VTKPVCLIENTSERVERCORECORE_EXPORT vtkPVPluginLoaderCleanerInitializer vtkPVPluginLoaderCleanerInitializerInstance
bool LoadPlugin(const char *filename)
Tries to the load the plugin given the path to the plugin file.