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 "vtkPVSessionBase.h"
26 #include "vtkRemotingServerManagerModule.h" //needed for exports
27 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
28 
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 
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 { /* nothing to do. */}
157 
158  //---------------------------------------------------------------------------
159  // API for Collaboration management
160  //---------------------------------------------------------------------------
161 
162  // Called before application quit or session disconnection
163  virtual void PreDisconnection() {}
164 
165  //---------------------------------------------------------------------------
166  // Static methods to create and register sessions easily.
167  //---------------------------------------------------------------------------
168 
175  static vtkIdType ConnectToCatalyst();
176 
184  static vtkIdType ConnectToSelf(int timeout = 60);
185 
193  static vtkIdType ConnectToRemote(const char* hostname, int port, int timeout = 60);
194 
203  {
204  return vtkSMSession::ReverseConnectToRemote(port, (bool (*)())NULL);
205  }
206  static vtkIdType ReverseConnectToRemote(int port, bool (*callback)());
207 
215  static vtkIdType ConnectToRemote(
216  const char* dshost, int dsport, const char* rshost, int rsport, int timeout = 60);
217 
225  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
226  {
227  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, NULL);
228  }
229  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, bool (*callback)());
230 
232 
238  static void Disconnect(vtkIdType sessionid);
239  static void Disconnect(vtkSMSession* session);
241 
243 
248  vtkGetMacro(IsAutoMPI, bool);
250 
251 protected:
252  // Subclasses should set initialize_during_constructor to false so that
253  // this->Initialize() is not called in constructor but only after the session
254  // has been created/setup correctly.
255  vtkSMSession(
256  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = NULL);
257  ~vtkSMSession() override;
258 
262  static vtkIdType ConnectToRemoteInternal(
263  const char* hostname, int port, bool is_auto_mpi, int timeout = 60);
264 
269  virtual void ProcessNotification(const vtkSMMessage*);
270 
275  virtual void Initialize();
276 
282  void UpdateStateHistory(vtkSMMessage* msg);
283 
287 
288  bool IsAutoMPI;
289 
290 private:
291  vtkSMSession(const vtkSMSession&) = delete;
292  void operator=(const vtkSMSession&) = delete;
293 
294  // AutoMPI helper class
296 };
297 
298 #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
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:163
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
vtkSMProxyLocator * ProxyLocator
Definition: vtkSMSession.h:286
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:285
is used to locate proxies referred to in state xmls while loading state files.
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:284
static vtkObject * New()
static vtkIdType ReverseConnectToRemote(int port)
Same as ConnectToRemote() except that it waits for a reverse connection.
Definition: vtkSMSession.h:202
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection.
Definition: vtkSMSession.h:225
Class used to retrieve a given message state based on its GlobalID.