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 vtkPVOptions;
37 class vtkSession;
38 class vtkSessionIterator;
39 
41 {
42 public:
43  static vtkProcessModule* New();
44  vtkTypeMacro(vtkProcessModule, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48  {
49  PROCESS_CLIENT, /* Capable of connecting to remote server or self.
50  Cannot run in Parallel */
51  PROCESS_SERVER, /* data-server+render-server */
52  PROCESS_DATA_SERVER, /* data-server */
53  PROCESS_RENDER_SERVER, /* render-server */
54  PROCESS_BATCH, /* Capable of running in parallel with root node acting as client.
55  Cannot connect to remote server */
56  PROCESS_INVALID = -1,
57  };
58 
67  {
68  DATA_SERVER = 0x01,
69  DATA_SERVER_ROOT = 0x02,
70  RENDER_SERVER = 0x04,
71  RENDER_SERVER_ROOT = 0x08,
72  SERVERS = DATA_SERVER | RENDER_SERVER,
73  CLIENT = 0x10,
74  CLIENT_AND_SERVERS = DATA_SERVER | CLIENT | RENDER_SERVER
75  };
76 
77  static ProcessTypes GetProcessType();
78  static unsigned int GetProcessTypeAsInt()
79  {
80  return static_cast<unsigned int>(vtkProcessModule::GetProcessType());
81  }
82 
90  void UpdateProcessType(ProcessTypes newType, bool dontKnowWhatImDoing = true);
91 
92  //********** PROCESS INITIALIZATION/CLEANUP API *****************************
93 
101  static bool Initialize(ProcessTypes type, int& argc, char**& argv);
102 
106  static bool Finalize();
107 
108  //********** SESSION MANAGEMENT API *****************************
109 
118  vtkIdType RegisterSession(vtkSession*);
119 
121 
131  bool UnRegisterSession(vtkIdType sessionID);
132  bool UnRegisterSession(vtkSession* session);
134 
136 
142  vtkGetMacro(EventCallDataSessionId, vtkIdType);
144 
148  vtkSession* GetSession(vtkIdType);
149 
154  vtkIdType GetSessionID(vtkSession*);
155 
160  vtkSessionIterator* NewSessionIterator();
161 
167  vtkSession* GetActiveSession();
168 
174  vtkSession* GetSession();
175 
177 
181  vtkGetMacro(MultipleSessionsSupport, bool);
182  vtkSetMacro(MultipleSessionsSupport, bool);
183  vtkBooleanMacro(MultipleSessionsSupport, bool);
185 
186  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
187 
192  static vtkProcessModule* GetProcessModule();
193 
195 
200  vtkGetObjectMacro(Options, vtkPVOptions);
201  void SetOptions(vtkPVOptions* op);
203 
204  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
205 
207 
215  vtkGetObjectMacro(NetworkAccessManager, vtkNetworkAccessManager);
216  void SetNetworkAccessManager(vtkNetworkAccessManager*);
218 
223  vtkMultiProcessController* GetGlobalController();
224 
228  int GetNumberOfLocalPartitions();
229 
233  int GetPartitionId();
234 
238  bool IsMPIInitialized();
239 
241 
244  vtkGetMacro(ReportInterpreterErrors, bool);
245  vtkSetMacro(ReportInterpreterErrors, bool);
246  vtkBooleanMacro(ReportInterpreterErrors, bool);
248 
250 
255  vtkGetMacro(SymmetricMPIMode, bool);
257 
261  const std::string& GetProgramPath() const { return this->ProgramPath; }
265  const std::string& GetSelfDir() const { return this->SelfDir; }
266 
268 
283  static void SetDefaultMinimumGhostLevelsToRequestForStructuredPipelines(int);
284  static int GetDefaultMinimumGhostLevelsToRequestForStructuredPipelines();
285  static void SetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines(int);
286  static int GetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines();
288 
293  static int GetNumberOfGhostLevelsToRequest(vtkInformation* outInfo);
294 
295 protected:
297  ~vtkProcessModule() override;
298 
299  vtkSetMacro(SymmetricMPIMode, bool);
300 
302 
305  void PushActiveSession(vtkSession*);
306  void PopActiveSession(vtkSession*);
308 
313  friend class vtkSession;
314 
317 
323 
328  void SetExecutablePath(const std::string& path);
329 
330 protected:
332 
333  // vtkSessionIterator needs access to vtkInternals to be able to iterate over
334  // the sessions efficiently.
335  friend class vtkSessionIterator;
336 
338 
339 private:
340  vtkProcessModule(const vtkProcessModule&) = delete;
341  void operator=(const vtkProcessModule&) = delete;
342 
343  void DetermineExecutablePath(int argc, char** argv);
344 
345  // Helper to initialize Python environment. This doesn't initialize Python
346  // but simply sets up the environment so when Python is initialized, it can
347  // find ParaView modules. This does nothing if not build with Python support.
348  bool InitializePythonEnvironment();
349 
350  static ProcessTypes ProcessType;
351 
352  // Set to true in Initialize if Finalize() should cleanup MPI.
353  static bool FinalizeMPI;
354 
355  // Set to true in InitializePythonEnvironment() if Finalize() should cleanup
356  // Python.
357  static bool FinalizePython;
358 
359  static vtkSmartPointer<vtkProcessModule> Singleton;
360  static vtkSmartPointer<vtkMultiProcessController> GlobalController;
361 
362  bool SymmetricMPIMode;
363 
364  bool MultipleSessionsSupport;
365 
366  vtkIdType EventCallDataSessionId;
367 
368  std::string ProgramPath;
369  std::string SelfDir;
370 
371  static int DefaultMinimumGhostLevelsToRequestForStructuredPipelines;
372  static int DefaultMinimumGhostLevelsToRequestForUnstructuredPipelines;
373 };
374 
375 #endif // vtkProcessModule_h
type
vtkIdType MaxSessionId
Used to keep track of maximum session used.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
int vtkIdType
vtkPVOptions * Options
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
ParaView options storage.
Definition: vtkPVOptions.h:37
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.