vtkProcessModule.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkProcessModule_h
12 #define vtkProcessModule_h
13 
14 #include "vtkNew.h" // needed for vtkNew
15 #include "vtkObject.h"
16 #include "vtkRemotingCoreModule.h" //needed for exports
17 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
18 
19 #include <string> // for std::string
20 
21 class vtkInformation;
25 class vtkSession;
26 class vtkSessionIterator;
27 class vtkThreadedCallbackQueue;
28 
30 {
31 public:
32  static vtkProcessModule* New();
33  vtkTypeMacro(vtkProcessModule, vtkObject);
34  void PrintSelf(ostream& os, vtkIndent indent) override;
35 
37  {
38  PROCESS_CLIENT, /* Capable of connecting to remote server or self.
39  Cannot run in Parallel */
40  PROCESS_SERVER, /* data-server+render-server */
41  PROCESS_DATA_SERVER, /* data-server */
42  PROCESS_RENDER_SERVER, /* render-server */
43  PROCESS_BATCH, /* Capable of running in parallel with root node acting as client.
44  Cannot connect to remote server */
45  PROCESS_INVALID = -1,
46  };
47 
56  {
57  DATA_SERVER = 0x01,
58  DATA_SERVER_ROOT = 0x02,
59  RENDER_SERVER = 0x04,
60  RENDER_SERVER_ROOT = 0x08,
61  SERVERS = DATA_SERVER | RENDER_SERVER,
62  CLIENT = 0x10,
63  CLIENT_AND_SERVERS = DATA_SERVER | CLIENT | RENDER_SERVER
64  };
65 
66  static ProcessTypes GetProcessType();
67  static unsigned int GetProcessTypeAsInt()
68  {
69  return static_cast<unsigned int>(vtkProcessModule::GetProcessType());
70  }
71 
79  void UpdateProcessType(ProcessTypes newType, bool dontKnowWhatImDoing = true);
80 
81  //********** PROCESS INITIALIZATION/CLEANUP API *****************************
82 
90  static bool Initialize(ProcessTypes type, int& argc, char**& argv);
91 
95  static bool Finalize();
96 
97  //********** SESSION MANAGEMENT API *****************************
98 
107  vtkIdType RegisterSession(vtkSession*);
108 
110 
120  bool UnRegisterSession(vtkIdType sessionID);
121  bool UnRegisterSession(vtkSession* session);
123 
125 
131  vtkGetMacro(EventCallDataSessionId, vtkIdType);
133 
137  vtkSession* GetSession(vtkIdType);
138 
143  vtkIdType GetSessionID(vtkSession*);
144 
149  vtkSessionIterator* NewSessionIterator();
150 
156  vtkSession* GetActiveSession();
157 
163  vtkSession* GetSession();
164 
166 
170  vtkGetMacro(MultipleSessionsSupport, bool);
171  vtkSetMacro(MultipleSessionsSupport, bool);
172  vtkBooleanMacro(MultipleSessionsSupport, bool);
174 
175  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
176 
181  static vtkProcessModule* GetProcessModule();
182 
183  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
184 
186 
194  vtkGetObjectMacro(NetworkAccessManager, vtkNetworkAccessManager);
195  void SetNetworkAccessManager(vtkNetworkAccessManager*);
197 
202  vtkMultiProcessController* GetGlobalController();
203 
207  int GetNumberOfLocalPartitions();
208 
212  int GetPartitionId();
213 
217  bool IsMPIInitialized();
218 
220 
223  vtkGetMacro(ReportInterpreterErrors, bool);
224  vtkSetMacro(ReportInterpreterErrors, bool);
225  vtkBooleanMacro(ReportInterpreterErrors, bool);
227 
229  static bool GetSymmetricMPIMode();
231 
235  const std::string& GetProgramPath() const { return this->ProgramPath; }
239  const std::string& GetSelfDir() const { return this->SelfDir; }
240 
242 
257  static void SetDefaultMinimumGhostLevelsToRequestForStructuredPipelines(int);
258  static int GetDefaultMinimumGhostLevelsToRequestForStructuredPipelines();
259  static void SetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines(int);
260  static int GetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines();
262 
267  static int GetNumberOfGhostLevelsToRequest(vtkInformation* outInfo);
268 
272  vtkThreadedCallbackQueue* GetCallbackQueue();
273 
274 protected:
276  ~vtkProcessModule() override;
277 
279 
282  void PushActiveSession(vtkSession*);
283  void PopActiveSession(vtkSession*);
285 
290  friend class vtkSession;
291 
293 
299 
304  void SetExecutablePath(const std::string& path);
305 
307 
308  // vtkSessionIterator needs access to vtkInternals to be able to iterate over
309  // the sessions efficiently.
310  friend class vtkSessionIterator;
311 
313 
314 private:
315  vtkProcessModule(const vtkProcessModule&) = delete;
316  void operator=(const vtkProcessModule&) = delete;
317 
318  void DetermineExecutablePath(int argc, char** argv);
319 
320  // Helper to initialize Python environment. This doesn't initialize Python
321  // but simply sets up the environment so when Python is initialized, it can
322  // find ParaView modules. This does nothing if not build with Python support.
323  bool InitializePythonEnvironment();
324 
325  static ProcessTypes ProcessType;
326 
327  // Set to true in Initialize if Finalize() should cleanup MPI.
328  static bool FinalizeMPI;
329 
330  // Set to true in InitializePythonEnvironment() if Finalize() should cleanup
331  // Python.
332  static bool FinalizePython;
333 
334  static vtkSmartPointer<vtkProcessModule> Singleton;
335  static vtkSmartPointer<vtkMultiProcessController> GlobalController;
336 
337  bool MultipleSessionsSupport;
338 
339  vtkIdType EventCallDataSessionId;
340 
341  std::string ProgramPath;
342  std::string SelfDir;
343 
344  static int DefaultMinimumGhostLevelsToRequestForStructuredPipelines;
345  static int DefaultMinimumGhostLevelsToRequestForUnstructuredPipelines;
346 };
347 
348 #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:17
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.