vtkSMSession.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
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 =========================================================================*/
22 #ifndef vtkSMSession_h
23 #define vtkSMSession_h
24 
25 #include "vtkNetworkAccessManager.h" // needed for vtkNetworkAccessManager::ConnectionResult.
26 #include "vtkPVSessionBase.h"
27 #include "vtkParaViewDeprecation.h" // for PARAVIEW_DEPRECATED_IN_5_10_0
28 #include "vtkRemotingServerManagerModule.h" //needed for exports
29 
31 class vtkSMProxyLocator;
33 class vtkSMStateLocator;
34 
36 {
37 public:
38  static vtkSMSession* New();
39  static vtkSMSession* New(vtkPVSessionBase* otherSession);
40  static vtkSMSession* New(vtkPVSessionCore* otherSessionCore);
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
44  //---------------------------------------------------------------------------
45  // API for collaboration management
46  //---------------------------------------------------------------------------
47 
53  virtual vtkSMCollaborationManager* GetCollaborationManager() { return nullptr; }
54 
55  //---------------------------------------------------------------------------
56  // API for client-side components of a session.
57  //---------------------------------------------------------------------------
58 
63  virtual const char* GetURI() { return "builtin:"; }
64 
66 
69  vtkGetObjectMacro(SessionProxyManager, vtkSMSessionProxyManager);
71 
79  virtual int GetNumberOfProcesses(vtkTypeUInt32 servers);
80 
86  virtual bool IsMPIInitialized(vtkTypeUInt32 servers);
87 
88  //---------------------------------------------------------------------------
89  // API for Proxy Finder/ReNew
90  //---------------------------------------------------------------------------
91 
92  vtkGetObjectMacro(ProxyLocator, vtkSMProxyLocator);
93 
95  {
96  RENDERING_NOT_AVAILABLE = 0x00,
97  RENDERING_UNIFIED = 0x01,
98  RENDERING_SPLIT = 0x02
99  };
100 
108  virtual unsigned int GetRenderClientMode();
109 
110  //---------------------------------------------------------------------------
111  // Undo/Redo related API.
112  //---------------------------------------------------------------------------
113 
115 
121  vtkGetObjectMacro(StateLocator, vtkSMStateLocator);
123 
124  //---------------------------------------------------------------------------
125  // Superclass Implementations
126  //---------------------------------------------------------------------------
127 
131  bool GetIsAlive() override { return true; }
132 
140  ServerFlags GetProcessRoles() override;
141 
146  void PushState(vtkSMMessage* msg) override;
147 
151  void NotifyAllClients(const vtkSMMessage* msg) override { this->ProcessNotification(msg); }
152 
156  void NotifyOtherClients(const vtkSMMessage*) override
157  { /* nothing to do. */
158  }
159 
160  //---------------------------------------------------------------------------
161  // API for Collaboration management
162  //---------------------------------------------------------------------------
163 
164  // Called before application quit or session disconnection
165  virtual void PreDisconnection() {}
166 
167  //---------------------------------------------------------------------------
168  // Static methods to create and register sessions easily.
169  //---------------------------------------------------------------------------
170 
177  static vtkIdType ConnectToCatalyst();
178 
180 
186  static vtkIdType ConnectToSelf();
188 
190 
201  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60)
202  {
204  return vtkSMSession::ConnectToRemote(hostname, port, timeout, nullptr, result);
205  }
206  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout, bool (*callback)(),
209 
211 
221  {
223  }
224  static vtkIdType ReverseConnectToRemoteWithTimeout(int port, int timeout)
225  {
227  return vtkSMSession::ReverseConnectToRemote(port, timeout, nullptr, result);
228  }
229  static vtkIdType ReverseConnectToRemote(
230  int port, int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
232 
234 
246  const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60)
247  {
249  return vtkSMSession::ConnectToRemote(dshost, dsport, rshost, rsport, timeout, nullptr, result);
250  }
251  static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport,
252  int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
254 
256 
265  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
266  {
267  return vtkSMSession::ReverseConnectToRemoteWithTimeout(dsport, rsport, 60);
268  }
269  static vtkIdType ReverseConnectToRemoteWithTimeout(int dsport, int rsport, int timeout)
270  {
272  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, timeout, nullptr, result);
273  }
274  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, int timeout, bool (*callback)(),
277 
279 
285  static void Disconnect(vtkIdType sessionid);
286  static void Disconnect(vtkSMSession* session);
288 
290 
294  PARAVIEW_DEPRECATED_IN_5_10_0("AutoMPI is no longer supported")
295  bool GetIsAutoMPI() const;
297 
298 protected:
299  // Subclasses should set initialize_during_constructor to false so that
300  // this->Initialize() is not called in constructor but only after the session
301  // has been created/setup correctly.
302  vtkSMSession(
303  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = nullptr);
304  ~vtkSMSession() override;
305 
310  virtual void ProcessNotification(const vtkSMMessage*);
311 
316  virtual void Initialize();
317 
323  void UpdateStateHistory(vtkSMMessage* msg);
324 
328 
329 private:
330  vtkSMSession(const vtkSMSession&) = delete;
331  void operator=(const vtkSMSession&) = delete;
332 };
333 
334 #endif
virtual const char * GetURI()
Return the URL that define where the session is connected to.
Definition: vtkSMSession.h:63
void NotifyAllClients(const vtkSMMessage *msg) override
Sends the message to all clients.
Definition: vtkSMSession.h:151
#define PARAVIEW_DEPRECATED_IN_5_10_0(reason)
bool GetIsAlive() override
Builtin session is always alive.
Definition: vtkSMSession.h:131
void NotifyOtherClients(const vtkSMMessage *) override
Sends the message to all but the active client-session.
Definition: vtkSMSession.h:156
#define VTKREMOTINGSERVERMANAGER_EXPORT
virtual void PushState(vtkSMMessage *msg)
Push the state message.
virtual vtkSMCollaborationManager * GetCollaborationManager()
Return the instance of vtkSMCollaborationManager that will be lazy created at the first call...
Definition: vtkSMSession.h:53
vtkSMSession is the default ParaView session.
Definition: vtkSMSession.h:35
void PrintSelf(ostream &os, vtkIndent indent) override
int vtkIdType
Class used to broadcast message from one client to the others.
vtkPVSessionCore is used by vtkSMSession.
virtual void PreDisconnection()
Definition: vtkSMSession.h:165
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
static vtkIdType ReverseConnectToRemoteWithTimeout(int port, int timeout)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:224
vtkSMProxyLocator * ProxyLocator
Definition: vtkSMSession.h:327
static vtkIdType ReverseConnectToRemoteWithTimeout(int dsport, int rsport, int timeout)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:269
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:326
static vtkIdType ConnectToRemote(const char *hostname, int port, int timeout=60)
These are static helper methods that help create standard ParaView sessions.
Definition: vtkSMSession.h:201
is used to locate proxies referred to in state xmls while loading state files.
static vtkIdType ConnectToRemote(const char *dshost, int dsport, const char *rshost, int rsport, int timeout=60)
These are static helper methods that help create standard ParaView sessions.
Definition: vtkSMSession.h:245
ServerFlags GetProcessRoles() override
Returns a ServerFlags indicate the nature of the current processes.
Abstract class used to provide the main implementation of the ParaView session methods for the follow...
port
vtkSMSessionProxyManager * SessionProxyManager
Definition: vtkSMSession.h:325
static vtkObject * New()
static vtkIdType ReverseConnectToRemote(int port)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:220
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:265
ConnectionResult
Possible result of connection when creating a new connection CONNECTION_SUCCESS: Connection was suces...
Class used to retrieve a given message state based on its GlobalID.