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 "vtkParaViewDeprecation.h" // for PARAVIEW_DEPRECATED_IN_5_10_0
28 #include "vtkRemotingCoreModule.h" //needed for exports
29 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
30 
31 #include <string> // for std::string
32 
33 class vtkInformation;
37 class vtkPVOptions;
38 class vtkSession;
39 class vtkSessionIterator;
40 
42 {
43 public:
44  static vtkProcessModule* New();
45  vtkTypeMacro(vtkProcessModule, vtkObject);
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
49  {
50  PROCESS_CLIENT, /* Capable of connecting to remote server or self.
51  Cannot run in Parallel */
52  PROCESS_SERVER, /* data-server+render-server */
53  PROCESS_DATA_SERVER, /* data-server */
54  PROCESS_RENDER_SERVER, /* render-server */
55  PROCESS_BATCH, /* Capable of running in parallel with root node acting as client.
56  Cannot connect to remote server */
57  PROCESS_INVALID = -1,
58  };
59 
68  {
69  DATA_SERVER = 0x01,
70  DATA_SERVER_ROOT = 0x02,
71  RENDER_SERVER = 0x04,
72  RENDER_SERVER_ROOT = 0x08,
73  SERVERS = DATA_SERVER | RENDER_SERVER,
74  CLIENT = 0x10,
75  CLIENT_AND_SERVERS = DATA_SERVER | CLIENT | RENDER_SERVER
76  };
77 
78  static ProcessTypes GetProcessType();
79  static unsigned int GetProcessTypeAsInt()
80  {
81  return static_cast<unsigned int>(vtkProcessModule::GetProcessType());
82  }
83 
91  void UpdateProcessType(ProcessTypes newType, bool dontKnowWhatImDoing = true);
92 
93  //********** PROCESS INITIALIZATION/CLEANUP API *****************************
94 
102  static bool Initialize(ProcessTypes type, int& argc, char**& argv);
103 
107  static bool Finalize();
108 
109  //********** SESSION MANAGEMENT API *****************************
110 
119  vtkIdType RegisterSession(vtkSession*);
120 
122 
132  bool UnRegisterSession(vtkIdType sessionID);
133  bool UnRegisterSession(vtkSession* session);
135 
137 
143  vtkGetMacro(EventCallDataSessionId, vtkIdType);
145 
149  vtkSession* GetSession(vtkIdType);
150 
155  vtkIdType GetSessionID(vtkSession*);
156 
161  vtkSessionIterator* NewSessionIterator();
162 
168  vtkSession* GetActiveSession();
169 
175  vtkSession* GetSession();
176 
178 
182  vtkGetMacro(MultipleSessionsSupport, bool);
183  vtkSetMacro(MultipleSessionsSupport, bool);
184  vtkBooleanMacro(MultipleSessionsSupport, bool);
186 
187  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
188 
193  static vtkProcessModule* GetProcessModule();
194 
196 
201  PARAVIEW_DEPRECATED_IN_5_10_0("Replaced by `vtkCLIOptions` APIs")
202  vtkPVOptions* GetOptions();
203  PARAVIEW_DEPRECATED_IN_5_10_0("Replaced by `vtkCLIOptions` APIs")
204  void SetOptions(vtkPVOptions*);
206 
207  //********** ACCESSORS FOR VARIOUS HELPERS *****************************
208 
210 
218  vtkGetObjectMacro(NetworkAccessManager, vtkNetworkAccessManager);
219  void SetNetworkAccessManager(vtkNetworkAccessManager*);
221 
226  vtkMultiProcessController* GetGlobalController();
227 
231  int GetNumberOfLocalPartitions();
232 
236  int GetPartitionId();
237 
241  bool IsMPIInitialized();
242 
244 
247  vtkGetMacro(ReportInterpreterErrors, bool);
248  vtkSetMacro(ReportInterpreterErrors, bool);
249  vtkBooleanMacro(ReportInterpreterErrors, bool);
251 
253  static bool GetSymmetricMPIMode();
255 
259  const std::string& GetProgramPath() const { return this->ProgramPath; }
263  const std::string& GetSelfDir() const { return this->SelfDir; }
264 
266 
281  static void SetDefaultMinimumGhostLevelsToRequestForStructuredPipelines(int);
282  static int GetDefaultMinimumGhostLevelsToRequestForStructuredPipelines();
283  static void SetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines(int);
284  static int GetDefaultMinimumGhostLevelsToRequestForUnstructuredPipelines();
286 
291  static int GetNumberOfGhostLevelsToRequest(vtkInformation* outInfo);
292 
293 protected:
295  ~vtkProcessModule() override;
296 
298 
301  void PushActiveSession(vtkSession*);
302  void PopActiveSession(vtkSession*);
304 
309  friend class vtkSession;
310 
312 
318 
323  void SetExecutablePath(const std::string& path);
324 
326 
327  // vtkSessionIterator needs access to vtkInternals to be able to iterate over
328  // the sessions efficiently.
329  friend class vtkSessionIterator;
330 
332 
333 private:
334  vtkProcessModule(const vtkProcessModule&) = delete;
335  void operator=(const vtkProcessModule&) = delete;
336 
337  void DetermineExecutablePath(int argc, char** argv);
338 
339  // Helper to initialize Python environment. This doesn't initialize Python
340  // but simply sets up the environment so when Python is initialized, it can
341  // find ParaView modules. This does nothing if not build with Python support.
342  bool InitializePythonEnvironment();
343 
344  static ProcessTypes ProcessType;
345 
346  // Set to true in Initialize if Finalize() should cleanup MPI.
347  static bool FinalizeMPI;
348 
349  // Set to true in InitializePythonEnvironment() if Finalize() should cleanup
350  // Python.
351  static bool FinalizePython;
352 
353  static vtkSmartPointer<vtkProcessModule> Singleton;
354  static vtkSmartPointer<vtkMultiProcessController> GlobalController;
355 
356  bool MultipleSessionsSupport;
357 
358  vtkIdType EventCallDataSessionId;
359 
360  std::string ProgramPath;
361  std::string SelfDir;
362 
363  static int DefaultMinimumGhostLevelsToRequestForStructuredPipelines;
364  static int DefaultMinimumGhostLevelsToRequestForUnstructuredPipelines;
365 
366  vtkPVOptions* Options;
367 };
368 
369 #endif // vtkProcessModule_h
#define PARAVIEW_DEPRECATED_IN_5_10_0(reason)
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
ParaView options storage.
Definition: vtkPVOptions.h:38
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.