Salome HOME
Revert "Synchronize adm files"
[samples/component.git] / src / SIGNALSComponent / SIGNALSComponent_CheckOfUndefined.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME Container : implementation of container and engine for Kernel
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 WIN32
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 //CCRT
54 #include <sstream>
55 #include <time.h>
56 #ifndef WIN32
57 #include <sys/time.h>
58 #include <sys/stat.h>
59 #endif
60 //end-CCRT
61
62 #include "Container_init_python.hxx"
63
64 using namespace std;
65
66 extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
67
68 int main(int argc, char* argv[])
69 {
70 #ifdef HAVE_MPI2
71   MPI_Init(&argc,&argv);
72 #endif
73
74   // Initialise the ORB.
75   //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
76   //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
77   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
78   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
79   CORBA::ORB_var orb = init(0 , 0 ) ;
80           
81   //SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
82   INFOS_COMPILATION;
83   BEGIN_OF(argv[0]);
84
85   ASSERT(argc > 1);
86   SCRUTE(argv[1]);
87   bool isSupervContainer = false;
88   if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true;
89
90   if (!isSupervContainer)
91     {
92       int _argc = 1;
93       char* _argv[] = {""};
94       KERNEL_PYTHON::init_python(argc,argv);
95     }
96   else
97     {
98       Py_Initialize() ;
99       PySys_SetArgv( argc , argv ) ;
100     }
101     
102   char *containerName = "";
103   if(argc > 1)
104     {
105       containerName = argv[1] ;
106     }
107
108   try
109     {  
110       CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
111       ASSERT(!CORBA::is_nil(obj));
112       PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
113
114       PortableServer::POAManager_var pman = root_poa->the_POAManager();
115
116       // add new container to the kill list
117 #ifndef WNT
118       char aCommand[40];
119       sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid());
120       system(aCommand);
121 #endif
122       
123       Engines_Container_i * myContainer 
124         = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
125       
126       pman->activate();
127       
128 #ifdef CHECKTIME
129       Utils_Timer timer;
130       timer.Start();
131       timer.Stop();
132       MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
133       timer.ShowAbsolute();
134 #endif
135       
136       HandleServerSideSignals(orb);
137       
138     }
139   catch(CORBA::SystemException&)
140     {
141       INFOS("Caught CORBA::SystemException.");
142     }
143   catch(PortableServer::POA::ServantAlreadyActive&)
144     {
145       INFOS("Caught CORBA::ServantAlreadyActiveException");
146     }
147   catch(CORBA::Exception&)
148     {
149       INFOS("Caught CORBA::Exception.");
150     }
151   catch(std::exception& exc)
152     {
153       INFOS("Caught std::exception - "<<exc.what()); 
154     }
155   catch(...)
156     {
157       INFOS("Caught unknown exception.");
158     }
159
160 #ifdef HAVE_MPI2
161   MPI_Finalize();
162 #endif
163
164   END_OF(argv[0]);
165   // delete myThreadTrace;
166   return 0 ;
167 }
168