ParaView
vtkProcessModule.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkProcessModule.h
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 =========================================================================*/
23 #ifndef vtkProcessModule_h
24 #define vtkProcessModule_h
25 
26 #include "vtkObject.h"
27 #include "vtkPVClientServerCoreCoreModule.h" //needed for exports
28 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
29 
30 #include <string> // for std::string
31 
32 class vtkMultiProcessController;
34 class vtkPVOptions;
35 class vtkSession;
36 class vtkSessionIterator;
38 
39 class VTKPVCLIENTSERVERCORECORE_EXPORT vtkProcessModule : public vtkObject
40 {
41 public:
42  static vtkProcessModule* New();
43  vtkTypeMacro(vtkProcessModule, vtkObject);
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
47  {
48  PROCESS_CLIENT, /* Capable of connecting to remote server or self.
49  Cannot run in Parallel */
50  PROCESS_SERVER, /* data-server+render-server */
51  PROCESS_DATA_SERVER, /* data-server */
52  PROCESS_RENDER_SERVER, /* render-server */
53  PROCESS_BATCH, /* Capable of running in parallel with root node acting as client.
54  Cannot connect to remote server */
55  PROCESS_INVALID = -1,
56  };
57 
66  {
67  DATA_SERVER = 0x01,
68  DATA_SERVER_ROOT = 0x02,
69  RENDER_SERVER = 0x04,
70  RENDER_SERVER_ROOT = 0x08,
71  SERVERS = DATA_SERVER | RENDER_SERVER,
72  CLIENT = 0x10,
73  CLIENT_AND_SERVERS = DATA_SERVER | CLIENT | RENDER_SERVER
74  };
75 
76  static ProcessTypes GetProcessType();
77  static unsigned int GetProcessTypeAsInt()
78  {
79  return static_cast<int>(vtkProcessModule::GetProcessType());
80  }
81 
89  void UpdateProcessType(ProcessTypes newType, bool dontKnowWhatImDoing = true);
90 
91  //********** PROCESS INITIALIZATION/CLEANUP API *****************************
92 
100  static bool Initialize(ProcessTypes type, int& argc, char**& argv);
101 
105  static bool Finalize();
106 
107  //********** SESSION MANAGEMENT API *****************************
108 
117  vtkIdType RegisterSession(vtkSession*);
118 
120 
130  bool UnRegisterSession(vtkIdType sessionID);
131  bool UnRegisterSession(vtkSession* session);
133 
135 
141  vtkGetMacro(EventCallDataSessionId, vtkIdType);
143 
147  vtkSession* GetSession(vtkIdType);
148 
153  vtkIdType GetSessionID(vtkSession*);
154 
159  vtkSessionIterator* NewSessionIterator();
160 
166  vtkSession* GetActiveSession();
167 
173  vtkSession* GetSession();
174 
176 
180  vtkGetMacro(MultipleSessionsSupport, bool);
181  vtkSetMacro(MultipleSessionsSupport, bool);
182  vtkBooleanMacro(MultipleSessionsSupport, bool);
184 
185  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
186 
191  static vtkProcessModule* GetProcessModule();
192 
194 
199  vtkGetObjectMacro(Options, vtkPVOptions);
200  void SetOptions(vtkPVOptions* op);
202 
203  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
204 
206 
214  vtkGetObjectMacro(NetworkAccessManager, vtkNetworkAccessManager);
215  void SetNetworkAccessManager(vtkNetworkAccessManager*);
217 
222  vtkMultiProcessController* GetGlobalController();
223 
227  int GetNumberOfLocalPartitions();
228 
232  int GetPartitionId();
233 
237  bool IsMPIInitialized();
238 
240 
243  vtkGetMacro(ReportInterpreterErrors, bool);
244  vtkSetMacro(ReportInterpreterErrors, bool);
245  vtkBooleanMacro(ReportInterpreterErrors, bool);
247 
249 
254  vtkGetMacro(SymmetricMPIMode, bool);
256 
260  std::string GetProgramPath() const { return this->ProgramPath; }
264  std::string GetSelfDir() const { return this->SelfDir; }
265 
266 protected:
268  ~vtkProcessModule();
269 
270  vtkSetMacro(SymmetricMPIMode, bool);
271 
273 
276  void PushActiveSession(vtkSession*);
277  void PopActiveSession(vtkSession*);
279 
284  friend class vtkSession;
285 
288 
293  vtkIdType MaxSessionId;
294 
299  void SetExecutablePath(const std::string& path);
300 
301 protected:
303 
304  // vtkSessionIterator needs access to vtkInternals to be able to iterate over
305  // the sessions efficiently.
306  friend class vtkSessionIterator;
307 
309 
310 private:
311  vtkProcessModule(const vtkProcessModule&) VTK_DELETE_FUNCTION;
312  void operator=(const vtkProcessModule&) VTK_DELETE_FUNCTION;
313 
314  void DetermineExecutablePath(int argc, char** argv);
315 
316  // Helper to initialize Python environment. This doesn't initialize Python
317  // but simply sets up the environment so when Python is initialized, it can
318  // find ParaView modules. This does nothing if not build with Python support.
319  bool InitializePythonEnvironment();
320 
321  static ProcessTypes ProcessType;
322 
323  // Set to true in Initialize if Finalize() should cleanup MPI.
324  static bool FinalizeMPI;
325 
326  // Set to true in InitializePythonEnvironment() if Finalize() should cleanup
327  // Python.
328  static bool FinalizePython;
329 
330  static vtkSmartPointer<vtkProcessModule> Singleton;
331  static vtkSmartPointer<vtkMultiProcessController> GlobalController;
332 
333  bool SymmetricMPIMode;
334 
335  bool MultipleSessionsSupport;
336 
337  vtkIdType EventCallDataSessionId;
338 
339  std::string ProgramPath;
340  std::string SelfDir;
341 };
342 
343 #endif // vtkProcessModule_h
vtkIdType MaxSessionId
Used to keep track of maximum session used.
vtkPVOptions * Options
vtkProcessModuleInternals * Internals
std::string GetProgramPath() const
The full path to the current executable that is running (or empty if unknown).
vtkSessionIterator is used to iterate over sessions in the global ProcessModule.
static unsigned int GetProcessTypeAsInt()
ServerFlags
These flags are used to specify destination servers for the SendStream function.
vtkNetworkAccessManager * NetworkAccessManager
vtkSession defines a session i.e.
Definition: vtkSession.h:29
ParaView options storage.
Definition: vtkPVOptions.h:33
vtkNetworkAccessManager is used to create new connections and monitor activity of those connections...
std::string GetSelfDir() const
The directory containing the current executable (or empty if unknown).
static ProcessTypes GetProcessType()
process initialization and management core for ParaView processes.