pvserver_common.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: ParaView
4 Module: pvserver.cxx
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 =========================================================================*/
15 #include "vtkPVConfig.h"
16 
20 #include "vtkPVPluginTracker.h"
21 #include "vtkPVServerOptions.h"
22 #include "vtkPVSessionServer.h"
23 #include "vtkProcessModule.h"
24 
25 #ifdef PARAVIEW_USE_PYTHON
26 extern "C" {
28 }
29 #endif
30 
32 
33 static bool RealMain(int argc, char* argv[], vtkProcessModule::ProcessTypes type)
34 {
35  // Marking this static avoids the false leak messages from vtkDebugLeaks when
36  // using mpich. It appears that the root process which spawns all the
37  // main processes waits in MPI_Init() and calls exit() when
38  // the others are done, causing apparent memory leaks for any non-static objects
39  // created before MPI_Init().
41 
42  // Init current process type
43  vtkInitializationHelper::Initialize(argc, argv, type, options);
44  if (options->GetTellVersion() || options->GetHelpSelected() || options->GetPrintMonitors())
45  {
47  return true;
48  }
49 
50 #ifdef PARAVIEW_USE_PYTHON
51  // register callback to initialize modules statically. The callback is
52  // empty when BUILD_SHARED_LIBS is ON.
54 #endif
55 
56  // register static plugins
58 
60 
63 
65  session->SetMultipleConnection(options->GetMultiClientMode() != 0);
67 
68  int process_id = controller->GetLocalProcessId();
69  if (process_id == 0)
70  {
71  // Report status:
72  if (options->GetReverseConnection())
73  {
74  cout << "Connecting to client (reverse connection requested)..." << endl;
75  }
76  else
77  {
78  cout << "Waiting for client..." << endl;
79  }
80  }
81  bool success = false;
82  if (session->Connect())
83  {
84  success = true;
85  pm->RegisterSession(session);
86  if (controller->GetLocalProcessId() == 0)
87  {
88  while (pm->GetNetworkAccessManager()->ProcessEvents(0) != -1)
89  {
90  }
91  }
92  else
93  {
94  controller->ProcessRMIs();
95  }
96  pm->UnRegisterSession(session);
97  }
98 
99  cout << "Exiting..." << endl;
100  session->Delete();
101  // Exit application
103  return success;
104 }
void LoadPluginConfigurationXMLs(const char *appname)
Called to load application-specific configuration xml.
virtual bool Connect(const char *url)
Connects a remote server.
static bool RealMain(int argc, char *argv[], vtkProcessModule::ProcessTypes type)
int ProcessRMIs(int reportErrors, int dont_loop=0)
void SetDisableFurtherConnections(bool disable)
Enable or Disable further connections in multiple connection mode.
static vtkPVSessionServer * New()
static void Finalize()
Finalizes the server manager.
virtual int GetReverseConnection()
static vtkSmartPointer< T > New()
static vtkProcessModule * GetProcessModule()
Provides access to the global ProcessModule.
void ParaView_paraview_plugins_initialize()
virtual int ProcessEvents(unsigned long timeout_msecs)=0
Process any network activity.
virtual int GetHelpSelected()
Was help selected?
static vtkPVPluginTracker * GetInstance()
Provides access to the singleton.
virtual int GetPrintMonitors()
Should this process just print monitor information and exit?
virtual int GetDisableFurtherConnections()
Returns if this server does not allow connection after the first client.
vtkMultiProcessController * GetGlobalController()
Provides access to the global MPI controller, if any.
static void Initialize(const char *executable, int type)
Initializes the server manager.
vtkIdType RegisterSession(vtkSession *)
Registers a new session.
virtual int GetMultiClientMode()
Is this server was started for collaboration meaning that it allow several clients to connect to the ...
Definition: vtkPVOptions.h:124
virtual void SetMultipleConnection(bool)
Enable or Disable multi-connection support.
vtkSMSessionServer is a session used on data and/or render servers.
virtual int GetTellVersion()
Should this run print the version numbers and exit.
virtual vtkNetworkAccessManager * GetNetworkAccessManager()
Get/Set the network access manager.
void vtkPVInitializePythonModules()
process initialization and management core for ParaView processes.
virtual void Delete()
bool UnRegisterSession(vtkIdType sessionID)
Unregister a session given its ID.