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 
49  static const char* GetBuiltinName() { return "builtin:"; }
50 
55  virtual const char* GetURI() { return vtkSMSession::GetBuiltinName(); }
56 
58 
61  vtkGetObjectMacro(SessionProxyManager, vtkSMSessionProxyManager);
63 
71  virtual int GetNumberOfProcesses(vtkTypeUInt32 servers);
72 
78  virtual bool IsMPIInitialized(vtkTypeUInt32 servers);
79 
80  //---------------------------------------------------------------------------
81  // API for Proxy Finder/ReNew
82  //---------------------------------------------------------------------------
83 
84  vtkGetObjectMacro(ProxyLocator, vtkSMProxyLocator);
85 
87  {
88  RENDERING_NOT_AVAILABLE = 0x00,
89  RENDERING_UNIFIED = 0x01,
90  RENDERING_SPLIT = 0x02
91  };
92 
100  virtual unsigned int GetRenderClientMode();
101 
102  //---------------------------------------------------------------------------
103  // Undo/Redo related API.
104  //---------------------------------------------------------------------------
105 
107 
113  vtkGetObjectMacro(StateLocator, vtkSMStateLocator);
115 
116  //---------------------------------------------------------------------------
117  // Superclass Implementations
118  //---------------------------------------------------------------------------
119 
123  bool GetIsAlive() override { return true; }
124 
132  ServerFlags GetProcessRoles() override;
133 
138  void PushState(vtkSMMessage* msg) override;
139 
143  void NotifyAllClients(const vtkSMMessage* msg) override { this->ProcessNotification(msg); }
144 
148  void NotifyOtherClients(const vtkSMMessage*) override
149  { /* nothing to do. */
150  }
151 
152  //---------------------------------------------------------------------------
153  // API for Collaboration management
154  //---------------------------------------------------------------------------
155 
156  // Called before application quit or session disconnection
157  virtual void PreDisconnection() {}
158 
159  //---------------------------------------------------------------------------
160  // Static methods to create and register sessions easily.
161  //---------------------------------------------------------------------------
162 
169  static vtkIdType ConnectToCatalyst();
170 
172 
178  static vtkIdType ConnectToSelf();
180 
182 
193  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60)
194  {
196  return vtkSMSession::ConnectToRemote(hostname, port, timeout, nullptr, result);
197  }
198  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout, bool (*callback)(),
201 
203 
213  {
215  }
216  static vtkIdType ReverseConnectToRemoteWithTimeout(int port, int timeout)
217  {
219  return vtkSMSession::ReverseConnectToRemote(port, timeout, nullptr, result);
220  }
221  static vtkIdType ReverseConnectToRemote(
222  int port, int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
224 
226 
238  const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60)
239  {
241  return vtkSMSession::ConnectToRemote(dshost, dsport, rshost, rsport, timeout, nullptr, result);
242  }
243  static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport,
244  int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
246 
248 
257  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
258  {
259  return vtkSMSession::ReverseConnectToRemoteWithTimeout(dsport, rsport, 60);
260  }
261  static vtkIdType ReverseConnectToRemoteWithTimeout(int dsport, int rsport, int timeout)
262  {
264  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, timeout, nullptr, result);
265  }
266  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, int timeout, bool (*callback)(),
269 
271 
277  static void Disconnect(vtkIdType sessionid);
278  static void Disconnect(vtkSMSession* session);
280 
281 protected:
282  // Subclasses should set initialize_during_constructor to false so that
283  // this->Initialize() is not called in constructor but only after the session
284  // has been created/setup correctly.
285  vtkSMSession(
286  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = nullptr);
287  ~vtkSMSession() override;
288 
293  virtual void ProcessNotification(const vtkSMMessage*);
294 
299  virtual void Initialize();
300 
306  void UpdateStateHistory(vtkSMMessage* msg);
307 
311 
312 private:
313  vtkSMSession(const vtkSMSession&) = delete;
314  void operator=(const vtkSMSession&) = delete;
315 };
316 
317 #endif
virtual const char * GetURI()
Return the URL that define where the session is connected to.
Definition: vtkSMSession.h:55
void NotifyAllClients(const vtkSMMessage *msg) override
Sends the message to all clients.
Definition: vtkSMSession.h:143
bool GetIsAlive() override
Builtin session is always alive.
Definition: vtkSMSession.h:123
void NotifyOtherClients(const vtkSMMessage *) override
Sends the message to all but the active client-session.
Definition: vtkSMSession.h:148
#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.
static const char * GetBuiltinName()
Get the URI name for the builtin session.
Definition: vtkSMSession.h:49
vtkPVSessionCore is used by vtkSMSession.
virtual void PreDisconnection()
Definition: vtkSMSession.h:157
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:216
vtkSMProxyLocator * ProxyLocator
Definition: vtkSMSession.h:310
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:261
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:309
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:193
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:237
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:308
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:212
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:257
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.