ParaView
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 "vtkPVServerManagerCoreModule.h" //needed for exports
26 #include "vtkPVSessionBase.h"
27 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
28 
31 class vtkSMProxyLocator;
33 class vtkSMStateLocator;
34 
35 class VTKPVSERVERMANAGERCORE_EXPORT vtkSMSession : public vtkPVSessionBase
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);
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  virtual bool GetIsAlive() { return true; }
132 
140  virtual ServerFlags GetProcessRoles();
141 
146  virtual void PushState(vtkSMMessage* msg);
147 
151  virtual void NotifyAllClients(const vtkSMMessage* msg) { this->ProcessNotification(msg); }
152 
156  virtual void NotifyOtherClients(const vtkSMMessage*) { /* 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 
183  static vtkIdType ConnectToSelf();
184 
191  static vtkIdType ConnectToRemote(const char* hostname, int port);
192 
200  static vtkIdType ReverseConnectToRemote(int port)
201  {
202  return vtkSMSession::ReverseConnectToRemote(port, (bool (*)())NULL);
203  }
204  static vtkIdType ReverseConnectToRemote(int port, bool (*callback)());
205 
213  static vtkIdType ConnectToRemote(const char* dshost, int dsport, const char* rshost, int rsport);
214 
222  static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
223  {
224  return vtkSMSession::ReverseConnectToRemote(dsport, rsport, NULL);
225  }
226  static vtkIdType ReverseConnectToRemote(int dsport, int rsport, bool (*callback)());
227 
229 
235  static void Disconnect(vtkIdType sessionid);
236  static void Disconnect(vtkSMSession* session);
238 
240 
245  vtkGetMacro(IsAutoMPI, bool);
247 
248 protected:
249  // Subclasses should set initialize_during_constructor to false so that
250  // this->Initialize() is not called in constructor but only after the session
251  // has been created/setup correctly.
252  vtkSMSession(
253  bool initialize_during_constructor = true, vtkPVSessionCore* preExistingSessionCore = NULL);
254  ~vtkSMSession();
255 
259  static vtkIdType ConnectToRemoteInternal(const char* hostname, int port, bool is_auto_mpi);
260 
265  virtual void ProcessNotification(const vtkSMMessage*);
266 
271  virtual void Initialize();
272 
278  void UpdateStateHistory(vtkSMMessage* msg);
279 
283 
284  bool IsAutoMPI;
285 
286 private:
287  vtkSMSession(const vtkSMSession&) VTK_DELETE_FUNCTION;
288  void operator=(const vtkSMSession&) VTK_DELETE_FUNCTION;
289 
290  // AutoMPI helper class
291  static vtkSmartPointer<vtkProcessModuleAutoMPI> AutoMPI;
292 };
293 
294 #endif
virtual const char * GetURI()
Return the URL that define where the session is connected to.
Definition: vtkSMSession.h:63
virtual bool GetIsAlive()
Builtin session is always alive.
Definition: vtkSMSession.h:131
virtual void PushState(vtkSMMessage *msg)
Push the state message.
virtual ServerFlags GetProcessRoles()
Returns a ServerFlags indicate the nature of the current processes.
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
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:282
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
vtkSMStateLocator * StateLocator
Definition: vtkSMSession.h:281
void PrintSelf(ostream &os, vtkIndent indent)
is used to locate proxies referred to in state xmls while loading state files.
virtual void NotifyAllClients(const vtkSMMessage *msg)
Sends the message to all clients.
Definition: vtkSMSession.h:151
Abstract class used to provide the main implementation of the ParaView session methods for the follow...
vtkSMSessionProxyManager * SessionProxyManager
Definition: vtkSMSession.h:280
static vtkIdType ReverseConnectToRemote(int port)
Same as ConnectToRemote() except that it waits for a reverse connection.
Definition: vtkSMSession.h:200
static vtkIdType ReverseConnectToRemote(int dsport, int rsport)
Same as ConnectToRemote() except that it waits for a reverse connection.
Definition: vtkSMSession.h:222
Class used to retreive a given message state based on its GlobalID.
virtual void NotifyOtherClients(const vtkSMMessage *)
Sends the message to all but the active client-session.
Definition: vtkSMSession.h:156