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 { /* nothing to do. */ }
149 
150  //---------------------------------------------------------------------------
151  // API for Collaboration management
152  //---------------------------------------------------------------------------
153 
154  // Called before application quit or session disconnection
155  virtual void PreDisconnection() {}
156 
157  //---------------------------------------------------------------------------
158  // Static methods to create and register sessions easily.
159  //---------------------------------------------------------------------------
160 
167  static vtkIdType ConnectToCatalyst();
168 
170 
176  static vtkIdType ConnectToSelf();
178 
180 
191  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60)
192  {
194  return vtkSMSession::ConnectToRemote(hostname, port, timeout, nullptr, result);
195  }
196  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout, bool (*callback)(),
199 
201 
211  {
213  }
214  static vtkIdType ReverseConnectToRemoteWithTimeout(int port, int timeout)
215  {
217  return vtkSMSession::ReverseConnectToRemote(port, timeout, nullptr, result);
218  }
219  static vtkIdType ReverseConnectToRemote(
220  int port, int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
222 
224 
236  const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60)
237  {
239  return vtkSMSession::ConnectToRemote(dshost, dsport, rshost, rsport, timeout, nullptr, result);
240  }
241  static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport,
242  int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
244 
246 
255  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
256  {
257  return vtkSMSession::ReverseConnectToRemoteWithTimeout(dsport, rsport, 60);
258  }
259  static vtkIdType ReverseConnectToRemoteWithTimeout(int dsport, int rsport, int timeout)
260  {
262  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, timeout, nullptr, result);
263  }
264  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, int timeout, bool (*callback)(),
267 
269 
275  static void Disconnect(vtkIdType sessionid);
276  static void Disconnect(vtkSMSession* session);
278 
279 protected:
280  // Subclasses should set initialize_during_constructor to false so that
281  // this->Initialize() is not called in constructor but only after the session
282  // has been created/setup correctly.
283  vtkSMSession(
284  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = nullptr);
285  ~vtkSMSession() override;
286 
291  virtual void ProcessNotification(const vtkSMMessage*);
292 
297  virtual void Initialize();
298 
304  void UpdateStateHistory(vtkSMMessage* msg);
305 
309 
310 private:
311  vtkSMSession(const vtkSMSession&) = delete;
312  void operator=(const vtkSMSession&) = delete;
313 };
314 
315 #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:155
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:214
vtkSMProxyLocator * ProxyLocator
Definition: vtkSMSession.h:308
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:259
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:307
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:191
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:235
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:306
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:210
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:255
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.