From b2bc1bc1202f431f3c1292f6863a9d809655a6ef Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 24 Dec 2021 21:48:30 +0300 Subject: [PATCH] Improve interface --- idl/SMESH_Homard.idl | 42 ------------------------ src/SMESH_I/SMESH_Homard_i.cxx | 59 ++++++++++++++++++---------------- src/SMESH_I/SMESH_Homard_i.hxx | 19 ++++------- 3 files changed, 39 insertions(+), 81 deletions(-) diff --git a/idl/SMESH_Homard.idl b/idl/SMESH_Homard.idl index 2783ffbca..10d190326 100644 --- a/idl/SMESH_Homard.idl +++ b/idl/SMESH_Homard.idl @@ -87,42 +87,6 @@ module SMESHHOMARD string GetCaseCreation() raises (SALOME::SALOME_Exception); }; - interface HOMARD_Iteration : SALOME::GenericObj - { - // Generalites - void SetName(in string Name) raises (SALOME::SALOME_Exception); - string GetName() raises (SALOME::SALOME_Exception); - - // Caracteristiques - void SetDirNameLoc(in string NomDir) raises (SALOME::SALOME_Exception); - string GetDirNameLoc() raises (SALOME::SALOME_Exception); - - string GetDirName() raises (SALOME::SALOME_Exception); - - void SetNumber(in long NumIter) raises (SALOME::SALOME_Exception); - long GetNumber() raises (SALOME::SALOME_Exception); - - void SetState(in long State) raises (SALOME::SALOME_Exception); - long GetState() raises (SALOME::SALOME_Exception); - - void SetMeshName(in string NomMesh) raises (SALOME::SALOME_Exception); - string GetMeshName() raises (SALOME::SALOME_Exception); - - void SetMeshFile(in string MeshFile) raises (SALOME::SALOME_Exception); - string GetMeshFile() raises (SALOME::SALOME_Exception); - - // Fichier des messages - void SetLogFile(in string LogFile) raises (SALOME::SALOME_Exception); - string GetLogFile() raises (SALOME::SALOME_Exception); - - void SetFileInfo(in string FileInfo) raises (SALOME::SALOME_Exception); - string GetFileInfo() raises (SALOME::SALOME_Exception); - - // Drivers - void SetInfoCompute(in long MessInfo) raises (SALOME::SALOME_Exception); - long GetInfoCompute() raises (SALOME::SALOME_Exception); - }; - interface HOMARD_Cas : SALOME::GenericObj { string GetName() raises (SALOME::SALOME_Exception); @@ -144,8 +108,6 @@ module SMESHHOMARD in string Group) raises (SALOME::SALOME_Exception); ListBoundaryGroupType GetBoundaryGroup() raises (SALOME::SALOME_Exception); void SupprBoundaryGroup() raises (SALOME::SALOME_Exception); - - void AddIteration (in string IterName) raises (SALOME::SALOME_Exception); }; interface HOMARD_Gen : SALOME::GenericObj @@ -192,12 +154,8 @@ module SMESHHOMARD // A.2. Information HOMARD_Boundary GetBoundary(in string BoundaryName) raises (SALOME::SALOME_Exception); HOMARD_Cas GetCase() raises (SALOME::SALOME_Exception); - HOMARD_Iteration GetIteration(in long numIter) raises (SALOME::SALOME_Exception); listeBoundarys GetAllBoundarysName() raises (SALOME::SALOME_Exception); - // B. CreateIteration - HOMARD_Iteration CreateIteration() raises (SALOME::SALOME_Exception); - void InvalideBoundary (in string BoundaryName) raises (SALOME::SALOME_Exception); long DeleteBoundary (in string BoundaryName) raises (SALOME::SALOME_Exception); diff --git a/src/SMESH_I/SMESH_Homard_i.cxx b/src/SMESH_I/SMESH_Homard_i.cxx index d4f2e6d55..e395e4b86 100644 --- a/src/SMESH_I/SMESH_Homard_i.cxx +++ b/src/SMESH_I/SMESH_Homard_i.cxx @@ -380,7 +380,8 @@ void HOMARD_Cas_i::SetDirName(const char* NomDir) throw SALOME::SALOME_Exception(es); } // D. En cas de reprise, deplacement du point de depart - SMESHHOMARD::HOMARD_Iteration_ptr Iter0 = _gen_i->GetIteration(0); + HOMARD_Gen_i* aGenImpl = SMESH::DownCast(_gen_i); + HOMARD_Iteration_i* Iter0 = aGenImpl->GetIteration(0); int state = Iter0->GetNumber(); if (state != 0) { // GetState() MESSAGE ("etat : " << state); @@ -660,7 +661,6 @@ void HOMARD_Cas_i::AddIteration(const char* NomIteration) */ //============================================================================= HOMARD_Iteration_i::HOMARD_Iteration_i() - : SALOME::GenericObj_i(SMESH_Gen_i::GetPOA()) { MESSAGE("Default constructor, not for use"); ASSERT(0); @@ -671,7 +671,6 @@ HOMARD_Iteration_i::HOMARD_Iteration_i() */ //============================================================================= HOMARD_Iteration_i::HOMARD_Iteration_i(SMESHHOMARD::HOMARD_Gen_var engine) - : SALOME::GenericObj_i(SMESH_Gen_i::GetPOA()) { MESSAGE("constructor"); _gen_i = engine; @@ -810,6 +809,8 @@ CORBA::Long HOMARD_Iteration_i::GetInfoCompute() */ //============================================================================= HOMARD_Gen_i::HOMARD_Gen_i() : SALOME::GenericObj_i(SMESH_Gen_i::GetPOA()), + myIteration0(NULL), + myIteration1(NULL), _ConfType(0), _KeepMedOUT(true), _PublishMeshOUT(false), @@ -884,10 +885,13 @@ CORBA::Long HOMARD_Gen_i::DeleteIteration(int numIter) MESSAGE ("DeleteIteration : numIter = " << numIter); if (numIter == 0) { - myIteration0 = SMESHHOMARD::HOMARD_Iteration::_nil(); + if (myIteration0 != NULL) { + delete myIteration0; + myIteration0 = NULL; + } } else { - if (!CORBA::is_nil(myIteration1)) { + if (myIteration1 != NULL) { // Invalide Iteration if (myIteration1->GetState() > 0) { myIteration1->SetState(1); @@ -909,7 +913,8 @@ CORBA::Long HOMARD_Gen_i::DeleteIteration(int numIter) } } - myIteration1 = SMESHHOMARD::HOMARD_Iteration::_nil(); + delete myIteration1; + myIteration1 = NULL; } } @@ -956,24 +961,26 @@ void HOMARD_Gen_i::AssociateCaseIter(int numIter, const char* labelIter) } if (numIter == 0) { - if (CORBA::is_nil(myIteration0)) { + if (myIteration0 == NULL) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; es.text = "Invalid iteration"; throw SALOME::SALOME_Exception(es); } - myCase->AddIteration(myIteration0->GetName()); + HOMARD_Cas_i* aCaseImpl = SMESH::DownCast(myCase); + aCaseImpl->AddIteration(myIteration0->GetName()); } else { - if (CORBA::is_nil(myIteration1)) { + if (myIteration1 == NULL) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; es.text = "Invalid iteration"; throw SALOME::SALOME_Exception(es); } - myCase->AddIteration(myIteration1->GetName()); + HOMARD_Cas_i* aCaseImpl = SMESH::DownCast(myCase); + aCaseImpl->AddIteration(myIteration1->GetName()); } } @@ -1016,15 +1023,15 @@ SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase() return SMESHHOMARD::HOMARD_Cas::_duplicate(myCase); } //============================================================================= -SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(int numIter) +HOMARD_Iteration_i* HOMARD_Gen_i::GetIteration(int numIter) { if (numIter == 0) { - ASSERT(!CORBA::is_nil(myIteration0)); - return SMESHHOMARD::HOMARD_Iteration::_duplicate(myIteration0); + ASSERT(myIteration0); + return myIteration0; } - ASSERT(!CORBA::is_nil(myIteration1)); - return SMESHHOMARD::HOMARD_Iteration::_duplicate(myIteration1); + ASSERT(myIteration1); + return myIteration1; } //============================================================================= @@ -1040,13 +1047,11 @@ SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase() return aCase._retn(); } //============================================================================= -SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration() +HOMARD_Iteration_i* HOMARD_Gen_i::newIteration() { SMESHHOMARD::HOMARD_Gen_var engine = POA_SMESHHOMARD::HOMARD_Gen::_this(); HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(engine); - SMESHHOMARD::HOMARD_Iteration_var aIter = - SMESHHOMARD::HOMARD_Iteration::_narrow(aServant->_this()); - return aIter._retn(); + return aServant; } //============================================================================= SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary() @@ -1261,9 +1266,9 @@ SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* MeshName, //============================================================================= // Create Iteration1 //============================================================================= -SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration() +HOMARD_Iteration_i* HOMARD_Gen_i::CreateIteration() { - if (CORBA::is_nil(myIteration0)) { + if (myIteration0 == NULL) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; es.text = "The parent iteration is not defined."; @@ -1278,12 +1283,12 @@ SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration() } const char* nomDirCase = myCase->GetDirName(); - if (!myIteration1->_is_nil()) { + if (myIteration1 != NULL) { DeleteIteration(1); } myIteration1 = newIteration(); - if (CORBA::is_nil(myIteration1)) { + if (myIteration1 == NULL) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; es.text = "Unable to create the iteration 1"; @@ -1323,7 +1328,7 @@ SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration() std::string label = "IterationHomard_" + nomIterParent; AssociateCaseIter(1, label.c_str()); - return SMESHHOMARD::HOMARD_Iteration::_duplicate(myIteration1); + return myIteration1; } //============================================================================= SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, @@ -1527,7 +1532,7 @@ CORBA::Long HOMARD_Gen_i::Compute() if (_LogInFile) myIteration1->SetLogFile(_LogFile.c_str()); // A.1. L'objet iteration - ASSERT(!CORBA::is_nil(myIteration1)); + ASSERT(myIteration1); // A.2. Controle de la possibilite d'agir // A.2.1. Etat de l'iteration @@ -1691,7 +1696,7 @@ CORBA::Long HOMARD_Gen_i::Compute() PythonDump(); // Delete log file, if required - if (!myIteration1->_is_nil()) { + if (myIteration1 != NULL) { MESSAGE("myIteration1->GetLogFile() = " << myIteration1->GetLogFile()); if (_LogInFile && _RemoveLogOnSuccess) { // Remove log file on success @@ -1747,7 +1752,7 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(SMESHHOMARDImpl::HomardDriver* myDriver) if (NumeIter < 11) { siter = "0" + siter; } // B. L'iteration parent - ASSERT(!CORBA::is_nil(myIteration0)); + ASSERT(myIteration0); // C. Le sous-répertoire de l'iteration precedente char* DirComputePa = ComputeDirPaManagement(); diff --git a/src/SMESH_I/SMESH_Homard_i.hxx b/src/SMESH_I/SMESH_Homard_i.hxx index ad0ea90b2..ad03cad48 100644 --- a/src/SMESH_I/SMESH_Homard_i.hxx +++ b/src/SMESH_I/SMESH_Homard_i.hxx @@ -135,8 +135,7 @@ private: SMESHHOMARD::HOMARD_Gen_var _gen_i; }; -class SMESH_I_EXPORT HOMARD_Iteration_i : public virtual SALOME::GenericObj_i, - public virtual POA_SMESHHOMARD::HOMARD_Iteration +class SMESH_I_EXPORT HOMARD_Iteration_i { public: HOMARD_Iteration_i(SMESHHOMARD::HOMARD_Gen_var gen_i); @@ -172,10 +171,6 @@ public: void SetFileInfo(const char* FileInfo); char* GetFileInfo(); - // Liens avec les autres iterations - void LinkNextIteration(const char* NomIteration); - void UnLinkNextIteration(const char* NomIteration); - // Liens avec les autres structures void SetCaseName(const char* NomCas); char* GetCaseName(); @@ -236,12 +231,12 @@ public: const char* FileName, const char* theWorkingDir); - SMESHHOMARD::HOMARD_Iteration_ptr CreateIteration(); + HOMARD_Iteration_i* CreateIteration(); // Les informations SMESHHOMARD::HOMARD_Boundary_ptr GetBoundary (const char* nomBoundary); SMESHHOMARD::HOMARD_Cas_ptr GetCase (); - SMESHHOMARD::HOMARD_Iteration_ptr GetIteration (CORBA::Long numIter); + HOMARD_Iteration_i* GetIteration (CORBA::Long numIter); SMESHHOMARD::listeBoundarys* GetAllBoundarysName(); @@ -285,15 +280,15 @@ public: private: SMESHHOMARD::HOMARD_Boundary_ptr newBoundary(); SMESHHOMARD::HOMARD_Cas_ptr newCase(); - SMESHHOMARD::HOMARD_Iteration_ptr newIteration(); + HOMARD_Iteration_i* newIteration(); void CleanCase(); private: SMESHHOMARDImpl::HOMARD_Gen* myHomard; + HOMARD_Iteration_i* myIteration0; + HOMARD_Iteration_i* myIteration1; + SMESHHOMARD::HOMARD_Cas_var myCase; std::map _mesBoundarys; - SMESHHOMARD::HOMARD_Iteration_var myIteration0; - SMESHHOMARD::HOMARD_Iteration_var myIteration1; - SMESHHOMARD::HOMARD_Cas_var myCase; // Preferences int _ConfType; // Le type de conformite ou non conformite -- 2.39.2