From ce9c7d44fe5e5d0631103beeea282dd76c330430 Mon Sep 17 00:00:00 2001 From: srn Date: Wed, 23 Aug 2006 14:13:37 +0000 Subject: [PATCH] BugID: PAL10141, added a possibility to lock the study by several processes. --- idl/SALOMEDS.idl | 15 +++++++------ src/SALOMEDS/SALOMEDS_Study.cxx | 24 ++++++++++++++------- src/SALOMEDS/SALOMEDS_Study.hxx | 4 ++-- src/SALOMEDS/SALOMEDS_Study_i.cxx | 18 ++++++++++++---- src/SALOMEDS/SALOMEDS_Study_i.hxx | 4 ++-- src/SALOMEDSClient/SALOMEDSClient_Study.hxx | 4 ++-- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 22 +++++++++++++------ src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx | 12 +++++------ src/SALOMEDSImpl/testDS.cxx | 2 +- 9 files changed, 66 insertions(+), 39 deletions(-) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 58339d9bf..5c270eff9 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -404,10 +404,10 @@ during each working session. /*! - Marks this Study as being locked. The lock status can be checked by method IsStudyLocked - \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that locked the study. + Marks this Study as being locked by the given locker. The lock status can be checked by method IsStudyLocked + \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that locks the study. */ - void SetStudyLock(in string theLockerIDe); + void SetStudyLock(in string theLockerID); /*! Returns True if the Study was marked locked. @@ -415,14 +415,15 @@ during each working session. boolean IsStudyLocked(); /*! - Marks this Study as being unlocked. The lock status can be checked by method IsStudyLocked + Marks this Study as being unlocked by the given locker. The lock status can be checked by method IsStudyLocked + \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that unlocks the study. */ - void UnLockStudy(); + void UnLockStudy(in string theLockerID); /*! - Returns the ID of the Study's locker. + Returns the list iof IDs of the Study's lockers. */ - string GetLockerID(); + ListOfStrings GetLockerID(); }; diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 9cef77820..ff2026894 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -663,21 +663,29 @@ bool SALOMEDS_Study::IsStudyLocked() return isLocked; } -void SALOMEDS_Study::UnLockStudy() +void SALOMEDS_Study::UnLockStudy(const string& theLockerID) { - if(_isLocal) _local_impl->UnLockStudy(); - else _corba_impl->UnLockStudy(); + if(_isLocal) _local_impl->UnLockStudy((char*)theLockerID.c_str()); + else _corba_impl->UnLockStudy((char*)theLockerID.c_str()); } -string SALOMEDS_Study::GetLockerID() +vector SALOMEDS_Study::GetLockerID() { - std::string aLockerID; + std::vector aVector; + int aLength, i; if (_isLocal) { SALOMEDS::Locker lock; - aLockerID = _local_impl->GetLockerID(); + + Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetLockerID(); + aLength = aSeq->Length(); + for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); } - else aLockerID = _corba_impl->GetLockerID(); - return aLockerID; + else { + SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID(); + aLength = aSeq->length(); + for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in()); + } + return aVector; } std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index d07a84dc6..8babf0b6e 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -92,8 +92,8 @@ public: const std::string& theModuleName, int theSavePoint); virtual void SetStudyLock(const std::string& theLockerID); virtual bool IsStudyLocked(); - virtual void UnLockStudy(); - virtual std::string GetLockerID(); + virtual void UnLockStudy(const std::string& theLockerID); + virtual std::vector GetLockerID(); std::string ConvertObjectToIOR(CORBA::Object_ptr theObject); CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 4dc6304f0..dcf58e808 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -840,10 +840,10 @@ bool SALOMEDS_Study_i::IsStudyLocked() * Purpose : */ //============================================================================ -void SALOMEDS_Study_i::UnLockStudy() +void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID) { SALOMEDS::Locker lock; - _impl->UnLockStudy(); + _impl->UnLockStudy(theLockerID); } //============================================================================ @@ -851,10 +851,20 @@ void SALOMEDS_Study_i::UnLockStudy() * Purpose : */ //============================================================================ -char* SALOMEDS_Study_i::GetLockerID() +SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID() { SALOMEDS::Locker lock; - return CORBA::string_dup(_impl->GetLockerID()); + + SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + + Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetLockerID(); + + int aLength = aSeq->Length(); + aResult->length(aLength); + for(int anIndex = 1; anIndex <= aLength; anIndex++) { + aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString()); + } + return aResult._retn(); } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 0f5fb2ec6..e1fdc8656 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -288,9 +288,9 @@ public: virtual bool IsStudyLocked(); - virtual void UnLockStudy(); + virtual void UnLockStudy(const char* theLockerID); - virtual char* GetLockerID(); + virtual SALOMEDS::ListOfStrings* GetLockerID(); virtual char* GetDefaultScript(const char* theModuleName, const char* theShift); diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 178a7ec9a..136bafd35 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -88,8 +88,8 @@ public: const std::string& theModuleName, int theSavePoint) = 0; virtual void SetStudyLock(const std::string& theLockerID) = 0; virtual bool IsStudyLocked() = 0; - virtual void UnLockStudy() = 0; - virtual std::string GetLockerID() = 0; + virtual void UnLockStudy(const std::string& theLockerID) = 0; + virtual std::vector GetLockerID() = 0; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 78fc9a9fc..63b5c2c3a 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -79,7 +79,7 @@ SALOMEDSImpl_Study::SALOMEDSImpl_Study(const Handle(TDocStd_Document)& doc, //Put on the root label a StudyHandle attribute to store the address of this object //It will be used to retrieve the study object by TDF_Label that belongs to the study SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this); - _locker = ""; + _lockers = new TColStd_HSequenceOfAsciiString(); } @@ -1595,7 +1595,7 @@ Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_Study::GetModuleParameters( //============================================================================ void SALOMEDSImpl_Study::SetStudyLock(const char* theLockerID) { - _locker = TCollection_AsciiString((char*)theLockerID); + _lockers->Append(TCollection_AsciiString((char*)theLockerID)); } //============================================================================ @@ -1605,7 +1605,7 @@ void SALOMEDSImpl_Study::SetStudyLock(const char* theLockerID) //============================================================================ bool SALOMEDSImpl_Study::IsStudyLocked() { - return !(_locker==""); + return (_lockers->Length() > 0); } //============================================================================ @@ -1613,9 +1613,17 @@ bool SALOMEDSImpl_Study::IsStudyLocked() * Purpose : */ //============================================================================ -void SALOMEDSImpl_Study::UnLockStudy() +void SALOMEDSImpl_Study::UnLockStudy(const char* theLockerID) { - _locker = ""; + int length = _lockers->Length(), pos = -1; + TCollection_AsciiString id((char*)theLockerID); + for(int i = 1; i<=length; i++) { + if(id == _lockers->Value(i)) { + pos = i; + break; + } + } + if(pos > 0) _lockers->Remove(pos); } //============================================================================ @@ -1623,7 +1631,7 @@ void SALOMEDSImpl_Study::UnLockStudy() * Purpose : */ //============================================================================ -char* SALOMEDSImpl_Study::GetLockerID() +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetLockerID() { - return _locker.ToCString(); + return _lockers; } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index e97109954..3aac4acb4 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -83,10 +83,10 @@ private: TDF_Label _current; bool _autoFill; TCollection_AsciiString _errorCode; - TCollection_AsciiString _locker; - Handle(SALOMEDSImpl_Callback) _cb; - Handle(SALOMEDSImpl_StudyBuilder) _builder; - Handle(SALOMEDSImpl_UseCaseBuilder) _useCaseBuilder; + Handle(TColStd_HSequenceOfAsciiString) _lockers; + Handle(SALOMEDSImpl_Callback) _cb; + Handle(SALOMEDSImpl_StudyBuilder) _builder; + Handle(SALOMEDSImpl_UseCaseBuilder) _useCaseBuilder; DataMapOfAsciiStringTransient _mapOfSO; DataMapOfAsciiStringTransient _mapOfSCO; @@ -283,10 +283,10 @@ public: Standard_EXPORT bool IsStudyLocked(); //Unlocks the study - Standard_EXPORT void UnLockStudy(); + Standard_EXPORT void UnLockStudy(const char* theLockerID); //Returns an ID of the study locker - Standard_EXPORT char* GetLockerID(); + Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetLockerID(); public: DEFINE_STANDARD_RTTI( SALOMEDSImpl_Study ) diff --git a/src/SALOMEDSImpl/testDS.cxx b/src/SALOMEDSImpl/testDS.cxx index 538f0ca40..c256306e7 100644 --- a/src/SALOMEDSImpl/testDS.cxx +++ b/src/SALOMEDSImpl/testDS.cxx @@ -55,7 +55,7 @@ int main (int argc, char * argv[]) aStudy->SetStudyLock("SRN"); cout << "Is study locked = " << aStudy->IsStudyLocked() << endl; cout << "Get study locker : " << aStudy->GetLockerID() << endl; - aStudy->UnLockStudy(); + aStudy->UnLockStudy("SRN"); cout << "Is study locked = " << aStudy->IsStudyLocked() << endl; Handle(SALOMEDSImpl_StudyBuilder) aBuilder = aStudy->NewBuilder(); -- 2.39.2