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 "vtkRemotingCoreModule.h" //needed for exports
28 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
29 
30 #include <string> // for std::string
31 
32 class vtkInformation;
36 class vtkSession;
37 class vtkSessionIterator;
38 
40 {
41 public:
42  static vtkProcessModule* New();
43  vtkTypeMacro(vtkProcessModule, vtkObject);
44  void PrintSelf(ostream& os, vtkIndent indent) override;
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<unsigned 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 
193  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
194 
196 
204  vtkGetObjectMacro(NetworkAccessManager, vtkNetworkAccessManager);
205  void SetNetworkAccessManager(vtkNetworkAccessManager*);
207 
212  vtkMultiProcessController* GetGlobalController();
213 
217  int GetNumberOfLocalPartitions();
218 
222  int GetPartitionId();
223 
227  bool IsMPIInitialized();
228 
230 
233  vtkGetMacro(ReportInterpreterErrors, bool);
234  vtkSetMacro(ReportInterpreterErrors, bool);
235  vtkBooleanMacro(ReportInterpreterErrors, bool);
237 
239  static bool GetSymmetricMPIMode();
241 
245  const std::string& GetProgramPath() const { return this->ProgramPath; }
249  const std::string& GetSelfDir() const { return this->SelfDir; }
250 
252 
267  static void SetDefaultMinimumGhostLevelsToRequestForStructuredPipelines(int);
268  static int GetDefaultMinimumGhostLevelsToRequestForStructuredPipelines();
269  static void SetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines(int);
270  static int GetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines();
272 
277  static int GetNumberOfGhostLevelsToRequest(vtkInformation* outInfo);
278 
279 protected:
281  ~vtkProcessModule() override;
282 
284 
287  void PushActiveSession(vtkSession*);
288  void PopActiveSession(vtkSession*);
290 
295  friend class vtkSession;
296 
298 
304 
309  void SetExecutablePath(const std::string& path);
310 
312 
313  // vtkSessionIterator needs access to vtkInternals to be able to iterate over
314  // the sessions efficiently.
315  friend class vtkSessionIterator;
316 
318 
319 private:
320  vtkProcessModule(const vtkProcessModule&) = delete;
321  void operator=(const vtkProcessModule&) = delete;
322 
323  void DetermineExecutablePath(int argc, char** argv);
324 
325  // Helper to initialize Python environment. This doesn't initialize Python
326  // but simply sets up the environment so when Python is initialized, it can
327  // find ParaView modules. This does nothing if not build with Python support.
328  bool InitializePythonEnvironment();
329 
330  static ProcessTypes ProcessType;
331 
332  // Set to true in Initialize if Finalize() should cleanup MPI.
333  static bool FinalizeMPI;
334 
335  // Set to true in InitializePythonEnvironment() if Finalize() should cleanup
336  // Python.
337  static bool FinalizePython;
338 
339  static vtkSmartPointer<vtkProcessModule> Singleton;
340  static vtkSmartPointer<vtkMultiProcessController> GlobalController;
341 
342  bool MultipleSessionsSupport;
343 
344  vtkIdType EventCallDataSessionId;
345 
346  std::string ProgramPath;
347  std::string SelfDir;
348 
349  static int DefaultMinimumGhostLevelsToRequestForStructuredPipelines;
350  static int DefaultMinimumGhostLevelsToRequestForUnstructuredPipelines;
351 };
352 
353 #endif // vtkProcessModule_h
type
vtkIdType MaxSessionId
Used to keep track of maximum session used.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
int vtkIdType
vtkProcessModuleInternals * Internals
vtkSessionIterator is used to iterate over sessions in the global ProcessModule.
static unsigned int GetProcessTypeAsInt()
#define VTKREMOTINGCORE_EXPORT
const std::string & GetProgramPath() const
The full path to the current executable that is running (or empty if unknown).
ServerFlags
These flags are used to specify destination servers for the SendStream function.
vtkNetworkAccessManager * NetworkAccessManager
const std::string & GetSelfDir() const
The directory containing the current executable (or empty if unknown).
vtkSession defines a session i.e.
Definition: vtkSession.h:29
vtkNetworkAccessManager is used to create new connections and monitor activity of those connections...
static vtkObject * New()
void operator=(const vtkObjectBase &)
static ProcessTypes GetProcessType()
process initialization and management core for ParaView processes.