Salome HOME
Updated copyright comment
[modules/smesh.git] / src / SMESHClient / SMESH_Client.cxx
index f0473ff66ae43334ce18e62f279260f7d87b7766..f5251c2ff46e8c38fb17f26817689ea5fc07888c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -28,9 +28,9 @@
 #include "SMESHDS_Mesh.hxx"
 #include "SMESHDS_Script.hxx"
 #include "SMESH_Mesh.hxx"
-#include "SMESH_Component_Generator.hxx"
 
 #include "SALOME_NamingService.hxx"
+#include "SALOME_Fake_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 
 #include <SALOMEconfig.h>
@@ -39,6 +39,7 @@
 #include CORBA_SERVER_HEADER(SALOME_Exception)
 
 #include "Basics_Utils.hxx"
+#include "KernelBasis.hxx"
 #include "utilities.h"
 
 #ifdef WIN32
@@ -48,6 +49,7 @@
 #endif
 
 #include <stdexcept>
+#include <memory>
 
 #ifndef EXCEPTION
 #define EXCEPTION(TYPE, MSG) {\
 }
 #endif
 
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
 namespace
 {
   using std::runtime_error;
@@ -787,31 +783,30 @@ SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
 
   if(CORBA::is_nil(aMeshGen.in()))
   {
-    Engines::EngineComponent_var isCompoInSSLMode = GetSMESHInstanceHasThis();
-    if( CORBA::is_nil(isCompoInSSLMode) )
-    {
 #ifdef WIN32
-      long aClientPID = (long)_getpid();
+    long aClientPID = (long)_getpid();
 #else
-      long aClientPID =  (long)getpid();
+    long aClientPID =  (long)getpid();
 #endif
 
-      SALOME_NamingService aNamingService(theORB);
-      SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
-      Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
-      aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
-
-      std::string aClientHostName = Kernel_Utils::GetHostname();
-      Engines::Container_var aServerContainer = aMeshGen->GetContainerRef();
-      CORBA::String_var aServerHostName = aServerContainer->getHostName();
-      CORBA::Long aServerPID = aServerContainer->getPID();
-      aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in()));
+    std::unique_ptr<SALOME_NamingService_Abstract> aNamingService;
+    if(getSSLMode())
+    {
+      aNamingService.reset(new SALOME_Fake_NamingService);
     }
     else
     {
-      aMeshGen = SMESH::SMESH_Gen::_narrow(isCompoInSSLMode);
+      aNamingService.reset(new SALOME_NamingService(theORB));
     }
-    
+    SALOME_LifeCycleCORBA aLifeCycleCORBA(aNamingService.get());
+    Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
+    aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
+
+    std::string aClientHostName = Kernel_Utils::GetHostname();
+    Engines::Container_var aServerContainer = aMeshGen->GetContainerRef();
+    CORBA::String_var aServerHostName = aServerContainer->getHostName();
+    CORBA::Long aServerPID = aServerContainer->getPID();
+    aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in()));
   }
   theIsEmbeddedMode = aMeshGen->IsEmbeddedMode();
   return aMeshGen;
@@ -828,19 +823,19 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
   mySMESHDSMesh(NULL),
   mySMDSMesh(NULL)
 {
-  if ( MYDEBUG ) MESSAGE("SMESH_Client::SMESH_Client");
+  MESSAGE("SMESH_Client::SMESH_Client");
   myMeshServer->Register();
 
   CORBA::Boolean anIsEmbeddedMode;
   GetSMESHGen(theORB,anIsEmbeddedMode);
   if(anIsEmbeddedMode){
-    if ( MYDEBUG ) MESSAGE("Info: The same process, update mesh by pointer ");
+    MESSAGE("Info: The same process, update mesh by pointer ");
     // just set client mesh pointer to server mesh pointer
     //SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*>(theMesh->GetMeshPtr());
     CORBA::LongLong pointeur = theMesh->GetMeshPtr();
-    if( MYDEBUG ) MESSAGE("SMESH_Client::SMESH_Client pointeur "<<pointeur);
+    MESSAGE("SMESH_Client::SMESH_Client pointeur "<<pointeur);
     SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*> (pointeur);
-    if ( MYDEBUG ) MESSAGE("SMESH_Client::SMESH_Client aMesh "<<aMesh);
+    MESSAGE("SMESH_Client::SMESH_Client aMesh "<<aMesh);
     //if(aMesh->GetMeshDS()->IsEmbeddedMode()){
     if(anIsEmbeddedMode){
       mySMESHDSMesh = aMesh->GetMeshDS();
@@ -898,18 +893,18 @@ SMESH_Client::Update(bool theIsClear)
   bool anIsModified = true;
   if(mySMESHDSMesh)
   {
-    if ( MYDEBUG ) MESSAGE("Update mySMESHDSMesh");
+    MESSAGE("Update mySMESHDSMesh");
     SMESHDS_Script* aScript = mySMESHDSMesh->GetScript();
     anIsModified = aScript->IsModified();
     aScript->SetModified(false);
   }
   else
   {
-    if ( MYDEBUG ) MESSAGE("Update CORBA");
+    MESSAGE("Update CORBA");
     SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear );
     CORBA::Long aLength = aSeq->length();
     anIsModified = aLength > 0;
-    if ( MYDEBUG ) MESSAGE( "Update: length of the script is "<<aLength );
+    MESSAGE( "Update: length of the script is "<<aLength );
 
     if ( !anIsModified )
       return false;
@@ -1020,7 +1015,7 @@ SMESH_Client::Update(bool theIsClear)
       INFOS("Unknown exception was cought !!!");
     }
 
-    if ( MYDEBUG && mySMDSMesh )
+    if (mySMDSMesh )
     {
       MESSAGE("Update - mySMDSMesh->NbNodes() = "<<mySMDSMesh->NbNodes());
       MESSAGE("Update - mySMDSMesh->Nb0DElements() = "<<mySMDSMesh->Nb0DElements());