From afdf2b7c2a9e2f6c42e3d6f5856c1d279c86f4cf Mon Sep 17 00:00:00 2001 From: srn Date: Tue, 22 Mar 2005 07:51:35 +0000 Subject: [PATCH] Implemented a support of creation of SObjects, SComponents and Attributes only once, without later re-creation. --- src/SALOMEDSImpl/Makefile.in | 10 --- .../SALOMEDSImpl_AttributeTableOfString.cxx | 9 +- .../SALOMEDSImpl_AttributeTableOfString.hxx | 6 +- src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx | 3 +- .../SALOMEDSImpl_SComponentIterator.cxx | 4 +- src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx | 18 ++-- src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx | 2 +- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 86 +++++++++++++------ src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx | 12 ++- .../SALOMEDSImpl_StudyBuilder.cxx | 8 +- .../SALOMEDSImpl_StudyManager.cxx | 9 +- .../SALOMEDSImpl_UseCaseBuilder.cxx | 7 +- .../SALOMEDSImpl_UseCaseIterator.cxx | 3 +- 13 files changed, 111 insertions(+), 66 deletions(-) diff --git a/src/SALOMEDSImpl/Makefile.in b/src/SALOMEDSImpl/Makefile.in index 975e04332..74f2396a1 100644 --- a/src/SALOMEDSImpl/Makefile.in +++ b/src/SALOMEDSImpl/Makefile.in @@ -53,11 +53,7 @@ EXPORT_HEADERS= \ SALOMEDSImpl_Study.hxx \ SALOMEDSImpl_StudyManager.hxx \ SALOMEDSImpl_OCAFApplication.hxx \ - SALOMEDSImpl_DataMapStringLabel.hxx \ - SALOMEDSImpl_DataMapOfIntegerString.hxx \ SALOMEDSImpl_ChildNodeIterator.hxx \ - Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx \ - Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx LIB_CLIENT_IDL = LIB_SERVER_IDL = @@ -108,12 +104,6 @@ LIB_SRC = SALOMEDSImpl_Tool.cxx \ SALOMEDSImpl_AttributeComment.cxx \ SALOMEDSImpl_AttributeReference.cxx \ SALOMEDSImpl_ChildNodeIterator.cxx \ - SALOMEDSImpl_DataMapOfIntegerString_0.cxx \ - SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx \ - SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx \ - SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx \ - SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx \ - SALOMEDSImpl_DataMapStringLabel_0.cxx \ SALOMEDSImpl_UseCaseBuilder.cxx \ SALOMEDSImpl_UseCaseIterator.cxx \ SALOMEDSImpl_SComponentIterator.cxx \ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx index e364ff799..321a53e3b 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx @@ -5,7 +5,6 @@ using namespace std; #include #include -#include #include #include #include @@ -13,6 +12,8 @@ using namespace std; IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfString, SALOMEDSImpl_GenericAttribute ) IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTableOfString, SALOMEDSImpl_GenericAttribute ) +typedef NCollection_DataMap::Iterator DataMapIterator; + const Standard_GUID& SALOMEDSImpl_AttributeTableOfString::GetID() { static Standard_GUID SALOMEDSImpl_AttributeTableOfStringID ("128371A4-8F52-11d6-A8A3-0001021E8C7F"); @@ -43,11 +44,11 @@ void SALOMEDSImpl_AttributeTableOfString::SetNbColumns(const Standard_Integer th CheckLocked(); Backup(); - SALOMEDSImpl_DataMapOfIntegerString aMap; + DataMapOfIntegerString aMap; aMap = myTable; myTable.Clear(); - SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString anIterator(aMap); + DataMapIterator anIterator(aMap); for(; anIterator.More(); anIterator.Next()) { int aRow = (int)(anIterator.Key()/myNbColumns) + 1; int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); @@ -339,7 +340,7 @@ void SALOMEDSImpl_AttributeTableOfString::ConvertToString(ostrstream& theStream) //Store the table values l = myTable.Extent(); theStream << l << "\n"; - SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString anIterator(myTable); + DataMapIterator anIterator(myTable); for(; anIterator.More(); anIterator.Next()) { if (anIterator.Value().Length()) { // check empty string in the value table theStream << anIterator.Key() << "\n"; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx index 0a3581fb0..5e1abfc33 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx @@ -27,11 +27,13 @@ DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfString, SALOMEDSImpl_Generi #include #include #include -#include +#include #include #include #include +typedef NCollection_DataMap DataMapOfIntegerString; + class SALOMEDSImpl_AttributeTableOfString : public SALOMEDSImpl_GenericAttribute { @@ -73,7 +75,7 @@ Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfString() {} private: -SALOMEDSImpl_DataMapOfIntegerString myTable; +DataMapOfIntegerString myTable; TCollection_ExtendedString myTitle; Handle_TColStd_HSequenceOfExtendedString myRows; Handle_TColStd_HSequenceOfExtendedString myCols; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx index 748033293..96eb8f14c 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx @@ -26,8 +26,7 @@ SALOMEDSImpl_SComponent::SALOMEDSImpl_SComponent(const TDF_Label& theLabel) */ //============================================================================ SALOMEDSImpl_SComponent::~SALOMEDSImpl_SComponent() -{ -} +{} //============================================================================ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx index 792b0f939..2040a0bd3 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx @@ -4,7 +4,7 @@ using namespace std; #include "SALOMEDSImpl_SComponentIterator.hxx" - +#include "SALOMEDSImpl_Study.hxx" //============================================================================ /*! Function : constructor @@ -61,6 +61,6 @@ void SALOMEDSImpl_SComponentIterator::Next() //============================================================================ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_SComponentIterator::Value() { - return new SALOMEDSImpl_SComponent (_it.Value()); + return SALOMEDSImpl_Study::GetStudy(_it.Value())->GetSComponent (_it.Value()); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx index 107d5f69b..e3594207e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx @@ -28,7 +28,15 @@ SALOMEDSImpl_SObject::SALOMEDSImpl_SObject(const TDF_Label& theLabel) _type = ""; _name = ""; } - + +//============================================================================ +/*! Function : Desctructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_SObject::~SALOMEDSImpl_SObject() +{} + //============================================================================ /*! Function : GetID * Purpose : @@ -55,7 +63,7 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_SObject::GetFatherComponent() if(LF.IsRoot()) return NULL; - return new SALOMEDSImpl_SComponent(LF); + return GetStudy()->GetSComponent(LF); } //============================================================================ @@ -65,7 +73,7 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_SObject::GetFatherComponent() //============================================================================ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_SObject::GetFather() { - return new SALOMEDSImpl_SObject(_lab.Father()); + return GetStudy()->GetSObject(_lab.Father()); } @@ -127,7 +135,7 @@ bool SALOMEDSImpl_SObject::ReferencedObject(Handle(SALOMEDSImpl_SObject)& theObj if (!_lab.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(),Ref)) return false; - theObject = new SALOMEDSImpl_SObject(Ref->Get()); + theObject = GetStudy()->GetSObject(Ref->Get()); return true; } @@ -141,7 +149,7 @@ bool SALOMEDSImpl_SObject::FindSubObject(int theTag, Handle(SALOMEDSImpl_SObject TDF_Label L = _lab.FindChild(theTag, false); if (L.IsNull()) return false; - theObject = new SALOMEDSImpl_SObject(L); + theObject = GetStudy()->GetSObject(L); return true; } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx index c6e0bc55a..be8bc6c48 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx @@ -35,7 +35,7 @@ protected: public: SALOMEDSImpl_SObject(const TDF_Label& theLabel); - ~SALOMEDSImpl_SObject() {}; + ~SALOMEDSImpl_SObject(); virtual TCollection_AsciiString GetID(); virtual Handle(SALOMEDSImpl_SComponent) GetFatherComponent(); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index c43d312a0..6bf2cbeed 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -17,7 +17,6 @@ using namespace std; #include #include -#include "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" #include "SALOMEDSImpl_ChildNodeIterator.hxx" #include "SALOMEDSImpl_Attributes.hxx" #include "SALOMEDSImpl_UseCaseIterator.hxx" @@ -239,7 +238,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectID(const TCollection_ _errorCode = "No label was found by ID"; return NULL; } - return new SALOMEDSImpl_SObject(Lab); + return GetSObject(Lab); } @@ -260,7 +259,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::CreateObjectID(const TCollectio _errorCode = "Can not create a label"; return NULL; } - return new SALOMEDSImpl_SObject(Lab); + return GetSObject(Lab); } @@ -291,7 +290,7 @@ Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindObjectByName(const TDF_ChildIterator it = NewChildIterator(compo); for ( ; it.More();it.Next() ) { - Handle(SALOMEDSImpl_SObject) CSO = new SALOMEDSImpl_SObject(it.Value()); + Handle(SALOMEDSImpl_SObject) CSO = GetSObject(it.Value()); if ( CSO->GetName() == anObjectName ) { /* add to list */ listSO->Append(CSO) ; @@ -321,7 +320,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectIOR(const TCollection // firstly searching in the datamap for optimization if (myIORLabels.IsBound(anObjectIOR)) { - Handle(SALOMEDSImpl_SObject) aResult = new SALOMEDSImpl_SObject(myIORLabels.Find(anObjectIOR)); + Handle(SALOMEDSImpl_SObject) aResult = GetSObject(myIORLabels.Find(anObjectIOR)); // 11 oct 2002: forbidden attributes must be checked here if (!aResult->GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID())) { myIORLabels.UnBind(anObjectIOR); @@ -373,7 +372,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollect bool isRelative = false; if(aLength == 0) { //Empty path - return the current context - return new SALOMEDSImpl_SObject (_current); + return GetSObject(_current); } if(aPath.Value(1) != '/') //Relative path @@ -389,7 +388,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollect } else { if(aPath.Length() == 1 && aPath.Value(1) == '/') { //Root - return new SALOMEDSImpl_SObject (_doc->Main()); + return GetSObject(_doc->Main()); } anIterator.Initialize(_doc->Main(), Standard_False); } @@ -405,7 +404,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollect if(anAttr->Get() == aToken) { aToken = aPath.Token("/", i+1); //Check if it was the last part of the path if(aToken.Length() == 0) { //The searched label is found (no part of the path is left) - return new SALOMEDSImpl_SObject (aLabel); + return GetSObject(aLabel); } anIterator.Initialize(aLabel, Standard_False); @@ -537,7 +536,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetContext() _errorCode = "InvaidContext"; return ""; } - Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject (_current); + Handle(SALOMEDSImpl_SObject) so = GetSObject(_current); return GetObjectPath(so); } @@ -836,11 +835,11 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::_FindObject(const Handle(SALOME TCollection_AsciiString Val(anAttr->Get()); if (Val == theObjectName) { - RefSO = new SALOMEDSImpl_SObject(it.Value()); + RefSO = GetSObject(it.Value()); _find = true; } } - if (!_find) RefSO = _FindObject(new SALOMEDSImpl_SObject(it.Value()), theObjectName, _find); + if (!_find) RefSO = _FindObject(GetSObject(it.Value()), theObjectName, _find); } } return RefSO; @@ -872,11 +871,11 @@ SALOMEDSImpl_Study::_FindObjectIOR(const Handle(SALOMEDSImpl_SObject)& SO, TCollection_AsciiString Val(anAttr->Value()); if (Val == theObjectIOR) { - RefSO = new SALOMEDSImpl_SObject(it.Value()); + RefSO = GetSObject(it.Value()); _find = true; } } - aSO = new SALOMEDSImpl_SObject(it.Value()); + aSO = GetSObject(it.Value()); if (!_find) RefSO = _FindObjectIOR(aSO, theObjectIOR, _find); } } @@ -939,7 +938,7 @@ Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindDependances(const H aTarget->Get(aLabelList); TDF_ListIteratorOfLabelList anIter(aLabelList); for(; anIter.More();anIter.Next()) { - aSeq->Append(new SALOMEDSImpl_SObject(anIter.Value())); + aSeq->Append(GetSObject(anIter.Value())); } return aSeq; } @@ -1019,6 +1018,8 @@ void SALOMEDSImpl_Study::Close() Handle(TDocStd_Application) anApp = Handle(TDocStd_Application)::DownCast(_doc->Application()); if(!anApp.IsNull()) anApp->Close(_doc); _doc.Nullify(); + _mapOfSO.Clear(); + _mapOfSCO.Clear(); } //============================================================================ @@ -1135,9 +1136,29 @@ void SALOMEDSImpl_Study::UndoPostponed(const int theWay) //============================================================================ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TCollection_AsciiString& theEntry) { - TDF_Label aLabel; - TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); - return new SALOMEDSImpl_SComponent(aLabel); + Handle(SALOMEDSImpl_SComponent) aSCO; + if(_mapOfSCO.IsBound(theEntry)) + aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(_mapOfSCO.Find(theEntry)); + else { + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); + aSCO = new SALOMEDSImpl_SComponent(aLabel); + _mapOfSCO.Bind(theEntry, aSCO); + } + + return aSCO; +} + +//============================================================================ +/*! Function : GetSComponent + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TDF_Label& theLabel) +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theLabel, anEntry); + return GetSComponent(anEntry); } //============================================================================ @@ -1147,10 +1168,29 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TCollect //============================================================================ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TCollection_AsciiString& theEntry) { - - TDF_Label aLabel; - TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); - return new SALOMEDSImpl_SObject(aLabel); + Handle(SALOMEDSImpl_SObject) aSO; + if(_mapOfSO.IsBound(theEntry)) + aSO = Handle(SALOMEDSImpl_SObject)::DownCast(_mapOfSO.Find(theEntry)); + else { + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); + aSO = new SALOMEDSImpl_SObject(aLabel); + _mapOfSO.Bind(theEntry, aSO); + } + + return aSO; +} + +//============================================================================ +/*! Function : GetSObject + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TDF_Label& theLabel) +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theLabel, anEntry); + return GetSObject(anEntry); } //============================================================================ @@ -1161,9 +1201,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TCollection_As Handle(TDF_Attribute) SALOMEDSImpl_Study::GetAttribute(const TCollection_AsciiString& theEntry, const TCollection_AsciiString& theType) { - TDF_Label aLabel; - TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); - Handle(SALOMEDSImpl_SObject) aSO = new SALOMEDSImpl_SObject(aLabel); + Handle(SALOMEDSImpl_SObject) aSO = GetSObject(theEntry); Handle(TDF_Attribute) anAttr; aSO->FindAttribute(anAttr, theType); return anAttr; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index fe143310a..33ae9e4fc 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -25,12 +25,12 @@ DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) #include #include #include +#include //SALOMEDSImpl headers #include "SALOMEDSImpl_SComponentIterator.hxx" #include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDSImpl_StudyBuilder.hxx" -#include "SALOMEDSImpl_DataMapStringLabel.hxx" #include "SALOMEDSImpl_UseCaseBuilder.hxx" #include "SALOMEDSImpl_AttributeStudyProperties.hxx" #include "SALOMEDSImpl_AttributeIOR.hxx" @@ -40,6 +40,9 @@ DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) class SALOMEDSImpl_StudyManager; class SALOMEDSImpl_GenericAttribute; +typedef NCollection_DataMap DataMapOfAsciiStringTransient; +typedef NCollection_DataMap DataMapAsciiStringLabel; + class SALOMEDSImpl_Study : public MMgt_TShared { private: @@ -55,11 +58,14 @@ private: Handle(SALOMEDSImpl_StudyBuilder) _builder; Handle(SALOMEDSImpl_UseCaseBuilder) _useCaseBuilder; + DataMapOfAsciiStringTransient _mapOfSO; + DataMapOfAsciiStringTransient _mapOfSCO; + // data structures for postponed destroying of object functionality TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction int myNbUndos; // number of current Undos, made by user - SALOMEDSImpl_DataMapStringLabel myIORLabels; + DataMapAsciiStringLabel myIORLabels; Handle(SALOMEDSImpl_SObject) _FindObject(const Handle(SALOMEDSImpl_SObject)& SO, @@ -209,7 +215,9 @@ public: virtual bool IsError() { return _errorCode != ""; } virtual Handle(SALOMEDSImpl_SComponent) GetSComponent(const TCollection_AsciiString& theEntry); + virtual Handle(SALOMEDSImpl_SComponent) GetSComponent(const TDF_Label& theLabel); virtual Handle(SALOMEDSImpl_SObject) GetSObject(const TCollection_AsciiString& theEntry); + virtual Handle(SALOMEDSImpl_SObject) GetSObject(const TDF_Label& theEntryLabel); virtual Handle(TDF_Attribute) GetAttribute(const TCollection_AsciiString& theEntry, const TCollection_AsciiString& theType); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index db842c476..f6b64b656 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -73,7 +73,7 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_StudyBuilder::NewComponent(const TC SALOMEDSImpl_AttributeComment::Set(NL, DataType); - Handle(SALOMEDSImpl_SComponent) so = new SALOMEDSImpl_SComponent (NL); + Handle(SALOMEDSImpl_SComponent) so = Handle(SALOMEDSImpl_Study)::DownCast(_study)->GetSComponent (NL); if(!_callbackOnAdd.IsNull()) _callbackOnAdd->OnAddSObject(so); @@ -134,7 +134,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyBuilder::NewObject(const Handle(S imax++; TDF_Label NewLab = Lab.FindChild(imax); - Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject(NewLab); + Handle(SALOMEDSImpl_SObject) so = Handle(SALOMEDSImpl_Study)::DownCast(_study)->GetSObject(NewLab); if(!_callbackOnAdd.IsNull()) _callbackOnAdd->OnAddSObject(so); return so; @@ -156,7 +156,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyBuilder::NewObjectToTag(const Han //Create or find label TDF_Label NewLab = Lab.FindChild(theTag, 1); - Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject (NewLab); + Handle(SALOMEDSImpl_SObject) so = Handle(SALOMEDSImpl_Study)::DownCast(_study)->GetSObject(NewLab); if(!_callbackOnAdd.IsNull()) _callbackOnAdd->OnAddSObject(so); @@ -967,7 +967,7 @@ static void Translate_persistentID_to_IOR(TDF_Label& Lab, SALOMEDSImpl_Driver* d if (anID->Value() == FILELOCALID) continue; //SRN: This attribute store a file name, skip it TCollection_AsciiString persist_ref(Att->Get()); - Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject(current); + Handle(SALOMEDSImpl_SObject) so = SALOMEDSImpl_Study::GetStudy(current)->GetSObject(current); TCollection_AsciiString ior_string = driver->LocalPersistentIDToIOR(so, persist_ref, isMultiFile, diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index ef3b6e8a1..7ad9cc4c5 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -740,7 +740,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const Handle(SALOMEDSImpl_SObjec if (anEmpty) continue; } - Handle(SALOMEDSImpl_SObject) SO = new SALOMEDSImpl_SObject(itchild.Value()); + Handle(SALOMEDSImpl_SObject) SO = SALOMEDSImpl_Study::GetStudy(itchild.Value())->GetSObject(itchild.Value()); char* scoid = (char*) SO->GetID().ToCString(); hdf_group_sobject = new HDFgroup(scoid, hdf_group_datatype); @@ -790,14 +790,11 @@ bool SALOMEDSImpl_StudyManager::CanCopy(const Handle(SALOMEDSImpl_SObject)& theO SALOMEDSImpl_Driver* theEngine) { _errorCode = ""; - Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent(); if (aComponent.IsNull()) return false; if (aComponent->GetLabel() == theObject->GetLabel()) return false; - TCollection_AsciiString IOREngine; if (!aComponent->ComponentIOR(IOREngine)) return false; - if (theEngine == NULL) return false; return theEngine->CanCopy(theObject); } @@ -1120,7 +1117,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOM PasteLabel(aStudy, theEngine, anIterator.Value(), aStartLabel, aCStudyID, false); } - return new SALOMEDSImpl_SObject (aStartLabel); + return SALOMEDSImpl_Study::GetStudy(aStartLabel)->GetSObject(aStartLabel); } //####################################################################################################### @@ -1241,7 +1238,7 @@ static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)& s TCollection_AsciiString ior_string, persistent_string, curid; for (; itchild.More(); itchild.Next()) { - Handle(SALOMEDSImpl_SObject) current = new SALOMEDSImpl_SObject(itchild.Value()); + Handle(SALOMEDSImpl_SObject) current = SALOMEDSImpl_Study::GetStudy(itchild.Value())->GetSObject(itchild.Value()); Handle(SALOMEDSImpl_AttributeIOR) IOR; if (current->GetLabel().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), IOR)) { ior_string = IOR->Value(); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx index d178f4a7f..0dffb75c5 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx @@ -6,6 +6,7 @@ using namespace std; #include "SALOMEDSImpl_UseCaseBuilder.hxx" #include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_Study.hxx" #include "SALOMEDSImpl_Attributes.hxx" #include @@ -286,7 +287,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseBuilder::GetCurrentObject() TDF_Label aCurrent = aRef->Get(); if(aCurrent.IsNull()) return NULL; - return new SALOMEDSImpl_SObject(aCurrent); + return SALOMEDSImpl_Study::GetStudy(aCurrent)->GetSObject(aCurrent); } //============================================================================ @@ -356,7 +357,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseBuilder::AddUseCase(const TColl aFatherNode->Append(aNode); SALOMEDSImpl_AttributeName::Set(aChild, theName); - return new SALOMEDSImpl_SObject(aChild); + return SALOMEDSImpl_Study::GetStudy(aChild)->GetSObject(aChild); } //============================================================================ @@ -384,5 +385,5 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseBuilder::GetSObject(const TColl { TDF_Label aLabel; TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); - return new SALOMEDSImpl_SObject(aLabel); + return SALOMEDSImpl_Study::GetStudy(aLabel)->GetSObject(aLabel); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx index dcfd56dd5..a6a4a2288 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx @@ -5,6 +5,7 @@ using namespace std; #include "SALOMEDSImpl_UseCaseIterator.hxx" #include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_Study.hxx" IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_UseCaseIterator, MMgt_TShared ) IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_UseCaseIterator, MMgt_TShared ) @@ -73,6 +74,6 @@ void SALOMEDSImpl_UseCaseIterator::Next() Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseIterator::Value() { TDF_Label L = _it.Value()->Label(); - return new SALOMEDSImpl_SObject(L); + return SALOMEDSImpl_Study::GetStudy(L)->GetSObject(L); } -- 2.39.2