]> SALOME platform Git repositories - samples/component.git/blob - src/SIGNALSComponent/SIGNALSComponent_CheckOfUndefined.cxx
Salome HOME
Merge from BR_V5_DEV 17Feb09
[samples/component.git] / src / SIGNALSComponent / SIGNALSComponent_CheckOfUndefined.cxx
1 //  Copyright (C) 2007-2008  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.
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 //  SALOME Container : implementation of container and engine for Kernel
23 //  File   : SALOME_Container.cxx
24 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
25 //  Module : SALOME
26 //  $Header$
27 //
28 #include <iostream>
29 #include <string>
30 #include <stdio.h>
31
32 #ifndef WNT
33 #include <unistd.h>
34 #else
35 #include <process.h>
36 #endif
37 #include "SALOME_Container_i.hxx"
38 #include "utilities.h"
39 #include "Utils_ORB_INIT.hxx"
40 #include "Utils_SINGLETON.hxx"
41 #include "SALOMETraceCollector.hxx"
42 #include "OpUtil.hxx"
43
44 #ifdef CHECKTIME
45 #include <Utils_Timer.hxx>
46 #endif
47
48 #ifdef HAVE_MPI2
49 #include <mpi.h>
50 #endif
51
52 //CCRT
53 #include <sstream>
54 #include <time.h>
55 #include <sys/time.h>
56 #include <sys/stat.h>
57 //end-CCRT
58
59 #include "Container_init_python.hxx"
60
61 using namespace std;
62
63 extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
64
65 int main(int argc, char* argv[])
66 {
67 #ifdef HAVE_MPI2
68   MPI_Init(&argc,&argv);
69 #endif
70
71   // Initialise the ORB.
72   //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
73   //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
74   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
75   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
76   CORBA::ORB_var orb = init(0 , 0 ) ;
77           
78   //SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
79   INFOS_COMPILATION;
80   BEGIN_OF(argv[0]);
81
82   ASSERT(argc > 1);
83   SCRUTE(argv[1]);
84   bool isSupervContainer = false;
85   if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true;
86
87   if (!isSupervContainer)
88     {
89       int _argc = 1;
90       char* _argv[] = {""};
91       KERNEL_PYTHON::init_python(argc,argv);
92     }
93   else
94     {
95       Py_Initialize() ;
96       PySys_SetArgv( argc , argv ) ;
97     }
98     
99   char *containerName = "";
100   if(argc > 1)
101     {
102       containerName = argv[1] ;
103     }
104
105   try
106     {  
107       CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
108       ASSERT(!CORBA::is_nil(obj));
109       PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
110
111       PortableServer::POAManager_var pman = root_poa->the_POAManager();
112
113       // add new container to the kill list
114 #ifndef WNT
115       char aCommand[40];
116       sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid());
117       system(aCommand);
118 #endif
119       
120       Engines_Container_i * myContainer 
121         = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
122       
123       pman->activate();
124       
125 #ifdef CHECKTIME
126       Utils_Timer timer;
127       timer.Start();
128       timer.Stop();
129       MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
130       timer.ShowAbsolute();
131 #endif
132       
133       HandleServerSideSignals(orb);
134       
135     }
136   catch(CORBA::SystemException&)
137     {
138       INFOS("Caught CORBA::SystemException.");
139     }
140   catch(PortableServer::POA::ServantAlreadyActive&)
141     {
142       INFOS("Caught CORBA::ServantAlreadyActiveException");
143     }
144   catch(CORBA::Exception&)
145     {
146       INFOS("Caught CORBA::Exception.");
147     }
148   catch(std::exception& exc)
149     {
150       INFOS("Caught std::exception - "<<exc.what()); 
151     }
152   catch(...)
153     {
154       INFOS("Caught unknown exception.");
155     }
156
157 #ifdef HAVE_MPI2
158   MPI_Finalize();
159 #endif
160
161   END_OF(argv[0]);
162   // delete myThreadTrace;
163   return 0 ;
164 }
165