Salome HOME
Fix bug in test on 24 cores CPU test
[modules/kernel.git] / src / ModuleCatalog / SALOME_ModuleCatalog_Acomponent_impl.cxx
index 228c4953809ec02110c02b1cd00490e33bf9a95f..fecc12beeac9453682d31dacf47fcdf3bf8b4f98 100644 (file)
@@ -1,40 +1,38 @@
-//  SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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, or (at your option) any later version.
 //
-//  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 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+//  SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
 //  File   : SALOME_ModuleCatalog_Acomponent_impl.cxx
 //  Author : Estelle Deville
 //  Module : SALOME
 //  $Header$
-
+//
 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
 
 #include "Utils_ExceptHandlers.hxx"
-UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound);
+UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound)
 
 #include "utilities.h"
 
-using namespace std;
-
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
@@ -44,13 +42,12 @@ static int MYDEBUG = 0;
 //----------------------------------------------------------------------
 // Function : SALOME_ModuleCatalog_AcomponentImpl
 // Purpose  : Constructor
-//            Affect the component name, type,icone,  a bool to define 
-//            if it's multistudy or not.
+//            Affect the component name, type,icon
 //            Affect too the constraint and the interfaces of the component
-//            and the pathes prefixes for all computers
+//            and the path prefixes for all computers
 //----------------------------------------------------------------------  
 SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl
-(SALOME_ModuleCatalog::Component &C) : _Component(C)
+(SALOME_ModuleCatalog::ComponentDef &C) : _Component(C)
 {
   if(MYDEBUG) BEGIN_OF("SALOME_ModuleCatalog_AcomponentImpl");
 
@@ -92,7 +89,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList()
     {
       _list[ind] = CORBA::string_dup(_Component.interfaces[ind].interfacename);
       if(MYDEBUG) MESSAGE("The component " << _Component.name 
-                         << " contains " << _list[ind] << " as interface");
+                          << " contains " << _list[ind] << " as interface");
     }
   
   if(MYDEBUG) END_OF("GetInterfaceList");
@@ -105,13 +102,12 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList()
 //----------------------------------------------------------------------
 SALOME_ModuleCatalog::DefinitionInterface*
 SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename)
-                                     throw(SALOME_ModuleCatalog::NotFound)
 {
   if(MYDEBUG) BEGIN_OF("GetInterface");
   if(MYDEBUG) SCRUTE(interfacename);
 
   SALOME_ModuleCatalog::DefinitionInterface *_interface =
-         new SALOME_ModuleCatalog::DefinitionInterface;
+          new SALOME_ModuleCatalog::DefinitionInterface;
 
   bool _find = false ;
   
@@ -119,21 +115,21 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename)
   for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++)
     {
       SALOME_ModuleCatalog::DefinitionInterface &I
-       = _Component.interfaces[ind];
+        = _Component.interfaces[ind];
 
       if (strcmp(interfacename, I.interfacename) == 0)
-       {
-         // wanted interface
-         _find = true ;
-         duplicate(*_interface, I);
-       }
+        {
+          // wanted interface
+          _find = true ;
+          duplicate(*_interface, I);
+        }
     }
 
   if(MYDEBUG) SCRUTE(_find);
   if (!_find)
     {
       // The interface was not found, the exception should be thrown
-      string message = "The interface";
+               std::string message = "The interface";
       message += interfacename;
       message += " of the component ";
       message += _Component.name;
@@ -156,7 +152,6 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename)
 //----------------------------------------------------------------------
 SALOME_ModuleCatalog::ListOfServices* 
 SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename)
-                                     throw(SALOME_ModuleCatalog::NotFound)
 {
   if(MYDEBUG) BEGIN_OF("GetServiceList");
   if(MYDEBUG) SCRUTE(interfacename);
@@ -173,25 +168,25 @@ SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename)
       SALOME_ModuleCatalog::DefinitionInterface & I = _Component.interfaces[ind];
 
       if (strcmp(interfacename, I.interfacename) == 0)
-       {
-         _find = true ;
-         // wanted interface
-         // Get the list of services name for this interface
-         unsigned int _length_services = I.interfaceservicelist.length();
-         _list->length(_length_services);
-         for (unsigned int ind1 = 0; ind1 < _length_services ; ind1++)
-           {
-             _list[ind1] = CORBA::string_dup(I.interfaceservicelist[ind1].ServiceName);
-             if(MYDEBUG) MESSAGE("The interface " << interfacename << " of the component " 
-                                 << _Component.name << " contains " << _list[ind1] << " as a service") 
-           }
-       }
+        {
+          _find = true ;
+          // wanted interface
+          // Get the list of services name for this interface
+          unsigned int _length_services = I.interfaceservicelist.length();
+          _list->length(_length_services);
+          for (unsigned int ind1 = 0; ind1 < _length_services ; ind1++)
+            {
+              _list[ind1] = CORBA::string_dup(I.interfaceservicelist[ind1].ServiceName);
+              if(MYDEBUG) MESSAGE("The interface " << interfacename << " of the component " 
+                                  << _Component.name << " contains " << _list[ind1] << " as a service") 
+            }
+        }
     }
 
  if (!_find)
     {
       // The interface was not found, the exception should be thrown
-      string message = "The interface";
+      std::string message = "The interface";
       message += interfacename;
       message += " of the component ";
       message += _Component.name;
@@ -211,8 +206,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename)
 //----------------------------------------------------------------------
 SALOME_ModuleCatalog::Service* 
 SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, 
-                                               const char* servicename) 
-                                     throw(SALOME_ModuleCatalog::NotFound)
+                                                const char* servicename) 
 {
   if(MYDEBUG) BEGIN_OF("GetService");
   if(MYDEBUG) SCRUTE(interfacename);
@@ -233,32 +227,32 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename,
 
       SALOME_ModuleCatalog::DefinitionInterface &I = _Component.interfaces[ind];
       if (strcmp(interfacename, I.interfacename) == 0)
-       {
-         // wanted interface
-         // looking for the specified service
-         for (unsigned int ind1 = 0; ind1 <  I.interfaceservicelist.length() ; ind1++)
-           {
-             SALOME_ModuleCatalog::Service &S = I.interfaceservicelist[ind1];
-             if(MYDEBUG) SCRUTE(ind1);
-             if(MYDEBUG) SCRUTE(S.ServiceName);
-
-             if (strcmp(servicename, S.ServiceName) == 0)
-             {
-               // Wanted Service
-               // Affect the service to be returned
-               _find = true ;
-               duplicate(*service, S);
-             }
-           }
-
-       }
+        {
+          // wanted interface
+          // looking for the specified service
+          for (unsigned int ind1 = 0; ind1 <  I.interfaceservicelist.length() ; ind1++)
+            {
+              SALOME_ModuleCatalog::Service &S = I.interfaceservicelist[ind1];
+              if(MYDEBUG) SCRUTE(ind1);
+              if(MYDEBUG) SCRUTE(S.ServiceName);
+
+              if (strcmp(servicename, S.ServiceName) == 0)
+              {
+                // Wanted Service
+                // Affect the service to be returned
+                _find = true ;
+                duplicate(*service, S);
+              }
+            }
+
+        }
     }
   
   if(MYDEBUG) SCRUTE(_find);
   if (!_find)
     {
       // The interface was not found, the exception should be thrown
-      string message = "The service";
+      std::string message = "The service";
       message += servicename;
       message += " of the interface ";
       message += interfacename;
@@ -279,7 +273,6 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename,
 //----------------------------------------------------------------------
 SALOME_ModuleCatalog::Service* 
 SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename) 
-                                     throw(SALOME_ModuleCatalog::NotFound)
 {
   if(MYDEBUG) BEGIN_OF("GetDefaultService");
   if(MYDEBUG) SCRUTE(interfacename);
@@ -294,27 +287,27 @@ SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename
   for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++)
     {
       if (strcmp(interfacename, _Component.interfaces[ind].interfacename) == 0)
-       {
-         // wanted interface
-         // looking for the defautl service of the wanted interface
-         for (unsigned int ind1 = 0; ind1 <  _Component.interfaces[ind].interfaceservicelist.length() ; ind1++)
-           {
-             if (_Component.interfaces[ind].interfaceservicelist[ind1].Servicebydefault)
-             {
-               // Default Service
-               // affect the service to be returned
-               _find = true ;
-               duplicate(*_service, _Component.interfaces[ind].interfaceservicelist[ind1]);
-             }
-           }
-
-       }
+        {
+          // wanted interface
+          // looking for the default service of the wanted interface
+          for (unsigned int ind1 = 0; ind1 <  _Component.interfaces[ind].interfaceservicelist.length() ; ind1++)
+            {
+              if (_Component.interfaces[ind].interfaceservicelist[ind1].Servicebydefault)
+              {
+                // Default Service
+                // affect the service to be returned
+                _find = true ;
+                duplicate(*_service, _Component.interfaces[ind].interfaceservicelist[ind1]);
+              }
+            }
+
+        }
     }
 
   if (!_find)
     {
       // The service was not found, the exception should be thrown
-      string message = "The default service of the interface ";
+      std::string message = "The default service of the interface ";
       message += interfacename;
       message += " of the component ";
       message += _Component.name;
@@ -333,7 +326,6 @@ SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename
 //----------------------------------------------------------------------
 char* 
 SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) 
-                                     throw(SALOME_ModuleCatalog::NotFound)
 {
   if(MYDEBUG) BEGIN_OF("GetPathPrefix");
   if(MYDEBUG) SCRUTE(machinename);
@@ -348,21 +340,21 @@ SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename)
   for (unsigned int ind = 0 ; ind < _Component.paths.length() ; ind++)
     {
       if (strcmp(machinename, _Component.paths[ind].machine) == 0)
-           {
-             _find = true ;
-             // Wanted computer
-             // affect the path to be returned
-               const char* _temp = _Component.paths[ind].path ;
-               _path = new char[strlen(_temp)+1];
-               strcpy(_path,_temp);
-           }
+            {
+              _find = true ;
+              // Wanted computer
+              // affect the path to be returned
+                const char* _temp = _Component.paths[ind].path ;
+                _path = new char[strlen(_temp)+1];
+                strcpy(_path,_temp);
+            }
      }
 
    if(MYDEBUG) SCRUTE(_find);
    if (!_find)
      {
        // The computer was not found, the exception should be thrown
-       string message = "The computer ";
+       std::string message = "The computer ";
        message += machinename;
        message += " was not found in the catalog associated to the component ";
        message += _Component.name;
@@ -402,22 +394,21 @@ char* SALOME_ModuleCatalog_AcomponentImpl::componentusername()
 }
 
 //----------------------------------------------------------------------
-// Function : multistudy
-// Purpose  : define if a component can be multistudy or not
+// Function : implementation type
+// Purpose  : return the implementation type :  C++ (dyn lib), Python (module) or executable
 //----------------------------------------------------------------------
-CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy()
+SALOME_ModuleCatalog::ImplType SALOME_ModuleCatalog_AcomponentImpl::implementation_type()
 {
-  return _Component.multistudy ;
+  return _Component.implementationType ;
 }
 
-
 //----------------------------------------------------------------------
-// Function : implementation type
-// Purpose  : define if a component is implemented in C++ or Python
+// Function : implementation name
+// Purpose  : return the implementation name to exec if the default one is not convenient
 //----------------------------------------------------------------------
-CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::implementation_type()
+char* SALOME_ModuleCatalog_AcomponentImpl::implementation_name()
 {
-  return _Component.implementationType ;
+  return _Component.implname ;
 }
 
 //----------------------------------------------------------------------
@@ -488,44 +479,32 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate
 
   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
     duplicate(S_out.ServiceinParameter[ind2],
-             S_in.ServiceinParameter[ind2]);
+              S_in.ServiceinParameter[ind2]);
   
   // duplicate out Parameters
   _length = S_in.ServiceoutParameter.length();
   S_out.ServiceoutParameter.length(_length);
 
-#ifndef WNT  
   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
-#else
-  for (ind2 = 0; ind2 < _length ; ind2 ++)
-#endif
     duplicate(S_out.ServiceoutParameter[ind2],
-             S_in.ServiceoutParameter[ind2]);
+              S_in.ServiceoutParameter[ind2]);
   
   // duplicate in DataStreamParameters
   _length = S_in.ServiceinDataStreamParameter.length();
   S_out.ServiceinDataStreamParameter.length(_length);
 
-#ifndef WNT
   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
-#else
-  for (ind2 = 0; ind2 < _length ; ind2 ++)
-#endif
     duplicate(S_out.ServiceinDataStreamParameter[ind2],
-             S_in.ServiceinDataStreamParameter[ind2]);
+              S_in.ServiceinDataStreamParameter[ind2]);
   
   // duplicate out DataStreamParameters
   _length = S_in.ServiceoutDataStreamParameter.length();
   if(MYDEBUG) SCRUTE(_length);
   S_out.ServiceoutDataStreamParameter.length(_length);
   
-#ifndef WNT
   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
-#else
-  for (ind2 = 0; ind2 < _length ; ind2 ++)
-#endif
     duplicate(S_out.ServiceoutDataStreamParameter[ind2],
-             S_in.ServiceoutDataStreamParameter[ind2]);
+              S_in.ServiceoutDataStreamParameter[ind2]);
 }
 
 
@@ -543,7 +522,7 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate
   
   for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
     duplicate(I_out.interfaceservicelist[ind1],
-             I_in.interfaceservicelist[ind1]);
+              I_in.interfaceservicelist[ind1]);
 }