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 "vtkRemotingServerManagerModule.h" //needed for exports
28 
30 class vtkSMProxyLocator;
32 class vtkSMStateLocator;
33 
35 {
36 public:
37  static vtkSMSession* New();
38  static vtkSMSession* New(vtkPVSessionBase* otherSession);
39  static vtkSMSession* New(vtkPVSessionCore* otherSessionCore);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
43  //---------------------------------------------------------------------------
44  // API for collaboration management
45  //---------------------------------------------------------------------------
46 
52  virtual vtkSMCollaborationManager* GetCollaborationManager() { return nullptr; }
53 
54  //---------------------------------------------------------------------------
55  // API for client-side components of a session.
56  //---------------------------------------------------------------------------
57 
62  virtual const char* GetURI() { return "builtin:"; }
63 
65 
68  vtkGetObjectMacro(SessionProxyManager, vtkSMSessionProxyManager);
70 
78  virtual int GetNumberOfProcesses(vtkTypeUInt32 servers);
79 
85  virtual bool IsMPIInitialized(vtkTypeUInt32 servers);
86 
87  //---------------------------------------------------------------------------
88  // API for Proxy Finder/ReNew
89  //---------------------------------------------------------------------------
90 
91  vtkGetObjectMacro(ProxyLocator, vtkSMProxyLocator);
92 
94  {
95  RENDERING_NOT_AVAILABLE = 0x00,
96  RENDERING_UNIFIED = 0x01,
97  RENDERING_SPLIT = 0x02
98  };
99 
107  virtual unsigned int GetRenderClientMode();
108 
109  //---------------------------------------------------------------------------
110  // Undo/Redo related API.
111  //---------------------------------------------------------------------------
112 
114 
120  vtkGetObjectMacro(StateLocator, vtkSMStateLocator);
122 
123  //---------------------------------------------------------------------------
124  // Superclass Implementations
125  //---------------------------------------------------------------------------
126 
130  bool GetIsAlive() override { return true; }
131 
139  ServerFlags GetProcessRoles() override;
140 
145  void PushState(vtkSMMessage* msg) override;
146 
150  void NotifyAllClients(const vtkSMMessage* msg) override { this->ProcessNotification(msg); }
151 
155  void NotifyOtherClients(const vtkSMMessage*) override
156  { /* nothing to do. */
157  }
158 
159  //---------------------------------------------------------------------------
160  // API for Collaboration management
161  //---------------------------------------------------------------------------
162 
163  // Called before application quit or session disconnection
164  virtual void PreDisconnection() {}
165 
166  //---------------------------------------------------------------------------
167  // Static methods to create and register sessions easily.
168  //---------------------------------------------------------------------------
169 
176  static vtkIdType ConnectToCatalyst();
177 
179 
185  static vtkIdType ConnectToSelf();
187 
189 
200  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60)
201  {
203  return vtkSMSession::ConnectToRemote(hostname, port, timeout, nullptr, result);
204  }
205  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout, bool (*callback)(),
208 
210 
220  {
222  }
223  static vtkIdType ReverseConnectToRemoteWithTimeout(int port, int timeout)
224  {
226  return vtkSMSession::ReverseConnectToRemote(port, timeout, nullptr, result);
227  }
228  static vtkIdType ReverseConnectToRemote(
229  int port, int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
231 
233 
245  const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60)
246  {
248  return vtkSMSession::ConnectToRemote(dshost, dsport, rshost, rsport, timeout, nullptr, result);
249  }
250  static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport,
251  int timeout, bool (*callback)(), vtkNetworkAccessManager::ConnectionResult& result);
253 
255 
264  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
265  {
266  return vtkSMSession::ReverseConnectToRemoteWithTimeout(dsport, rsport, 60);
267  }
268  static vtkIdType ReverseConnectToRemoteWithTimeout(int dsport, int rsport, int timeout)
269  {
271  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, timeout, nullptr, result);
272  }
273  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, int timeout, bool (*callback)(),
276 
278 
284  static void Disconnect(vtkIdType sessionid);
285  static void Disconnect(vtkSMSession* session);
287 
288 protected:
289  // Subclasses should set initialize_during_constructor to false so that
290  // this->Initialize() is not called in constructor but only after the session
291  // has been created/setup correctly.
292  vtkSMSession(
293  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = nullptr);
294  ~vtkSMSession() override;
295 
300  virtual void ProcessNotification(const vtkSMMessage*);
301 
306  virtual void Initialize();
307 
313  void UpdateStateHistory(vtkSMMessage* msg);
314 
318 
319 private:
320  vtkSMSession(const vtkSMSession&) = delete;
321  void operator=(const vtkSMSession&) = delete;
322 };
323 
324 #endif
virtual const char * GetURI()
Return the URL that define where the session is connected to.
Definition: vtkSMSession.h:62
void NotifyAllClients(const vtkSMMessage *msg) override
Sends the message to all clients.
Definition: vtkSMSession.h:150
bool GetIsAlive() override
Builtin session is always alive.
Definition: vtkSMSession.h:130
void NotifyOtherClients(const vtkSMMessage *) override
Sends the message to all but the active client-session.
Definition: vtkSMSession.h:155
#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:52
vtkSMSession is the default ParaView session.
Definition: vtkSMSession.h:34
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:164
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:223
vtkSMProxyLocator * ProxyLocator
Definition: vtkSMSession.h:317
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:268
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:316
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:200
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:244
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:315
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:219
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection for timeout seconds...
Definition: vtkSMSession.h:264
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.