From 248eb5919a8fca980a5a288dbd85d4e201eeee9e Mon Sep 17 00:00:00 2001 From: srn Date: Tue, 22 Mar 2005 07:54:00 +0000 Subject: [PATCH] Fixed bug with freezing the SALOMEDS in standalone mode. Implemented a support of creation SObjects, SComponents and Attributes only once, without their later re-creation. --- src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx | 5 +- src/SALOMEDS/SALOMEDS_Attributes.hxx | 1 + src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx | 8 ++-- src/SALOMEDS/SALOMEDS_Driver_i.cxx | 48 ++++++++----------- src/SALOMEDS/SALOMEDS_Driver_i.hxx | 2 +- src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx | 23 +++++++-- .../SALOMEDS_SComponentIterator_i.cxx | 5 +- src/SALOMEDS/SALOMEDS_SComponent_i.cxx | 19 ++++++++ src/SALOMEDS/SALOMEDS_SComponent_i.hxx | 2 + src/SALOMEDS/SALOMEDS_SObject_i.cxx | 37 ++++++++++---- src/SALOMEDS/SALOMEDS_SObject_i.hxx | 2 + src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx | 15 +++--- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 7 ++- src/SALOMEDS/SALOMEDS_Study_i.cxx | 48 ++++++++----------- src/SALOMEDS/SALOMEDS_Study_i.hxx | 10 ++-- src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx | 6 +-- src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx | 3 +- 17 files changed, 136 insertions(+), 105 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx index af9d090e0..13ac6002e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx @@ -6,6 +6,7 @@ using namespace std; #include "SALOMEDS_AttributeTarget_i.hxx" #include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_Study.hxx" #include "SALOMEDS.hxx" #include @@ -31,8 +32,8 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() TDF_ListIteratorOfLabelList anIter(aLList); int index; for(index=0;anIter.More();anIter.Next(),index++) { - SALOMEDS_SObject_i* anSO = new SALOMEDS_SObject_i(new SALOMEDSImpl_SObject(anIter.Value()), _orb); - aSList[index] = anSO->_this(); + SALOMEDS::SObject_var anSO = SALOMEDS_SObject_i::New(SALOMEDSImpl_Study::GetStudy(anIter.Value())->GetSObject(anIter.Value()), _orb); + aSList[index] = anSO; } return aSList._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_Attributes.hxx b/src/SALOMEDS/SALOMEDS_Attributes.hxx index b818ad9e9..2d39bb79f 100644 --- a/src/SALOMEDS/SALOMEDS_Attributes.hxx +++ b/src/SALOMEDS/SALOMEDS_Attributes.hxx @@ -69,6 +69,7 @@ #define __CreateCORBAAttribute(CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \ Handle(SALOMEDSImpl_##CORBA_Name) A = Handle(SALOMEDSImpl_##CORBA_Name)::DownCast(theAttr); \ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(A, theOrb); \ + attr_servant = Attr; \ anAttribute = Attr->CORBA_Name::_this(); \ } diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx index 8ff093bad..a659d66d4 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx @@ -7,6 +7,7 @@ using namespace std; #include "SALOMEDS_SObject_i.hxx" #include "SALOMEDS.hxx" #include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_Study.hxx" #include "utilities.h" //============================================================================ @@ -86,9 +87,8 @@ void SALOMEDS_ChildIterator_i::Next() SALOMEDS::SObject_ptr SALOMEDS_ChildIterator_i::Value() { SALOMEDS::Locker lock; - Handle(SALOMEDSImpl_SObject) aSO = new SALOMEDSImpl_SObject(_it.Value()); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); - return so; + Handle(SALOMEDSImpl_SObject) aSO = SALOMEDSImpl_Study::GetStudy(_it.Value())->GetSObject(_it.Value()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); + return so._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 551b640ef..01c549371 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -13,11 +13,12 @@ unsigned char* SALOMEDS_Driver_i::Save(const Handle(SALOMEDSImpl_SComponent)& th long& theStreamLength, bool isMultiFile) { - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (theComponent, _orb); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); SALOMEDS::TMPFile_var aStream; CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); + SALOMEDS::unlock(); aStream = _driver->Save(sco.in(), url, isMultiFile); + SALOMEDS::lock(); theStreamLength = aStream->length(); unsigned char* aRetStream = NULL; if(theStreamLength > 0) { @@ -32,11 +33,12 @@ unsigned char* SALOMEDS_Driver_i::SaveASCII(const Handle(SALOMEDSImpl_SComponent long& theStreamLength, bool isMultiFile) { - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (theComponent, _orb); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); SALOMEDS::TMPFile_var aStream; CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); + SALOMEDS::unlock(); aStream = _driver->SaveASCII(sco.in(), url, isMultiFile); + SALOMEDS::lock(); theStreamLength = aStream->length(); unsigned char* aRetStream = NULL; if(theStreamLength > 0) { @@ -52,9 +54,7 @@ bool SALOMEDS_Driver_i::Load(const Handle(SALOMEDSImpl_SComponent)& theComponent const TCollection_AsciiString& theURL, bool isMultiFile) { - SALOMEDS::Locker lock; - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (theComponent, _orb); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; @@ -74,9 +74,7 @@ bool SALOMEDS_Driver_i::LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComp const TCollection_AsciiString& theURL, bool isMultiFile) { - SALOMEDS::Locker lock; - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (theComponent, _orb); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; @@ -92,9 +90,10 @@ bool SALOMEDS_Driver_i::LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComp void SALOMEDS_Driver_i::Close(const Handle(SALOMEDSImpl_SComponent)& theComponent) { - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (theComponent, _orb); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); + SALOMEDS::unlock(); _driver->Close(sco.in()); + SALOMEDS::lock(); } @@ -104,9 +103,7 @@ TCollection_AsciiString SALOMEDS_Driver_i::IORToLocalPersistentID(const Handle(S bool isMultiFile, bool isASCII) { - SALOMEDS::Locker lock; - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (theSObject, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theSObject, _orb); CORBA::String_var ior = CORBA::string_dup(IORString.ToCString()); SALOMEDS::unlock(); CORBA::String_var pers_string =_driver->IORToLocalPersistentID(so.in(), ior.in(), isMultiFile, isASCII); @@ -120,9 +117,7 @@ TCollection_AsciiString SALOMEDS_Driver_i::LocalPersistentIDToIOR(const Handle(S bool isMultiFile, bool isASCII) { - SALOMEDS::Locker lock; - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (theObject, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb); CORBA::String_var pers_string = CORBA::string_dup(aLocalPersistentID.ToCString()); SALOMEDS::unlock(); CORBA::String_var IOR =_driver->LocalPersistentIDToIOR(so.in(), pers_string.in(), isMultiFile, isASCII); @@ -132,8 +127,8 @@ TCollection_AsciiString SALOMEDS_Driver_i::LocalPersistentIDToIOR(const Handle(S bool SALOMEDS_Driver_i::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject) { - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (theObject, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb); + SALOMEDS::unlock(); return _driver->CanCopy(so.in()); } @@ -147,10 +142,7 @@ unsigned char* SALOMEDS_Driver_i::CopyFrom(const Handle(SALOMEDSImpl_SObject)& t int& theObjectID, long& theStreamLength) { - SALOMEDS::Locker lock; - - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (theObject, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb); SALOMEDS::TMPFile_var aStream; CORBA::Long anObjectID; @@ -177,6 +169,7 @@ unsigned char* SALOMEDS_Driver_i::CopyFrom(const Handle(SALOMEDSImpl_SObject)& t bool SALOMEDS_Driver_i::CanPaste(const TCollection_AsciiString& theComponentName, int theObjectID) { + SALOMEDS::unlock(); return _driver->CanPaste(theComponentName.ToCString(), theObjectID); } @@ -185,10 +178,7 @@ TCollection_AsciiString SALOMEDS_Driver_i::PasteInto(const unsigned char* theStr int theObjectID, const Handle(SALOMEDSImpl_SObject)& theObject) { - SALOMEDS::Locker lock; - - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (theObject, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb); CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; SALOMEDS::TMPFile_var aStream; @@ -215,7 +205,9 @@ unsigned char* SALOMEDS_Driver_i::DumpPython(const Handle(SALOMEDSImpl_Study)& t CORBA::Boolean aValidScript, aPublished; aPublished = isPublished; Engines::Component_ptr aComponent = Engines::Component::_narrow(_driver); + SALOMEDS::unlock(); aStream = aComponent->DumpPython(st.in(), aPublished, aValidScript); + SALOMEDS::lock(); isValidScript = aValidScript; theStreamLength = aStream->length(); unsigned char* aRetStream = NULL; diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.hxx b/src/SALOMEDS/SALOMEDS_Driver_i.hxx index f5bf3ad81..218c81a88 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.hxx @@ -22,7 +22,7 @@ public: SALOMEDS_Driver_i(SALOMEDS::Driver_ptr theDriver, CORBA::ORB_ptr theORB) { _driver = SALOMEDS::Driver::_duplicate(theDriver); - _orb = CORBA::ORB::_duplicate(theORB); + _orb = CORBA::ORB::_duplicate(theORB); } virtual TCollection_AsciiString GetIOR() diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index 837bce858..99d6bfc8c 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -8,8 +8,10 @@ using namespace std; #include "SALOMEDS_Attributes.hxx" #include "SALOMEDS.hxx" #include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_Study.hxx" #include "Utils_ExceptHandlers.hxx" #include +#include UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection); @@ -38,9 +40,8 @@ SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject() { SALOMEDS::Locker lock; if (_impl.IsNull() || _impl->Label().IsNull()) return SALOMEDS::SObject::_nil(); - Handle(SALOMEDSImpl_SObject) so_impl = new SALOMEDSImpl_SObject(_impl->Label()); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (so_impl, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + Handle(SALOMEDSImpl_SObject) so_impl = SALOMEDSImpl_Study::GetStudy(_impl->Label())->GetSObject(_impl->Label()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (so_impl, _orb); return so._retn(); } @@ -60,8 +61,20 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(cons CORBA::ORB_ptr theOrb) { SALOMEDS::Locker lock; - char* aTypeOfAttribute = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr)->GetClassType().ToCString(); + + static std::map _mapOfAttrib; SALOMEDS::GenericAttribute_var anAttribute; - __CreateGenericCORBAAttribute + SALOMEDS_GenericAttribute_i* attr_servant = NULL; + + if(_mapOfAttrib.find(theAttr.operator->()) != _mapOfAttrib.end()) { + attr_servant = _mapOfAttrib[theAttr.operator->()]; + anAttribute = SALOMEDS::GenericAttribute::_narrow(attr_servant->_this()); + } + else { + char* aTypeOfAttribute = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr)->GetClassType().ToCString(); + __CreateGenericCORBAAttribute + _mapOfAttrib[theAttr.operator->()] = attr_servant; + } + return anAttribute._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx index 57cbcf25e..e1cfac20d 100644 --- a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx @@ -70,8 +70,7 @@ void SALOMEDS_SComponentIterator_i::Next() SALOMEDS::SComponent_ptr SALOMEDS_SComponentIterator_i::Value() { SALOMEDS::Locker lock; - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (_impl.Value(), _orb); - SALOMEDS::SComponent_var so = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); - return so; + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (_impl.Value(), _orb); + return sco._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx index 80f6591d2..76b7153f3 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx @@ -6,7 +6,26 @@ using namespace std; #include "SALOMEDS_SComponent_i.hxx" #include "SALOMEDS.hxx" #include "utilities.h" +#include +SALOMEDS::SComponent_ptr SALOMEDS_SComponent_i::New(const Handle(SALOMEDSImpl_SComponent)& theImpl, CORBA::ORB_ptr theORB) +{ + static std::map _mapOfSCO; + SALOMEDS::SComponent_var sco; + SALOMEDS_SComponent_i* sco_servant = NULL; + + if(_mapOfSCO.find(theImpl.operator->()) != _mapOfSCO.end()) { + sco_servant = _mapOfSCO[theImpl.operator->()]; + } + else { + sco_servant = new SALOMEDS_SComponent_i(theImpl, theORB); + _mapOfSCO[theImpl.operator->()] = sco_servant; + } + + sco = SALOMEDS::SComponent::_narrow(sco_servant->SComponent::_this()); + + return sco._retn(); +} //============================================================================ /*! Function : constructor diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.hxx b/src/SALOMEDS/SALOMEDS_SComponent_i.hxx index f35cffcda..f0f0361f8 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.hxx @@ -23,6 +23,8 @@ class SALOMEDS_SComponent_i: public POA_SALOMEDS::SComponent, { public: + + static SALOMEDS::SComponent_ptr New(const Handle(SALOMEDSImpl_SComponent)&, CORBA::ORB_ptr); SALOMEDS_SComponent_i(const Handle(SALOMEDSImpl_SComponent)&, CORBA::ORB_ptr); diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 4f474bf15..ce60bace5 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -18,6 +18,27 @@ using namespace std; #include #include #include +#include + +SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const Handle(SALOMEDSImpl_SObject)& theImpl, CORBA::ORB_ptr theORB) +{ + static std::map _mapOfSO; + SALOMEDS::SObject_var so; + SALOMEDS_SObject_i* so_servant = NULL; + + if(_mapOfSO.find(theImpl.operator->()) != _mapOfSO.end()) { + so_servant = _mapOfSO[theImpl.operator->()]; + } + else { + so_servant = new SALOMEDS_SObject_i(theImpl, theORB); + _mapOfSO[theImpl.operator->()] = so_servant; + } + + so = SALOMEDS::SObject::_narrow(so_servant->_this()); + + return so._retn(); +} + //============================================================================ /*! Function : constructor @@ -59,9 +80,8 @@ char* SALOMEDS_SObject_i::GetID() SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent() { SALOMEDS::Locker lock; - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (_impl->GetFatherComponent(), _orb); - SALOMEDS::SComponent_var so = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); - return so; + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (_impl->GetFatherComponent(), _orb); + return sco._retn(); } //============================================================================ @@ -72,9 +92,8 @@ SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent() SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather() { SALOMEDS::Locker lock; - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_impl->GetFather(), _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); - return so; + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (_impl->GetFather(), _orb); + return so._retn(); } //============================================================================ @@ -156,8 +175,7 @@ CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj) Handle(SALOMEDSImpl_SObject) aRefObj; if(!_impl->ReferencedObject(aRefObj)) return false; - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aRefObj, _orb); - obj = SALOMEDS::SObject::_narrow(so_servant->_this()); + obj = SALOMEDS_SObject_i::New (aRefObj, _orb); return true; } @@ -172,8 +190,7 @@ CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(long atag, SALOMEDS::SObject_ou Handle(SALOMEDSImpl_SObject) aSubObj; if(!_impl->FindSubObject(atag, aSubObj)) return false; - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSubObj, _orb); - obj = SALOMEDS::SObject::_narrow(so_servant->_this()); + obj = SALOMEDS_SObject_i::New (aSubObj, _orb); return true; } diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index a393cffe3..e42eaa98b 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -22,6 +22,8 @@ protected: Handle(SALOMEDSImpl_SObject) _impl; public: + + static SALOMEDS::SObject_ptr New(const Handle(SALOMEDSImpl_SObject)&, CORBA::ORB_ptr); SALOMEDS_SObject_i(const Handle(SALOMEDSImpl_SObject)&, CORBA::ORB_ptr); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 62855fb3e..49e000af5 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -59,9 +59,8 @@ SALOMEDS::SComponent_ptr SALOMEDS_StudyBuilder_i::NewComponent(const char* DataT //CORBA::free_string(aDataType); if(aSCO.IsNull()) return SALOMEDS::SComponent::_nil(); - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (aSCO,_orb); - SALOMEDS::SComponent_var so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); - return so; + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO,_orb); + return sco._retn(); } //============================================================================ @@ -110,10 +109,9 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr t aFO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theFatherObject->GetID()); aSO = _impl->NewObject(aFO); if(aSO.IsNull()) return SALOMEDS::SObject::_nil(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO,_orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO,_orb); - return so; + return so._retn(); } //============================================================================ @@ -130,9 +128,8 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ aFO = Handle(SALOMEDSImpl_Study)::DownCast(_impl->GetOwner())->GetSObject((char*)theFatherObject->GetID()); aSO = _impl->NewObjectToTag(aFO, atag); if(aSO.IsNull()) return SALOMEDS::SObject::_nil(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); - return so; + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); + return so._retn(); } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index aabb1dec7..c2709aad7 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -164,7 +164,9 @@ void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) _name_service->Destroy_Name(aString.in()); } + SALOMEDS::unlock(); aStudy->Close(); + SALOMEDS::lock(); } //============================================================================ @@ -393,16 +395,13 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theOb throw SALOMEDS::StudyBuilder::LockProtection(); } - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aNewSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb); return so._retn(); } SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb) { - SALOMEDS::Locker lock; - SALOMEDS_Driver_i* driver = NULL; Handle(SALOMEDSImpl_SComponent) aSCO = theObject->GetFatherComponent(); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 4f365ceee..e57b2575a 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -38,8 +38,10 @@ SALOMEDS_Study_i::SALOMEDS_Study_i(const Handle(SALOMEDSImpl_Study) theImpl, { _orb = CORBA::ORB::_duplicate(orb); _impl = theImpl; - _UseCaseBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb); - _Builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb); + + _useCaseBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb); + _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb); + _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb); } //============================================================================ @@ -95,9 +97,8 @@ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponent Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponent(TCollection_AsciiString((char*)aComponentName)); if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil(); - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (aCompImpl, _orb); - SALOMEDS::SComponent_var compo = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); - return compo._retn(); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb); + return sco._retn(); } //============================================================================ @@ -112,9 +113,8 @@ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponen Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponentID(TCollection_AsciiString((char*)aComponentID)); if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil(); - SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (aCompImpl, _orb); - SALOMEDS::SComponent_var compo = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); - return compo._retn(); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb); + return sco._retn(); } //============================================================================ @@ -131,13 +131,11 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName) if(aSO->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_SComponent)) { Handle(SALOMEDSImpl_SComponent) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO); - SALOMEDS_SComponent_i * sco_servant = new SALOMEDS_SComponent_i (aSCO, _orb); - SALOMEDS::SComponent_var sco = SALOMEDS::SComponent::_narrow(sco_servant->SComponent::_this()); + SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb); return sco._retn(); } - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } @@ -153,8 +151,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID) Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectID(TCollection_AsciiString((char*)anObjectID)); if(aSO.IsNull()) return SALOMEDS::SObject::_nil(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } @@ -170,8 +167,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID) Handle(SALOMEDSImpl_SObject) aSO = _impl->CreateObjectID((char*)anObjectID); if(aSO.IsNull()) return SALOMEDS::SObject::_nil(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } @@ -193,8 +189,7 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* listSO->length(aLength); for(int i = 1; i<=aLength; i++) { Handle(SALOMEDSImpl_SObject) aSO = Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); listSO[i-1] = so ; } return listSO._retn() ; @@ -212,8 +207,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR) Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectIOR(TCollection_AsciiString((char*)anObjectIOR)); if(aSO.IsNull()) return SALOMEDS::SObject::_nil(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } @@ -229,8 +223,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath) Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectByPath(TCollection_AsciiString((char*)thePath)); if(aSO.IsNull()) return SALOMEDS::SObject::_nil(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } @@ -388,11 +381,8 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() { SALOMEDS::Locker lock; - - SALOMEDSImpl_SComponentIterator aCI = _impl->NewComponentIterator(); - SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(aCI, _orb); - SALOMEDS::SComponentIterator_var it = SALOMEDS::SComponentIterator::_narrow(it_servant->_this()); - return it; + _it->Init(); + return _it->_this(); } @@ -404,7 +394,7 @@ SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder() { SALOMEDS::Locker lock; - return _Builder->_this(); + return _builder->_this(); } //============================================================================ @@ -580,7 +570,7 @@ SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() { SALOMEDS::Locker lock; - return _UseCaseBuilder->_this(); + return _useCaseBuilder->_this(); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 5e969bd8f..6c6ed6208 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -29,10 +29,12 @@ class SALOMEDS_Study_i: public POA_SALOMEDS::Study, public PortableServer::RefCountServantBase { private: - CORBA::ORB_ptr _orb; - Handle(SALOMEDSImpl_Study) _impl; - SALOMEDS_StudyBuilder_i* _Builder; - SALOMEDS_UseCaseBuilder_i* _UseCaseBuilder; + CORBA::ORB_ptr _orb; + Handle(SALOMEDSImpl_Study) _impl; + SALOMEDS_StudyBuilder_i* _builder; + SALOMEDS_UseCaseBuilder_i* _useCaseBuilder; + SALOMEDS_SComponentIterator_i* _it; + public: //! standard constructor diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx index 4aca24826..dd61e3d46 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@ -144,8 +144,7 @@ SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetCurrentObject() if(_impl.IsNull()) return NULL; Handle(SALOMEDSImpl_SObject) aSO = _impl->GetCurrentObject(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } @@ -184,8 +183,7 @@ SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::AddUseCase(const char* theName) if(_impl.IsNull()) return SALOMEDS::SObject::_nil(); Handle(SALOMEDSImpl_SObject) aSO = _impl->AddUseCase((char*)theName); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx index fc99c72d6..aa18c5e57 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx @@ -74,8 +74,7 @@ SALOMEDS::SObject_ptr SALOMEDS_UseCaseIterator_i::Value() { SALOMEDS::Locker lock; Handle(SALOMEDSImpl_SObject) aSO = _impl->Value(); - SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aSO, _orb); - SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb); return so._retn(); } -- 2.39.2