Salome HOME
Fix a compilation problem: comment SALOMETraceCollector::instance() method
[samples/component.git] / src / SIGNALSComponent / SIGNALSComponent_CheckOfUndefined.cxx
1 //  SALOME Container : implementation of container and engine for Kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_Container.cxx
25 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
26 //  Module : SALOME
27 //  $Header$
28
29 #include <iostream>
30 #include <string>
31 #include <stdio.h>
32
33 #ifndef WNT
34 #include <unistd.h>
35 #else
36 #include <process.h>
37 #endif
38 #include "SALOME_Container_i.hxx"
39 #include "utilities.h"
40 #include "Utils_ORB_INIT.hxx"
41 #include "Utils_SINGLETON.hxx"
42 #include "SALOMETraceCollector.hxx"
43 #include "OpUtil.hxx"
44
45 #ifdef CHECKTIME
46 #include <Utils_Timer.hxx>
47 #endif
48
49 #ifdef HAVE_MPI2
50 #include <mpi.h>
51 #endif
52
53 #include "Container_init_python.hxx"
54
55 using namespace std;
56
57 extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
58
59 int main(int argc, char* argv[])
60 {
61 #ifdef HAVE_MPI2
62   MPI_Init(&argc,&argv);
63 #endif
64
65   // Initialise the ORB.
66   //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
67   //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
68   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
69   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
70   CORBA::ORB_var orb = init(0 , 0 ) ;
71           
72   //SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
73   INFOS_COMPILATION;
74   BEGIN_OF(argv[0]);
75
76   ASSERT(argc > 1);
77   SCRUTE(argv[1]);
78   bool isSupervContainer = false;
79   if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true;
80
81   if (!isSupervContainer)
82     {
83       int _argc = 1;
84       char* _argv[] = {""};
85       KERNEL_PYTHON::init_python(argc,argv);
86     }
87   else
88     {
89       Py_Initialize() ;
90       PySys_SetArgv( argc , argv ) ;
91     }
92     
93   char *containerName = "";
94   if(argc > 1)
95     {
96       containerName = argv[1] ;
97     }
98
99   try
100     {  
101       CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
102       ASSERT(!CORBA::is_nil(obj));
103       PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
104
105       PortableServer::POAManager_var pman = root_poa->the_POAManager();
106
107       // add new container to the kill list
108 #ifndef WNT
109       char aCommand[40];
110       sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid());
111       system(aCommand);
112 #endif
113       
114       Engines_Container_i * myContainer 
115         = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
116       
117       pman->activate();
118       
119 #ifdef CHECKTIME
120       Utils_Timer timer;
121       timer.Start();
122       timer.Stop();
123       MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
124       timer.ShowAbsolute();
125 #endif
126       
127       HandleServerSideSignals(orb);
128       
129     }
130   catch(CORBA::SystemException&)
131     {
132       INFOS("Caught CORBA::SystemException.");
133     }
134   catch(PortableServer::POA::ServantAlreadyActive&)
135     {
136       INFOS("Caught CORBA::ServantAlreadyActiveException");
137     }
138   catch(CORBA::Exception&)
139     {
140       INFOS("Caught CORBA::Exception.");
141     }
142   catch(std::exception& exc)
143     {
144       INFOS("Caught std::exception - "<<exc.what()); 
145     }
146   catch(...)
147     {
148       INFOS("Caught unknown exception.");
149     }
150
151 #ifdef HAVE_MPI2
152   MPI_Finalize();
153 #endif
154
155   END_OF(argv[0]);
156   delete myThreadTrace;
157   return 0 ;
158 }
159