vtkSMProxyManager.h 6.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*=========================================================================

  Program:   ParaView
  Module:    vtkSMProxyManager.h

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
15 16 17 18 19 20 21 22 23 24
/**
 * @class   vtkSMProxyManager
 * @brief   singleton/facade to vtkSMSessionProxyManager
 *
 * vtkSMProxyManager is a singleton/facade that creates and manages proxies.
 * It maintains a map of vtkSMSessionProxyManager and delegate all proxy related
 * call to the appropriate one based on the provided session.
 * @sa
 * vtkSMSessionProxyManager, vtkSMProxyDefinitionManager
*/
25

26 27
#ifndef vtkSMProxyManager_h
#define vtkSMProxyManager_h
28

29
#include "vtkPVServerManagerCoreModule.h" //needed for exports
30 31 32 33
#include "vtkSMObject.h"
#include "vtkSmartPointer.h" // Needed for the singleton

class vtkPVXMLElement;
34
class vtkSMPluginManager;
35 36 37
class vtkSMProxy;
class vtkSMProxyLocator;
class vtkSMProxySelectionModel;
38
class vtkSMReaderFactory;
39
class vtkSMSession;
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
40
class vtkSMSessionProxyManager;
41
class vtkSMStateLoader;
42
class vtkSMUndoStackBuilder;
43
class vtkSMWriterFactory;
44

45
class VTKPVSERVERMANAGERCORE_EXPORT vtkSMProxyManager : public vtkSMObject
46 47
{
public:
48
  vtkTypeMacro(vtkSMProxyManager, vtkSMObject);
49
  void PrintSelf(ostream& os, vtkIndent indent) override;
50

51 52 53
  /**
   * Provides access to the global ProxyManager.
   */
54 55
  static vtkSMProxyManager* GetProxyManager();

56 57 58
  /**
   * Free the singleton
   */
59 60
  static void Finalize();

61 62 63 64
  /**
   * Allow to check if the Singleton has been initialized and has a reference
   * to a valid ProxyManager
   */
65 66
  static bool IsInitialized();

67 68 69 70 71
  /**
   * These methods can be used to obtain the ProxyManager version number.
   * Returns the major version number eg. if version is 2.9.1
   * this method will return 2.
   */
72 73
  static int GetVersionMajor();

74 75 76 77 78
  /**
   * These methods can be used to obtain the ProxyManager version number.
   * Returns the minor version number eg. if version is 2.9.1
   * this method will return 9.
   */
79 80
  static int GetVersionMinor();

81 82 83 84 85
  /**
   * These methods can be used to obtain the ProxyManager version number.
   * Returns the patch version number eg. if version is 2.9.1
   * this method will return 1.
   */
86 87
  static int GetVersionPatch();

88 89 90
  /**
   * Returns a string with the format "paraview version x.x.x, Date: YYYY-MM-DD"
   */
91 92
  static const char* GetParaViewSourceVersion();

93 94 95 96 97
  /**
   * Returns the current active session. If no active session is set, and
   * there's only one registered vtkSMSession with vtkProcessModule, then that
   * session is automatically treated as the active session.
   */
98 99
  vtkSMSession* GetActiveSession();

100 101 102 103 104 105
  //@{
  /**
   * Set the active session. It's acceptable to set the active session as NULL
   * (or 0 in case of sessionId), however GetActiveSession() may automatically
   * pick an active session if none is provided.
   */
106
  void SetActiveSession(vtkSMSession* session);
107
  void SetActiveSession(vtkIdType sessionId);
108
  //@}
109

110 111 112
  /**
   * Convenient method to get the active vtkSMSessionProxyManager. If no
   */
113 114
  vtkSMSessionProxyManager* GetActiveSessionProxyManager();

115 116 117 118
  /**
   * Return the corresponding vtkSMSessionProxyManager and if any,
   * then create a new one.
   */
119 120
  vtkSMSessionProxyManager* GetSessionProxyManager(vtkSMSession* session);

121 122 123 124 125 126
  //@{
  /**
   * Calls forwarded to the active vtkSMSessionProxyManager, if any. Raises
   * errors if no active session manager can be determined (using
   * GetActiveSessionProxyManager()).
   */
Kitware Robot's avatar
Kitware Robot committed
127 128
  vtkSMProxy* NewProxy(
    const char* groupName, const char* proxyName, const char* subProxyName = NULL);
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
129 130 131
  void RegisterProxy(const char* groupname, const char* name, vtkSMProxy* proxy);
  vtkSMProxy* GetProxy(const char* groupname, const char* name);
  void UnRegisterProxy(const char* groupname, const char* name, vtkSMProxy*);
Sebastien Jourdain's avatar
Sebastien Jourdain committed
132 133
  const char* GetProxyName(const char* groupname, unsigned int idx);
  const char* GetProxyName(const char* groupname, vtkSMProxy* proxy);
134
  //@}
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
135

136 137 138 139 140
  //@{
  /**
   * Get/Set the undo-stack builder if the application is using undo-redo
   * mechanism to track changes.
   */
141 142
  void SetUndoStackBuilder(vtkSMUndoStackBuilder* builder);
  vtkGetObjectMacro(UndoStackBuilder, vtkSMUndoStackBuilder);
143
  //@}
144

145 146 147 148 149
  //@{
  /**
   * PluginManager keeps track of plugins loaded on various sessions.
   * This provides access to the application-wide plugin manager.
   */
150
  vtkGetObjectMacro(PluginManager, vtkSMPluginManager);
151
  //@}
152

153 154 155 156 157
  //@{
  /**
   * Provides access to the reader factory. Before using the reader factory, it
   * is essential that it's configured correctly.
   */
158
  vtkGetObjectMacro(ReaderFactory, vtkSMReaderFactory);
159
  //@}
160

161 162 163 164 165
  //@{
  /**
   * Provides access to the writer factory. Before using the reader factory, it
   * is essential that it's configured correctly.
   */
166
  vtkGetObjectMacro(WriterFactory, vtkSMWriterFactory);
167
  //@}
168

169
  enum eventId
Kitware Robot's avatar
Kitware Robot committed
170
  {
171
    ActiveSessionChanged = 9753
Kitware Robot's avatar
Kitware Robot committed
172
  };
173

174 175 176 177 178 179 180 181 182 183
  struct RegisteredProxyInformation
  {
    vtkSMProxy* Proxy;
    const char* GroupName;
    const char* ProxyName;
    // Set when the register/unregister event if fired for registration of
    // a compound proxy definition.
    unsigned int Type;

    enum
Kitware Robot's avatar
Kitware Robot committed
184 185
    {
      PROXY = 0x1,
186 187
      COMPOUND_PROXY_DEFINITION = 0x2,
      LINK = 0x3,
Kitware Robot's avatar
Kitware Robot committed
188
    };
189 190 191
  };

  struct ModifiedPropertyInformation
Kitware Robot's avatar
Kitware Robot committed
192
  {
193 194
    vtkSMProxy* Proxy;
    const char* PropertyName;
Kitware Robot's avatar
Kitware Robot committed
195
  };
196 197

  struct LoadStateInformation
Kitware Robot's avatar
Kitware Robot committed
198
  {
199 200
    vtkPVXMLElement* RootElement;
    vtkSMProxyLocator* ProxyLocator;
Kitware Robot's avatar
Kitware Robot committed
201
  };
202 203

  struct StateChangedInformation
Kitware Robot's avatar
Kitware Robot committed
204
  {
205 206
    vtkSMProxy* Proxy;
    vtkPVXMLElement* StateChangeElement;
Kitware Robot's avatar
Kitware Robot committed
207
  };
208 209 210

protected:
  vtkSMProxyManager();
211
  ~vtkSMProxyManager() override;
212
#ifndef __WRAP__
213
  static vtkSMProxyManager* New();
214
#endif
215

216 217
  friend class vtkSMSessionProxyManager;

218 219 220
  /**
   * Connections updated. Update the active session accordingly.
   */
221 222
  void ConnectionsUpdated(vtkObject*, unsigned long, void*);

223
  vtkSMUndoStackBuilder* UndoStackBuilder;
224
  vtkSMPluginManager* PluginManager;
225 226
  vtkSMReaderFactory* ReaderFactory;
  vtkSMWriterFactory* WriterFactory;
227

228 229 230 231 232 233
private:
  class vtkPXMInternal;
  vtkPXMInternal* PXMStorage;

  static vtkSmartPointer<vtkSMProxyManager> Singleton;

234 235
  vtkSMProxyManager(const vtkSMProxyManager&) = delete;
  void operator=(const vtkSMProxyManager&) = delete;
236 237 238
};

#endif