Salome HOME
PR: portage CCRT - ajustements sur RedHat8: minimisation ecart du au portage sur...
[modules/kernel.git] / src / NamingService / SALOME_NamingService.cxx
index b4a4ebb2ed6d7d07e31b6afc2eb52aba67b5aa52..07b0e93423de3be5914a2aa34133d8f965a79dae 100644 (file)
@@ -1,17 +1,41 @@
-using namespace std;
-// File: SALOME_NamingService.cxx
-// Created: Tue June 12 2001
-// Author: Estelle Deville
-// Project: SALOME
-// Copyright : CEA/DEN/DMSS/LGLS
-// $Header$
+//  SALOME NamingService : wrapping NamingService services
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : SALOME_NamingService.cxx
+//  Author : Estelle Deville
+//  Module : SALOME
+//  $Header$
 
-//----------------------------------------------------------------------
 #include "SALOME_NamingService.hxx"
 #include "ServiceUnreachable.hxx"
+
+#include "utilities.h"
+
 #include <iostream>
 #include <cstring>
 
+using namespace std;
+
 //----------------------------------------------------------------------
 /*! Function : SALOME_NamingService
  *  Purpose  : Constructor and Initialisation of _root_context
@@ -163,7 +187,7 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef,
                      _temp_context =
                        _current_context->bind_new_context(_context_name);
                      _current_context = _temp_context;
-                     //MESSAGE("This context was'nt created, it's now done");
+                     //INFOS("This context was'nt created, it's now done");
                    }
                }
            }
@@ -436,7 +460,7 @@ bool SALOME_NamingService::Create_Directory(const char* Path)
              _temp_context =
                _current_context->bind_new_context(_context_name);
              _current_context = _temp_context;
-             MESSAGE("This context was'nt created, it's now done");
+             INFOS("This context was'nt created, it's now done");
                }
        }
     }
@@ -543,31 +567,31 @@ bool SALOME_NamingService::Change_Directory(const char* Path)
          _return_code = false;
          CosNaming::Name n = ex.rest_of_name;
          if (ex.why == CosNaming::NamingContext::missing_node)
-           MESSAGE( "Change_Directory() : " << (char *) n[0].id
+           INFOS( "Change_Directory() : " << (char *) n[0].id
                  << " (" << (char *) n[0].kind << ") not found")
          if (ex.why == CosNaming::NamingContext::not_context)
-           MESSAGE("Change_Directory() : " << (char *) n[0].id
+           INFOS("Change_Directory() : " << (char *) n[0].id
                 << " (" << (char *) n[0].kind
                 << ") is not a context" )
          if (ex.why == CosNaming::NamingContext::not_object)
-           MESSAGE( "Change_Directory() : " << (char *) n[0].id
+           INFOS( "Change_Directory() : " << (char *) n[0].id
                 << " (" << (char *) n[0].kind
                 << ") is not an object" )
        }
       catch(CosNaming::NamingContext::CannotProceed&)
        {
          _return_code = false;
-         MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" )
+         INFOS( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" )
        } 
       catch(CosNaming::NamingContext::InvalidName&) 
        {
          _return_code = false;
-         MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" )
+         INFOS( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" )
        }
       catch(CORBA::COMM_FAILURE&)
        {
          _return_code = false;
-         MESSAGE( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact"
+         INFOS( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact"
               << "the naming service")
          throw ServiceUnreachable();
        }
@@ -611,7 +635,7 @@ char* SALOME_NamingService::Current_Directory()
     }
   catch(CORBA::COMM_FAILURE&)
     {
-      MESSAGE("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact"
+      INFOS("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact"
           << " the naming service" )
       throw ServiceUnreachable();
     }
@@ -665,7 +689,7 @@ void SALOME_NamingService::list()
        }
       catch (ServiceUnreachable&)
        {
-         MESSAGE( "!!!list(): ServiceUnreachable" )
+         INFOS( "!!!list(): ServiceUnreachable" )
          throw ServiceUnreachable(); 
        }
 
@@ -698,6 +722,7 @@ vector<string> SALOME_NamingService::list_directory()
   CosNaming::Binding_var _binding ;
   CosNaming::NamingContext_var _ref_context = _current_context;
   _current_context->list(nb, _binding_list, _binding_iterator) ;
+  if (_binding_iterator->_is_nil()) return _list;
 
   while (_binding_iterator->next_one(_binding)) {
     CosNaming::Name _bindingName = _binding->binding_name;
@@ -756,28 +781,28 @@ void SALOME_NamingService::Destroy_Name(const char* Path)
        {
          CosNaming::Name n = ex.rest_of_name;
          if (ex.why == CosNaming::NamingContext::missing_node)
-           MESSAGE(  "Destroy_Name() : " << (char *) n[0].id
+           INFOS(  "Destroy_Name() : " << (char *) n[0].id
                  << " (" << (char *) n[0].kind << ") not found" )
          if (ex.why == CosNaming::NamingContext::not_context)
-           MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+           INFOS( "Destroy_Name() : " << (char *) n[0].id
                 << " (" << (char *) n[0].kind
                 << ") is not a context" )
          if (ex.why == CosNaming::NamingContext::not_object)
-           MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+           INFOS( "Destroy_Name() : " << (char *) n[0].id
                 << " ("  << (char *) n[0].kind
                 << ") is not an object" )
        } 
       catch (CosNaming::NamingContext::InvalidName &) 
        {
-         MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" )
+         INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" )
        }
       catch (CosNaming::NamingContext::CannotProceed &)
        {
-         MESSAGE( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" )
+         INFOS( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" )
        }
       catch(CORBA::COMM_FAILURE&)
        {
-         MESSAGE( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact"
+         INFOS( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact"
               << " the naming service")
          throw ServiceUnreachable();
        }
@@ -800,28 +825,28 @@ void SALOME_NamingService::Destroy_Name(const char* Path)
     {
       CosNaming::Name n = ex.rest_of_name;
       if (ex.why == CosNaming::NamingContext::missing_node)
-       MESSAGE(  "Destroy_Name() : " << (char *) n[0].id
+       INFOS(  "Destroy_Name() : " << (char *) n[0].id
              << " (" << (char *) n[0].kind << ") not found" )
       if (ex.why == CosNaming::NamingContext::not_context)
-       MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+       INFOS( "Destroy_Name() : " << (char *) n[0].id
             << " (" << (char *) n[0].kind
             << ") is not a context" )
       if (ex.why == CosNaming::NamingContext::not_object)
-       MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+       INFOS( "Destroy_Name() : " << (char *) n[0].id
             << " ("  << (char *) n[0].kind
             << ") is not an object" )
     }
   catch(CosNaming::NamingContext::CannotProceed&)
     {
-      MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed")
+      INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed")
     } 
   catch(CosNaming::NamingContext::InvalidName&) 
     {
-      MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName")
+      INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName")
     }
   catch(CORBA::COMM_FAILURE&)
     {
-      MESSAGE( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" 
+      INFOS( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" 
           << " the naming service") 
       throw ServiceUnreachable();
     }
@@ -879,28 +904,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path)
        {
          CosNaming::Name n = ex.rest_of_name;
          if (ex.why == CosNaming::NamingContext::missing_node)
-           MESSAGE(  "Destroy_Directory() : " << (char *) n[0].id
+           INFOS(  "Destroy_Directory() : " << (char *) n[0].id
                  << " (" << (char *) n[0].kind << ") not found")
          if (ex.why == CosNaming::NamingContext::not_context)
-           MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+           INFOS( "Destroy_Directory() : " << (char *) n[0].id
                 << " (" << (char *) n[0].kind
                 << ") is not a context" )
          if (ex.why == CosNaming::NamingContext::not_object)
-           MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+           INFOS( "Destroy_Directory() : " << (char *) n[0].id
                 << " ("  << (char *) n[0].kind
                 << ") is not an object" )
        } 
       catch (CosNaming::NamingContext::InvalidName &) 
        {
-         MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
+         INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
        }
       catch (CosNaming::NamingContext::CannotProceed &)
        {
-         MESSAGE("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
+         INFOS("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
        }
       catch(CORBA::COMM_FAILURE&)
        {
-         MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
+         INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
               << " the naming service" )
          throw ServiceUnreachable();
        }
@@ -923,28 +948,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path)
     {
       CosNaming::Name n = ex.rest_of_name;
       if (ex.why == CosNaming::NamingContext::missing_node)
-       MESSAGE(  "Destroy_Directory() : " << (char *) n[0].id
+       INFOS(  "Destroy_Directory() : " << (char *) n[0].id
              << " (" << (char *) n[0].kind << ") not found" )
       if (ex.why == CosNaming::NamingContext::not_context)
-       MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+       INFOS( "Destroy_Directory() : " << (char *) n[0].id
             << " (" << (char *) n[0].kind
             << ") is not a context" )
       if (ex.why == CosNaming::NamingContext::not_object)
-       MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+       INFOS( "Destroy_Directory() : " << (char *) n[0].id
             << " ("  << (char *) n[0].kind
             << ") is not an object" )
     } 
   catch (CosNaming::NamingContext::InvalidName &) 
     {
-      MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
+      INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
     }
   catch (CosNaming::NamingContext::CannotProceed &)
     {
-      MESSAGE( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
+      INFOS( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
     }
   catch(CORBA::COMM_FAILURE&)
     {
-      MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
+      INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
           << " the naming service" )
       throw ServiceUnreachable();
     }
@@ -958,12 +983,12 @@ void SALOME_NamingService::Destroy_Directory(const char* Path)
     }
   catch(CosNaming::NamingContext::NotEmpty&)
     {
-      MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty "
+      INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty "
           << Path << " is not empty" )
     } 
   catch(CORBA::COMM_FAILURE&)
     {
-      MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : "
+      INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : "
           << "unable to contact the naming service") 
       throw ServiceUnreachable();
     }
@@ -978,28 +1003,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path)
     {
       CosNaming::Name n = ex.rest_of_name;
       if (ex.why == CosNaming::NamingContext::missing_node)
-       MESSAGE(  "Destroy_Directory() : " << (char *) n[0].id
+       INFOS(  "Destroy_Directory() : " << (char *) n[0].id
              << " (" << (char *) n[0].kind << ") not found" )
       if (ex.why == CosNaming::NamingContext::not_context)
-       MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+       INFOS( "Destroy_Directory() : " << (char *) n[0].id
             << " (" << (char *) n[0].kind
             << ") is not a context" )
       if (ex.why == CosNaming::NamingContext::not_object)
-       MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+       INFOS( "Destroy_Directory() : " << (char *) n[0].id
             << " ("  << (char *) n[0].kind
             << ") is not an object" )
     }
   catch(CosNaming::NamingContext::CannotProceed&)
     {
-      MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed")
+      INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed")
     } 
   catch(CosNaming::NamingContext::InvalidName&) 
     {
-      MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName")
+      INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName")
     }
   catch(CORBA::COMM_FAILURE&)
     {
-      MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" 
+      INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" 
           << " the naming service") 
       throw ServiceUnreachable();
     }