pqPluginManager.h 5.08 KB
Newer Older
Berk Geveci's avatar
Berk Geveci committed
1
2
/*=========================================================================

Andy Cedilnik's avatar
Andy Cedilnik committed
3
   Program: ParaView
4
   Module:    pqPluginManager.h
Berk Geveci's avatar
Berk Geveci committed
5

6
   Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
Berk Geveci's avatar
Berk Geveci committed
7
8
   All rights reserved.

Andy Cedilnik's avatar
Andy Cedilnik committed
9
   ParaView is a free software; you can redistribute it and/or modify it
Kitware Robot's avatar
Kitware Robot committed
10
   under the terms of the ParaView license version 1.2.
Berk Geveci's avatar
Berk Geveci committed
11

12
   See License_v1.2.txt for the full ParaView license.
Berk Geveci's avatar
Berk Geveci committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
   A copy of this license can be obtained by contacting
   Kitware Inc.
   28 Corporate Drive
   Clifton Park, NY 12065
   USA

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=========================================================================*/
Clinton Stimpson's avatar
   
Clinton Stimpson committed
32

33
34
#ifndef _pqPluginManager_h
#define _pqPluginManager_h
Clinton Stimpson's avatar
   
Clinton Stimpson committed
35

36
#include "pqCoreModule.h"
Clinton Stimpson's avatar
   
Clinton Stimpson committed
37
#include <QObject>
38
#include <QStringList>
39
40

class pqServer;
41
class vtkPVPlugin;
42
class vtkPVPluginsInformation;
43
class vtkSMPluginManager;
44

45
46
47
48
49
50
51
52
53
54
55
/**
* pqPluginManager works with vtkSMPluginManager to keep track for plugins
* loaded/available. It also ensures that when a new session is created, the
* default plugin-configuration-xmls are parsed on all processes involved to
* ensure that auto-load plugins are loaded. It preserves the information about
* plugins loaded across ParaView sessions in settings so that users can easily
* load previously loaded plugins.
*
* pqPluginManager can work with multiple sessions. It maintains internal
* data-structures for different sessions.
*/
56
class PQCORE_EXPORT pqPluginManager : public QObject
Clinton Stimpson's avatar
   
Clinton Stimpson committed
57
58
{
  Q_OBJECT
59
  typedef QObject Superclass;
Kitware Robot's avatar
Kitware Robot committed
60

Clinton Stimpson's avatar
   
Clinton Stimpson committed
61
public:
62
  pqPluginManager(QObject* p = 0);
Ben Boeckel's avatar
Ben Boeckel committed
63
  ~pqPluginManager() override;
64

65
66
67
68
69
70
71
  /**
  * Called during application initialization to load plugins from settings.
  * This only loads "local" plugins. pqApplicationCore calls this method
  * explicitly after the essential components of the core have been
  * initialized. This ensures that any plugins  being loaded during startup of
  * application have the environment setup correctly.
  */
72
73
  void loadPluginsFromSettings();

Kitware Robot's avatar
Kitware Robot committed
74
75
76
77
78
79
  enum LoadStatus
  {
    LOADED,
    NOTLOADED,
    ALREADYLOADED
  };
Clinton Stimpson's avatar
   
Clinton Stimpson committed
80

81
82
83
84
85
86
87
  /**
  * attempt to load an extension on a server
  * if server is NULL, extension will be loaded on client side
  * return status on success, if NOTLOADED was returned, the error is reported
  * If errorMsg is non-null, then errors are not reported, but the error
  * message is put in the errorMsg string
  */
Kitware Robot's avatar
Kitware Robot committed
88
89
  LoadStatus loadExtension(
    pqServer* session, const QString& lib, QString* errorMsg = 0, bool remote = true);
90

91
  /**
Kitware Robot's avatar
Kitware Robot committed
92
  * attempt to load all available plugins on a server,
93
94
  * or client plugins if NULL
  */
Clinton Stimpson's avatar
   
Clinton Stimpson committed
95
  void loadExtensions(pqServer*);
96

97
98
99
100
101
  /**
  * return all the plugins loaded on a session. This will either returns the
  * plugins information for local processes or server-process (for remote
  * sessions) based on the state of \c remote.
  */
102
  vtkPVPluginsInformation* loadedExtensions(pqServer* session, bool remote);
103

104
105
106
  /**
  * Return all the paths that plugins will be searched for.
  */
107
  QStringList pluginPaths(pqServer* session, bool remote);
Clinton Stimpson's avatar
   
Clinton Stimpson committed
108

109
110
111
112
  /**
  * simply adds the plugin to the ignore list, so when this class tries to
  * serialize the plugin information, it skips the indicated plugin.
  */
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
113
114
115
  void hidePlugin(const QString& lib, bool remote);
  bool isHidden(const QString& lib, bool remote);

116
117
118
119
120
  /**
  * ensures that plugins required on client and server are present on both.
  * Fires requiredPluginsNotLoaded() signal if any mismatch is found.
  * Returns true is all plugin requirements are satisfied, else returns false.
  */
121
  bool verifyPlugins(pqServer* session);
122

123
Q_SIGNALS:
124
125
126
  /**
  * notification when plugin has been loaded.
  */
127
  void pluginsUpdated();
128

129
130
131
132
  /**
  * notification that the plugins on the client and
  * server are mismatched.
  */
133
  void requiredPluginsNotLoaded(pqServer*);
134

135
136
137
138
139
  /**
   * Fired when the last set of autoload plugins are loaded during program initialization.
   */
  void initialPluginsLoaded();

140
protected:
141
142
  void initialize(vtkSMPluginManager*);

143
protected Q_SLOTS:
144
145
146
  /**
  * attempts to load the configuration for plugins for the particular server.
  */
147
148
  void loadPluginsFromSettings(pqServer*);

149
150
  void onServerConnected(pqServer*);
  void onServerDisconnected(pqServer*);
151
  void updatePluginLists();
152

153
154
155
private:
  class pqInternals;
  pqInternals* Internals;
156
157
158
159
160
161

  /**
   * Callback passed on to `vtkPVPluginLoader::SetEULAConfirmationCallback` to
   * confirm EULA for locally loaded plugins.
   */
  static bool confirmEULA(vtkPVPlugin* plugin);
Clinton Stimpson's avatar
   
Clinton Stimpson committed
162
163
164
};

#endif