vtkSMSession.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
10 #ifndef vtkSMSession_h
11 #define vtkSMSession_h
12 
13 #include "vtkNetworkAccessManager.h" // needed for vtkNetworkAccessManager::ConnectionResult.
14 #include "vtkPVSessionBase.h"
15 #include "vtkRemotingServerManagerModule.h" //needed for exports
16 
18 class vtkSMProxyLocator;
20 class vtkSMStateLocator;
21 
23 {
24 public:
25  static vtkSMSession* New();
26  static vtkSMSession* New(vtkPVSessionBase* otherSession);
27  static vtkSMSession* New(vtkPVSessionCore* otherSessionCore);
29  void PrintSelf(ostream& os, vtkIndent indent) override;
30 
31  //---------------------------------------------------------------------------
32  // API for collaboration management
33  //---------------------------------------------------------------------------
34 
40  virtual vtkSMCollaborationManager* GetCollaborationManager() { return nullptr; }
41 
42  //---------------------------------------------------------------------------
43  // API for client-side components of a session.
44  //---------------------------------------------------------------------------
45 
50  virtual const char* GetURI() { return "builtin:"; }
51 
53 
56  vtkGetObjectMacro(SessionProxyManager, vtkSMSessionProxyManager);
58 
66  virtual int GetNumberOfProcesses(vtkTypeUInt32 servers);
67 
73  virtual bool IsMPIInitialized(vtkTypeUInt32 servers);
74 
75  //---------------------------------------------------------------------------
76  // API for Proxy Finder/ReNew
77  //---------------------------------------------------------------------------
78 
79  vtkGetObjectMacro(ProxyLocator, vtkSMProxyLocator);
80 
82  {
83  RENDERING_NOT_AVAILABLE = 0x00,
84  RENDERING_UNIFIED = 0x01,
85  RENDERING_SPLIT = 0x02
86  };
87 
95  virtual unsigned int GetRenderClientMode();
96 
97  //---------------------------------------------------------------------------
98  // Undo/Redo related API.
99  //---------------------------------------------------------------------------
100 
102 
108  vtkGetObjectMacro(StateLocator, vtkSMStateLocator);
110 
111  //---------------------------------------------------------------------------
112  // Superclass Implementations
113  //---------------------------------------------------------------------------
114 
118  bool GetIsAlive() override { return true; }
119 
127  ServerFlags GetProcessRoles() override;
128 
133  void PushState(vtkSMMessage* msg) override;
134 
138  void NotifyAllClients(const vtkSMMessage* msg) override { this->ProcessNotification(msg); }
139 
143  void NotifyOtherClients(const vtkSMMessage*) override
144  { /* nothing to do. */
145  }
146 
147  //---------------------------------------------------------------------------
148  // API for Collaboration management
149  //---------------------------------------------------------------------------
150 
151  // Called before application quit or session disconnection
152  virtual void PreDisconnection() {}
153 
154  //---------------------------------------------------------------------------
155  // Static methods to create and register sessions easily.
156  //---------------------------------------------------------------------------
157 
164  static vtkIdType ConnectToCatalyst();
165 
167 
173  static vtkIdType ConnectToSelf();
175 
177 
188  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60)
189  {
191  return vtkSMSession::ConnectToRemote(hostname, port, timeout, nullptr, result);
192  }
193  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout, bool (*callback)(),
196 
198 
208  {
210  }
211  static vtkIdType ReverseConnectToRemoteWithTimeout(int port, int timeout)
212  {
214  return vtkSMSession::ReverseConnectToRemote(port, timeout, nullptr, result);
215  }
216  static vtkIdType ReverseConnectToRemote(
217  int port, int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
219 
221 
233  const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60)
234  {
236  return vtkSMSession::ConnectToRemote(dshost, dsport, rshost, rsport, timeout, nullptr, result);
237  }
238  static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport,
239  int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
241 
243 
252  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
253  {
254  return vtkSMSession::ReverseConnectToRemoteWithTimeout(dsport, rsport, 60);
255  }
256  static vtkIdType ReverseConnectToRemoteWithTimeout(int dsport, int rsport, int timeout)
257  {
259  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, timeout, nullptr, result);
260  }
261  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, int timeout, bool (*callback)(),
264 
266 
272  static void Disconnect(vtkIdType sessionid);
273  static void Disconnect(vtkSMSession* session);
275 
276 protected:
277  // Subclasses should set initialize_during_constructor to false so that
278  // this->Initialize() is not called in constructor but only after the session
279  // has been created/setup correctly.
280  vtkSMSession(
281  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = nullptr);
282  ~vtkSMSession() override;
283 
288  virtual void ProcessNotification(const vtkSMMessage*);
289 
294  virtual void Initialize();
295 
301  void UpdateStateHistory(vtkSMMessage* msg);
302 
306 
307 private:
308  vtkSMSession(const vtkSMSession&) = delete;
309  void operator=(const vtkSMSession&) = delete;
310 };
311 
312 #endif
virtual const char * GetURI()
Return the URL that define where the session is connected to.
Definition: vtkSMSession.h:50
void NotifyAllClients(const vtkSMMessage *msg) override
Sends the message to all clients.
Definition: vtkSMSession.h:138
bool GetIsAlive() override
Builtin session is always alive.
Definition: vtkSMSession.h:118
void NotifyOtherClients(const vtkSMMessage *) override
Sends the message to all but the active client-session.
Definition: vtkSMSession.h:143
#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:40
vtkSMSession is the default ParaView session.
Definition: vtkSMSession.h:22
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:152
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:211
vtkSMProxyLocator * ProxyLocator
Definition: vtkSMSession.h:305
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:256
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:304
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:188
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:232
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:303
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:207
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:252
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.