Back to index

salome-kernel  6.5.0
Utils_ORB_INIT.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME Utils : general SALOME's definitions and tools
00024 //  File   : Utils_ORB_INIT.cxx
00025 //  Author : Antoine YESSAYAN, EDF
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Utils/Utils_ORB_INIT.cxx,v 1.9.2.1.10.2.12.1 2012-04-12 14:05:32 vsr Exp $
00028 //
00029 # include "Utils_ORB_INIT.hxx" 
00030 # include "utilities.h" 
00031 
00032 # include "SALOMEconfig.h"
00033 
00034 ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() )
00035 {
00036 }
00037 
00038 
00039 ORB_INIT::~ORB_INIT()
00040 {
00041   if ( ! CORBA::is_nil( _orb ) )
00042   {
00043     MESSAGE("WARNING: orb destroy is no more called at exit. Use explicit call.");
00044     //std::cerr << "appel _orb->destroy()" << std::endl;
00045     /*
00046     try {
00047       _orb->destroy() ;
00048     }
00049     catch(...) {
00050       MESSAGE("Caught CORBA::Exception.");
00051     }
00052     */
00053     //std::cerr << "retour _orb->destroy()" << std::endl;
00054   }
00055 }
00056 
00057 
00058 CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) throw( CommException )
00059 {
00060   try {
00061     if ( CORBA::is_nil( _orb ) )
00062       {
00063         try
00064           {
00065 #if OMNIORB_VERSION >= 4
00066             _orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ;
00067 #else
00068             _orb = CORBA::ORB_init( argc, argv, "omniORB3" ) ;
00069 #endif
00070           }
00071         catch( const CORBA::Exception & )
00072           {
00073             throw CommException( "Unable to create an ORB connexion" ) ;
00074           }
00075       }
00076     return _orb ;
00077   } catch ( CommException& e) {throw e;}
00078   catch (...) { throw CommException( "ORB_INIT::operator() : Unknown exception was caught" ) ;}
00079 }