1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 // File : SALOMEDSImpl_StudyManager.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDSImpl_StudyManager.hxx"
26 #include <CDF_Session.hxx>
27 #include <CDF_DirectoryIterator.hxx>
28 #include <TDF_Label.hxx>
29 #include <TDF_Tool.hxx>
30 #include <TDF_Data.hxx>
31 #include <TDF_RelocationTable.hxx>
32 #include <TDF_ChildIterator.hxx>
33 #include <TDF_AttributeIterator.hxx>
34 #include <TColStd_HSequenceOfReal.hxx>
35 #include <TColStd_HSequenceOfInteger.hxx>
36 #include <TColStd_HArray1OfCharacter.hxx>
37 #include <TColStd_HSequenceOfAsciiString.hxx>
38 #include <TColStd_HSequenceOfExtendedString.hxx>
39 #include <TCollection_ExtendedString.hxx>
40 #include <OSD_Process.hxx>
41 #include <Quantity_Date.hxx>
42 #include "HDFexplorer.hxx"
44 #include "SALOMEDSImpl_Attributes.hxx"
45 #include "SALOMEDSImpl_Tool.hxx"
46 #include "SALOMEDSImpl_SComponent.hxx"
55 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared )
56 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyManager, MMgt_TShared )
58 #define USE_CASE_LABEL_ID "0:2"
59 #define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2"
60 #define AUTO_SAVE_TAG "0:8"
61 #define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200
63 static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject);
64 static void ReadAttributes(const Handle(SALOMEDSImpl_Study)&, const Handle(SALOMEDSImpl_SObject)&, HDFdataset* );
65 static void BuildTree (const Handle(SALOMEDSImpl_Study)&, HDFgroup*);
66 static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)&,
67 SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII);
69 //============================================================================
70 /*! Function : SALOMEDSImpl_StudyManager
71 * Purpose : SALOMEDSImpl_StudyManager constructor
73 //============================================================================
74 SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager()
77 _OCAFApp = new SALOMEDSImpl_OCAFApplication();
79 _OCAFApp->NewDocument("SALOME_STUDY", _clipboard);
82 //============================================================================
83 /*! Function : ~SALOMEDSImpl_StudyManager
84 * Purpose : SALOMEDSImpl_StudyManager destructor
86 //============================================================================
87 SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager()
89 // Destroy OCAF application
94 //============================================================================
95 /*! Function : NewStudy
96 * Purpose : Create a New Study of name study_name
98 //==================================================T==========================
99 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::NewStudy(const TCollection_AsciiString& study_name)
103 Handle(TDocStd_Document) Doc;
104 _OCAFApp->NewDocument("SALOME_STUDY",Doc);
106 Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, study_name);
109 Study->StudyId( _IDcounter );
111 // set Study properties
112 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Study->GetProperties();
113 OSD_Process aProcess;
114 Quantity_Date aDate = aProcess.SystemDate();
115 aProp->SetModification(aProcess.UserName().ToCString(),
116 aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year());
117 aProp->SetCreationMode(1); //"from scratch"
122 //============================================================================
124 * Purpose : Open a Study from it's persistent reference
126 //============================================================================
127 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_AsciiString& aUrl)
132 HDFfile *hdf_file =0;
133 HDFgroup *hdf_group_study_structure =0;
136 TCollection_AsciiString aHDFUrl;
137 bool isASCII = false;
138 if (HDFascii::isASCII(aUrl.ToCString())) {
140 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aUrl.ToCString());
141 aC_HDFUrl = new char[strlen(aResultPath) + 19];
142 sprintf(aC_HDFUrl, "%shdf_from_ascii.hdf", aResultPath);
150 hdf_file = new HDFfile((char*)aHDFUrl.ToCString());
152 hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too
157 // char eStr[strlen(aUrl.ToCString())+17];
160 eStr = new char[strlen(aUrl.ToCString())+17];
162 sprintf(eStr,"Can't open file %s",aUrl.ToCString());
166 _errorCode = TCollection_AsciiString(eStr);
170 // Temporary aStudyUrl in place of study name
171 Handle(TDocStd_Document) Doc;
172 _OCAFApp->NewDocument("SALOME_STUDY",Doc);
174 Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, aUrl);
177 Study->StudyId( _IDcounter );
179 // Assign the value of the URL in the study object
182 SALOMEDSImpl_AttributePersistentRef::Set(Doc->Main(), aUrl);
184 if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) {
185 _errorCode = "Study is empty";
189 //Create the Structure of the OCAF Document
190 hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
192 Handle(TDF_Data) DF = Doc->GetData();
194 BuildTree (Study, hdf_group_study_structure);
199 // char eStr[strlen(aUrl.ToCString())+17];
201 char *eStr = new char [strlen(aUrl.ToCString())+17];
203 sprintf(eStr,"Can't open file %s", aUrl.ToCString());
204 _errorCode = TCollection_AsciiString(eStr);
208 hdf_file->CloseOnDisk();
211 Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString;
212 aFilesToRemove->Append("hdf_from_ascii.hdf");
213 SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
216 delete hdf_file; // all related hdf objects will be deleted
223 //============================================================================
225 * Purpose : Close a study.
226 * If the study hasn't been saved, ask the user to confirm the
227 * close action without saving
230 //============================================================================
231 void SALOMEDSImpl_StudyManager::Close(const Handle(SALOMEDSImpl_Study)& aStudy)
235 if(aStudy.IsNull()) {
236 _errorCode = "Study is null";
243 //============================================================================
245 * Purpose : Save a Study to it's persistent reference
247 //============================================================================
248 bool SALOMEDSImpl_StudyManager::Save(const Handle(SALOMEDSImpl_Study)& aStudy,
249 SALOMEDSImpl_DriverFactory* aFactory,
254 TCollection_AsciiString url = aStudy->URL();
256 _errorCode = "No path specified to save the study. Nothing done";
260 return Impl_SaveAs(url,aStudy, aFactory, theMultiFile, false);
266 bool SALOMEDSImpl_StudyManager::SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy,
267 SALOMEDSImpl_DriverFactory* aFactory,
272 TCollection_AsciiString url = aStudy->URL();
274 _errorCode = "No path specified to save the study. Nothing done";
278 return Impl_SaveAs(url,aStudy, aFactory, theMultiFile, true);
284 //=============================================================================
285 /*! Function : SaveAs
286 * Purpose : Save a study to the persistent reference aUrl
288 //============================================================================
289 bool SALOMEDSImpl_StudyManager::SaveAs(const TCollection_AsciiString& aUrl,
290 const Handle(SALOMEDSImpl_Study)& aStudy,
291 SALOMEDSImpl_DriverFactory* aFactory,
295 return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, false);
298 bool SALOMEDSImpl_StudyManager::SaveAsASCII(const TCollection_AsciiString& aUrl,
299 const Handle(SALOMEDSImpl_Study)& aStudy,
300 SALOMEDSImpl_DriverFactory* aFactory,
304 return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, true);
307 //============================================================================
308 /*! Function : GetOpenStudies
309 * Purpose : Get name list of open studies in the session
311 //============================================================================
312 Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_StudyManager::GetOpenStudies()
315 Handle(TColStd_HSequenceOfTransient) aList = new TColStd_HSequenceOfTransient;
317 int nbDocs = _OCAFApp->NbDocuments();
320 _errorCode = "No active study in this session";
324 Handle(SALOMEDSImpl_Study) aStudy;
325 Handle(CDF_Session) S = CDF_Session::CurrentSession();
326 CDF_DirectoryIterator it (S->Directory());
327 for (;it.MoreDocument();it.NextDocument()) {
328 Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document());
329 if(D == _clipboard) continue;
330 aStudy = SALOMEDSImpl_Study::GetStudy(D->Main());
331 if(aStudy.IsNull()) continue;
332 aList->Append(aStudy);
339 //============================================================================
340 /*! Function : GetStudyByName
341 * Purpose : Get a study from its name
343 //============================================================================
344 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName
345 (const TCollection_AsciiString& aStudyName)
348 int nbDocs = _OCAFApp->NbDocuments();
351 _errorCode = "No active study in this session";
355 Handle(SALOMEDSImpl_Study) aStudy;
356 Handle(CDF_Session) S = CDF_Session::CurrentSession();
357 CDF_DirectoryIterator it (S->Directory());
358 for (; it.MoreDocument(); it.NextDocument()) {
359 Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document());
360 if (D == _clipboard) continue;
361 aStudy = SALOMEDSImpl_Study::GetStudy(D->Main());
362 if (aStudy.IsNull()) continue;
363 if (aStudy->Name() == aStudyName) return aStudy;
367 _errorCode = TCollection_AsciiString("Found no study with the name ") + aStudyName;
371 //============================================================================
372 /*! Function : GetStudyByID
373 * Purpose : Get a study from its ID
375 //============================================================================
376 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID)
379 int nbDocs = _OCAFApp->NbDocuments();
382 _errorCode = "No active study in this session";
386 Handle(SALOMEDSImpl_Study) aStudy;
387 Handle(CDF_Session) S = CDF_Session::CurrentSession();
388 CDF_DirectoryIterator it (S->Directory());
389 for (; it.MoreDocument(); it.NextDocument()) {
390 Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document());
391 if (D == _clipboard) continue;
392 aStudy = SALOMEDSImpl_Study::GetStudy(D->Main());
393 if (aStudy.IsNull()) continue;
394 if (aStudy->StudyId() == aStudyID) return aStudy;
398 _errorCode = "Found no study with the given ID";
402 //=============================================================================
403 /*! Function : _SaveProperties
404 * Purpose : save the study properties in HDF file
406 //============================================================================
407 bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy,
412 HDFdataset *hdf_dataset = 0;
416 // add modifications list (user and date of save)
417 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = aStudy->GetProperties();
418 Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder();
419 int aLocked = aProp->IsLocked();
420 if (aLocked) aProp->SetLocked(Standard_False);
422 OSD_Process aProcess;
423 Quantity_Date aDate = aProcess.SystemDate();
424 aProp->SetModification(aProcess.UserName().ToCString(),
425 aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year());
427 if (aLocked) aProp->SetLocked(Standard_True);
429 Handle(TColStd_HSequenceOfExtendedString) aNames;
430 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
432 aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
434 int aLength = 0, anIndex, i;
435 for(i=1; i<=aNames->Length(); i++)
436 aLength += aNames->Value(i).Length() + 1;
438 //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte
439 char* aProperty = new char[3 + aLength + 12 * aNames->Length()];
442 sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u');
444 aLength = aNames->Length();
446 for(anIndex = 1; anIndex <= aLength; anIndex++) {
447 sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s",
448 (int)(aMinutes->Value(anIndex)),
449 (int)(aHours->Value(anIndex)),
450 (int)(aDays->Value(anIndex)),
451 (int)(aMonths->Value(anIndex)),
452 (int)(aYears->Value(anIndex)),
453 TCollection_AsciiString(aNames->Value(anIndex)).ToCString());
454 a = strlen(aProperty);
459 name_len = (hdf_int32) a;
460 size[0] = name_len + 1 ;
461 hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
462 hdf_dataset->CreateOnDisk();
463 hdf_dataset->WriteOnDisk(aProperty);
464 hdf_dataset->CloseOnDisk();
465 hdf_dataset=0; //will be deleted by hdf_sco_group destructor
468 aProp->SetModified(0);
472 //=============================================================================
473 /*! Function : _SaveAs
474 * Purpose : save the study in HDF file
476 //============================================================================
477 bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl,
478 const Handle(SALOMEDSImpl_Study)& aStudy,
479 SALOMEDSImpl_DriverFactory* aFactory,
483 // HDF File will be composed of differents part :
484 // * For each ComponentDataType, all data created by the component
485 // Informations in data group hdf_group_datacomponent
486 // * Study Structure -> Exactly what is contained in OCAF document
487 // Informations in data group hdf_group_study_structure
492 HDFgroup *hdf_group_study_structure =0;
493 HDFgroup *hdf_sco_group =0;
494 HDFgroup *hdf_sco_group2 =0;
496 HDFgroup *hdf_group_datacomponent =0;
497 HDFdataset *hdf_dataset =0;
499 hdf_int32 name_len = 0;
500 char *component_name = 0;
502 int aLocked = aStudy->GetProperties()->IsLocked();
503 if (aLocked) aStudy->GetProperties()->SetLocked(false);
505 Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder();
506 map<char*, SALOMEDSImpl_Driver*> aMapTypeDriver;
508 if(aStudy.IsNull()) {
509 _errorCode = "Study is null";
515 // mpv 15.12.2003: for saving components we have to load all data from all modules
516 SALOMEDSImpl_SComponentIterator itcomponent1 = aStudy->NewComponentIterator();
517 for (; itcomponent1.More(); itcomponent1.Next())
519 Handle(SALOMEDSImpl_SComponent) sco = itcomponent1.Value();
521 // if there is an associated Engine call its method for saving
522 TCollection_AsciiString IOREngine;
524 if (!sco->ComponentIOR(IOREngine)) {
525 TCollection_AsciiString aCompType = sco->GetComment();
526 if (!aCompType.IsEmpty()) {
528 SALOMEDSImpl_Driver* aDriver = aFactory->GetDriverByType(aCompType);
529 aMapTypeDriver[aCompType.ToCString()] = aDriver;
531 if (aDriver != NULL) {
532 if(!SB->LoadWith(sco, aDriver)) {
533 _errorCode = SB->GetErrorCode();
540 _errorCode = "Can not restore information to resave it";
545 TCollection_AsciiString anOldName = aStudy->Name();
548 // To change for Save
549 // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything??
550 hdf_file = new HDFfile(aUrl.ToCString());
551 hdf_file->CreateOnDisk();
553 //-----------------------------------------------------------------------
554 // 1 - Create a groupe for each SComponent and Update the PersistanceRef
555 //-----------------------------------------------------------------------
556 hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file);
557 hdf_group_datacomponent->CreateOnDisk();
559 SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator();
561 //SRN: Added 17 Nov, 2003
562 Handle(SALOMEDSImpl_SObject) anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG);
564 for (; itcomponent.More(); itcomponent.Next())
566 Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value();
568 TCollection_AsciiString scoid = sco->GetID();
569 hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent);
570 hdf_sco_group->CreateOnDisk();
572 TCollection_AsciiString componentDataType = sco->ComponentDataType();
574 //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save
575 if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) {
577 Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
578 if(anAutoSaveSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(), aTable)) {
579 Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0;
580 if(nbRows > 0 && aTable->GetNbColumns() > 1) {
582 Handle(TColStd_HSequenceOfExtendedString) aRow;
583 for(k=1; k<=nbRows; k++) {
584 aRow = aTable->GetRowData(k);
585 if (aRow->Value(1) == componentDataType) {
586 TCollection_AsciiString anEntry = TCollection_AsciiString(aRow->Value(2));
587 Handle(SALOMEDSImpl_SObject) aCompSpecificSO = aStudy->FindObjectID(anEntry);
588 if(!aCompSpecificSO.IsNull()) {
589 Handle(SALOMEDSImpl_AttributeInteger) anInteger;
590 if(aCompSpecificSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) {
591 anInteger->SetValue(-1);
592 while(anInteger->Value() < 0) {
598 if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS)
601 } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger"))
602 } // if(!CORBA::is_nil(aCompSpecificSO))
603 } // if (strcmp(aRow[0], componentDataType) == 0)
606 } // if(nbRows > 0 && aTable->GetNbColumns() > 1)
608 } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString")
610 } // if(SB->IsGUID(AUTO_SAVE_GUID)
613 TCollection_AsciiString IOREngine;
614 if (sco->ComponentIOR(IOREngine))
616 SALOMEDSImpl_Driver* Engine = NULL;
617 if(aMapTypeDriver.find(componentDataType.ToCString()) != aMapTypeDriver.end()) {
618 // we have found the associated engine to write the data
619 Engine = aMapTypeDriver[componentDataType.ToCString()];
622 Engine = aFactory->GetDriverByIOR(IOREngine);
627 Handle(SALOMEDSImpl_TMPFile) aStream;
630 if (theASCII) aStream = Engine->SaveASCII(sco,
631 SALOMEDSImpl_Tool::GetDirFromPath(aUrl),
634 else aStream = Engine->Save(sco,
635 SALOMEDSImpl_Tool::GetDirFromPath(aUrl),
638 HDFdataset *hdf_dataset;
639 hdf_size aHDFSize[1];
640 if(length > 0) { //The component saved some auxiliary files, then put them into HDF file
642 aHDFSize[0] = length;
644 HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
645 hdf_dataset->CreateOnDisk();
646 hdf_dataset->WriteOnDisk(aStream->Data()); //Save the stream in the HDF file
647 hdf_dataset->CloseOnDisk();
650 // store multifile state
652 hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
653 hdf_dataset->CreateOnDisk();
654 hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single
655 hdf_dataset->CloseOnDisk();
656 hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
659 hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
660 hdf_dataset->CreateOnDisk();
661 hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY
662 hdf_dataset->CloseOnDisk();
663 hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
664 // Creation of the persistance reference attribute
665 Translate_IOR_to_persistentID (sco, Engine, theMultiFile, theASCII);
668 hdf_sco_group->CloseOnDisk();
669 hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor
671 hdf_group_datacomponent->CloseOnDisk();
672 hdf_group_datacomponent =0; // will be deleted by hdf_file destructor
674 //-----------------------------------------------------------------------
675 //3 - Write the Study Structure
676 //-----------------------------------------------------------------------
677 hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
678 hdf_group_study_structure->CreateOnDisk();
679 // save component attributes
680 SALOMEDSImpl_SComponentIterator itcomp = aStudy->NewComponentIterator();
681 for (; itcomp.More(); itcomp.Next())
683 Handle(SALOMEDSImpl_SComponent) SC = itcomp.Value();
684 TCollection_AsciiString scid = SC->GetID();
685 hdf_sco_group2 = new HDFgroup(scid.ToCString(), hdf_group_study_structure);
686 hdf_sco_group2->CreateOnDisk();
687 SaveAttributes(SC, hdf_sco_group2);
688 // ComponentDataType treatment
689 component_name = SC->ComponentDataType().ToCString();
690 name_len = (hdf_int32)strlen(component_name);
691 size[0] = name_len +1 ;
692 hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1);
693 hdf_dataset->CreateOnDisk();
694 hdf_dataset->WriteOnDisk(component_name);
695 hdf_dataset->CloseOnDisk();
696 hdf_dataset=0; //will be deleted by hdf_sco_group destructor
697 Impl_SaveObject(SC, hdf_sco_group2);
698 hdf_sco_group2->CloseOnDisk();
699 hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor
702 //-----------------------------------------------------------------------
703 //4 - Write the Study UseCases Structure
704 //-----------------------------------------------------------------------
705 Handle(SALOMEDSImpl_SObject) aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID);
707 HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure);
708 hdf_soo_group->CreateOnDisk();
709 SaveAttributes(aSO, hdf_soo_group);
710 Impl_SaveObject(aSO, hdf_soo_group);
711 hdf_soo_group->CloseOnDisk();
712 hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor
715 if (aLocked) aStudy->GetProperties()->SetLocked(true);
716 //-----------------------------------------------------------------------
717 //5 - Write the Study Properties
718 //-----------------------------------------------------------------------
719 name_len = (hdf_int32) aStudy->Name().Length();
720 size[0] = name_len +1 ;
721 hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1);
722 hdf_dataset->CreateOnDisk();
723 char* studid = aStudy->Name().ToCString();
724 hdf_dataset->WriteOnDisk(studid);
725 hdf_dataset->CloseOnDisk();
726 hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor
728 Impl_SaveProperties(aStudy, hdf_group_study_structure);
730 hdf_group_study_structure->CloseOnDisk();
731 hdf_file->CloseOnDisk();
733 aStudy->IsSaved(true);
734 hdf_group_study_structure =0; // will be deleted by hdf_file destructor
735 delete hdf_file; // recursively deletes all hdf objects...
739 _errorCode = "HDFexception ! ";
742 catch(std::exception& exc)
744 _errorCode = const_cast<char*>(exc.what());
749 _errorCode = "Unknown exception ! ";
752 if (theASCII) { // save file in ASCII format
753 HDFascii::ConvertFromHDFToASCII(aUrl.ToCString(), true);
759 //============================================================================
760 /*! Function : Impl_SaveObject
763 //============================================================================
764 bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC,
765 HDFgroup *hdf_group_datatype)
769 // Write in group hdf_group_datatype all informations of SObject SC
770 // Iterative function to parse all SObjects under a SComponent
772 HDFgroup *hdf_group_sobject = 0;
774 TDF_ChildIterator itchild(SC->GetLabel());
775 for (; itchild.More(); itchild.Next())
778 // mpv: don't save empty labels
779 TDF_AttributeIterator AI1(itchild.Value());
780 if (!AI1.More()) { //No attributes on the label
781 TDF_ChildIterator subchild(SC->GetLabel());
782 if (!subchild.More()) {
785 subchild.Initialize(SC->GetLabel(), true);
787 for (; subchild.More() && anEmpty; subchild.Next()) {
788 TDF_AttributeIterator AI2(subchild.Value());
789 if (AI2.More()) anEmpty = false; //There are attributes on the child label
791 if (anEmpty) continue;
794 Handle(SALOMEDSImpl_SObject) SO = SALOMEDSImpl_Study::SObject(itchild.Value());
796 char* scoid = (char*) SO->GetID().ToCString();
797 hdf_group_sobject = new HDFgroup(scoid, hdf_group_datatype);
798 hdf_group_sobject->CreateOnDisk();
799 SaveAttributes(SO, hdf_group_sobject);
800 Impl_SaveObject(SO, hdf_group_sobject);
801 hdf_group_sobject->CloseOnDisk();
802 hdf_group_sobject =0; // will be deleted by father hdf object destructor
808 //============================================================================
809 /*! Function : Impl_SubstituteSlash
812 //============================================================================
813 TCollection_AsciiString SALOMEDSImpl_StudyManager::Impl_SubstituteSlash(const TCollection_AsciiString& aUrl)
817 TCollection_ExtendedString theUrl(aUrl);
818 Standard_ExtCharacter val1 = ToExtCharacter('/');
819 Standard_ExtCharacter val2 = ToExtCharacter(':');
820 theUrl.ChangeAll(val1,val2);
824 //============================================================================
825 /*! Function : GetDocumentOfStudy
828 //============================================================================
829 Handle(TDocStd_Document) SALOMEDSImpl_StudyManager::GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy)
832 return theStudy->_doc;
835 //============================================================================
836 /*! Function : CanCopy
839 //============================================================================
840 bool SALOMEDSImpl_StudyManager::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject,
841 SALOMEDSImpl_Driver* theEngine)
844 Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent();
845 if (aComponent.IsNull()) return false;
846 if (aComponent->GetLabel() == theObject->GetLabel()) return false;
847 TCollection_AsciiString IOREngine;
848 if (!aComponent->ComponentIOR(IOREngine)) return false;
849 if (theEngine == NULL) return false;
850 return theEngine->CanCopy(theObject);
853 //============================================================================
854 /*! Function : CopyLabel
857 //============================================================================
858 bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theSourceStudy,
859 SALOMEDSImpl_Driver* theEngine,
860 const Standard_Integer theSourceStartDepth,
861 const TDF_Label& theSource,
862 const TDF_Label& theDestinationMain)
867 TDF_Label aTargetLabel = theDestinationMain;
868 TDF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2);
869 for(a = theSource.Depth() - theSourceStartDepth; a > 0 ; a--) {
870 TDF_Label aSourceLabel = theSource;
871 for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
872 aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
873 aAuxTargetLabel = aAuxTargetLabel.FindChild(aSourceLabel.Tag());
875 // iterate attributes
876 TDF_AttributeIterator anAttrIterator(theSource);
877 Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable();
878 for(; anAttrIterator.More(); anAttrIterator.Next()) {
879 Handle(TDF_Attribute) anAttr = anAttrIterator.Value();
880 if (!Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(anAttr).IsNull()) continue; // never copy tree node attribute
881 if (!Handle(SALOMEDSImpl_AttributeTarget)::DownCast(anAttr).IsNull()) continue; // and target attribute
883 if (!Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr).IsNull()) { // reference copied as Comment in aux tree
884 TDF_Label aReferenced = Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr)->Get();
885 TCollection_AsciiString anEntry;
886 TDF_Tool::Entry(aReferenced, anEntry);
887 // store the value of name attribute of referenced label
888 Handle(SALOMEDSImpl_AttributeName) aNameAttribute;
889 if (aReferenced.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttribute)) {
891 anEntry += aNameAttribute->Value();
893 SALOMEDSImpl_AttributeComment::Set(aAuxTargetLabel, TCollection_ExtendedString(anEntry));
897 if (!Handle(SALOMEDSImpl_AttributeIOR)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine
898 TCollection_AsciiString anEntry;
899 TDF_Tool::Entry(theSource, anEntry);
900 Handle(SALOMEDSImpl_SObject) aSO = theSourceStudy->FindObjectID(anEntry.ToCString());
903 Handle(SALOMEDSImpl_TMPFile) aStream = theEngine->CopyFrom(aSO, anObjID, aLen);
904 TCollection_ExtendedString aResStr("");
905 for(a = 0; a < aLen; a++) {
906 aResStr += TCollection_ExtendedString(ToExtCharacter(Standard_Character(aStream->Get(a))));
908 SALOMEDSImpl_AttributeInteger::Set(aAuxTargetLabel, anObjID);
909 SALOMEDSImpl_AttributeName::Set(aAuxTargetLabel, aResStr);
912 Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty();
913 aTargetLabel.AddAttribute(aNewAttribute);
914 anAttr->Paste(aNewAttribute, aRT);
920 //============================================================================
924 //============================================================================
925 bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObject,
926 SALOMEDSImpl_Driver* theEngine)
930 // adoptation for alliances datamodel copy: without IOR attributes !!!
931 bool aStructureOnly; // copy only SObjects and attributes without component help
932 aStructureOnly = !theObject->GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID());
934 // get component-engine
935 Handle(SALOMEDSImpl_Study) aStudy = theObject->GetStudy();
937 // CAF document of current study usage
938 Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy);
939 if (aDocument.IsNull()) {
940 _errorCode = "OCAF document is null";
944 //Clear the clipboard
945 _clipboard->Main().Root().ForgetAllAttributes(Standard_True);
946 _OCAFApp->Close(_clipboard);
947 Handle(TDocStd_Document) aDoc;
948 _OCAFApp->NewDocument("SALOME_STUDY", aDoc);
951 // set component data type to the name attribute of root label
952 if (!aStructureOnly) {
953 SALOMEDSImpl_AttributeComment::Set(_clipboard->Main().Root(),
954 TCollection_ExtendedString(theEngine->ComponentDataType()));
956 // set to the Root label integer attribute: study id
957 SALOMEDSImpl_AttributeInteger::Set(_clipboard->Main().Root(), aStudy->StudyId());
958 // iterate all theObject's label children
959 TDF_Label aStartLabel = theObject->GetLabel();
960 Standard_Integer aSourceStartDepth = aStartLabel.Depth();
962 // copy main source label
963 CopyLabel(aStudy, theEngine, aSourceStartDepth, aStartLabel, _clipboard->Main());
965 // copy all subchildren of the main source label (all levels)
966 TDF_ChildIterator anIterator(aStartLabel, Standard_True);
967 for(; anIterator.More(); anIterator.Next()) {
968 CopyLabel(aStudy, theEngine, aSourceStartDepth, anIterator.Value(), _clipboard->Main());
973 //============================================================================
974 /*! Function : CanPaste
977 //============================================================================
978 bool SALOMEDSImpl_StudyManager::CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject,
979 SALOMEDSImpl_Driver* theEngine)
983 if (_clipboard.IsNull()) {
984 _errorCode = "Clipboard is null";
988 Handle(SALOMEDSImpl_AttributeComment) aCompName;
989 if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aCompName)) {
990 _errorCode = "Clipboard has no component type";
993 Handle(SALOMEDSImpl_AttributeInteger) anObjID;
994 if (!_clipboard->Main().Father().FindChild(2).FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anObjID)) {
995 _errorCode = "Clipboard has no object id";
998 Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent();
999 if (aComponent.IsNull()) {
1000 _errorCode = "Object doesn't belong to component";
1004 TCollection_AsciiString IOREngine;
1005 if (!aComponent->ComponentIOR(IOREngine)) {
1006 _errorCode = "component has no IOR";
1009 return theEngine->CanPaste(aCompName->Value(), anObjID->Value());
1012 //============================================================================
1013 /*! Function : PasteLabel
1016 //============================================================================
1017 TDF_Label SALOMEDSImpl_StudyManager::PasteLabel(const Handle(SALOMEDSImpl_Study)& theDestinationStudy,
1018 SALOMEDSImpl_Driver* theEngine,
1019 const TDF_Label& theSource,
1020 const TDF_Label& theDestinationStart,
1021 const int theCopiedStudyID,
1022 const bool isFirstElement)
1026 // get corresponding source, target and auxiliary labels
1027 TDF_Label aTargetLabel = theDestinationStart;
1029 TDF_Label aAuxSourceLabel = theSource.Root().FindChild(2);
1031 if (!isFirstElement) {
1032 for(a = theSource.Depth() - 1; a > 0 ; a--) {
1033 TDF_Label aSourceLabel = theSource;
1034 for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
1035 aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
1036 aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag());
1040 // check auxiliary label for TMPFile => IOR
1041 Handle(SALOMEDSImpl_AttributeName) aNameAttribute;
1042 if (aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttribute)) {
1043 Handle(SALOMEDSImpl_AttributeInteger) anObjID;
1045 aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anObjID);
1046 Handle(SALOMEDSImpl_AttributeComment) aComponentName;
1047 theSource.Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComponentName);
1048 TCollection_AsciiString aCompName = aComponentName->Value();
1050 if (theEngine->CanPaste(aCompName, anObjID->Value())) {
1051 TCollection_ExtendedString aTMPStr = aNameAttribute->Value();
1052 int aLen = aTMPStr.Length();
1053 unsigned char* aStream = NULL;
1055 aStream = new unsigned char[aLen+10];
1056 for(a = 0; a < aLen; a++) {
1057 aStream[a] = ToCharacter(aTMPStr.Value(a+1));
1061 TCollection_AsciiString anEntry;
1062 TDF_Tool::Entry(aTargetLabel, anEntry);
1063 Handle(SALOMEDSImpl_SObject) aPastedSO = theDestinationStudy->FindObjectID(anEntry);
1065 if (isFirstElement) {
1066 TCollection_AsciiString aDestEntry = theEngine->PasteInto(aStream,
1069 aPastedSO->GetFatherComponent());
1070 TDF_Tool::Label(theDestinationStart.Data(), aDestEntry, aTargetLabel);
1072 theEngine->PasteInto(aStream, aLen, anObjID->Value(), aPastedSO);
1074 if(aStream != NULL) delete []aStream;
1078 // iterate attributes
1079 TDF_AttributeIterator anAttrIterator(theSource);
1080 Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable();
1081 for(; anAttrIterator.More(); anAttrIterator.Next()) {
1082 Handle(TDF_Attribute) anAttr = anAttrIterator.Value();
1083 if (aTargetLabel.FindAttribute(anAttr->ID(), anAttr)) {
1084 aTargetLabel.ForgetAttribute(anAttr->ID());
1085 anAttr = anAttrIterator.Value();
1087 Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty();
1088 aTargetLabel.AddAttribute(aNewAttribute);
1089 anAttr->Paste(aNewAttribute, aRT);
1092 // check auxiliary label for Comment => reference or name attribute of the referenced object
1093 Handle(SALOMEDSImpl_AttributeComment) aCommentAttribute;
1094 if (aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aCommentAttribute)) {
1095 char * anEntry = new char[aCommentAttribute->Value().Length() + 1];
1096 strcpy(anEntry, TCollection_AsciiString(aCommentAttribute->Value()).ToCString());
1097 char* aNameStart = strchr(anEntry, ' ');
1102 if (theCopiedStudyID == theDestinationStudy->StudyId()) { // if copy to the same study, reanimate reference
1103 TDF_Label aRefLabel;
1104 TDF_Tool::Label(aTargetLabel.Data(), anEntry, aRefLabel);
1105 SALOMEDSImpl_AttributeReference::Set(aTargetLabel, aRefLabel);
1106 // target attributes structure support
1107 SALOMEDSImpl_AttributeTarget::Set(aRefLabel)->Add(SALOMEDSImpl_Study::SObject(aTargetLabel));
1109 if (aNameStart) SALOMEDSImpl_AttributeName::Set(aTargetLabel, aNameStart);
1110 else SALOMEDSImpl_AttributeName::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry);
1115 return aTargetLabel;
1118 //============================================================================
1119 /*! Function : Paste
1122 //============================================================================
1123 Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOMEDSImpl_SObject)& theObject,
1124 SALOMEDSImpl_Driver* theEngine)
1128 Handle(SALOMEDSImpl_Study) aStudy = theObject->GetStudy();
1130 // if study is locked, then paste can't be done
1131 if (aStudy->GetProperties()->IsLocked()) {
1132 _errorCode = "LockProtection";
1133 throw LockProtection("LockProtection");
1136 // if there is no component name, then paste only SObjects and attributes: without component help
1137 Handle(SALOMEDSImpl_AttributeComment) aComponentName;
1138 bool aStructureOnly = !_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComponentName);
1140 // get copied study ID
1141 Handle(SALOMEDSImpl_AttributeInteger) aStudyIDAttribute;
1142 if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), aStudyIDAttribute)) {
1143 _errorCode = "No study ID was found";
1146 int aCStudyID = aStudyIDAttribute->Value();
1148 // CAF document of current study usage
1149 Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy);
1150 if (aDocument.IsNull()) {
1151 _errorCode = "OCAF document is null";
1155 Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent();
1157 // fill root inserted SObject
1158 TDF_Label aStartLabel;
1159 if (aStructureOnly) {
1160 TDF_Label anObjectLabel;
1161 TDF_Tool::Label(aDocument->GetData(), theObject->GetID(), anObjectLabel);
1162 aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), anObjectLabel, aCStudyID, false);
1164 TDF_Label aComponentLabel;
1165 TDF_Tool::Label(aDocument->GetData(), aComponent->GetID(), aComponentLabel);
1166 aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), aComponentLabel, aCStudyID, true);
1169 // paste all sublebels
1170 TDF_ChildIterator anIterator(_clipboard->Main(), Standard_True);
1171 for(; anIterator.More(); anIterator.Next()) {
1172 PasteLabel(aStudy, theEngine, anIterator.Value(), aStartLabel, aCStudyID, false);
1175 return SALOMEDSImpl_Study::SObject(aStartLabel);
1178 //#######################################################################################################
1179 //# STATIC PRIVATE FUNCTIONS
1180 //#######################################################################################################
1182 //============================================================================
1183 /*! Function : SaveAttributes
1184 * Purpose : Save attributes for object
1186 //============================================================================
1187 static void SaveAttributes(Handle(SALOMEDSImpl_SObject) aSO, HDFgroup *hdf_group_sobject)
1190 TDF_AttributeIterator Itr(aSO->GetLabel());
1191 Handle(TDF_Attribute) anAttr;
1192 for(; Itr.More(); Itr.Next()) {
1193 anAttr = Itr.Value();
1194 //The following attributes are not supposed to be written to the file
1195 if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeIOR)) continue; //IOR attribute is not saved
1196 Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr);
1197 TCollection_AsciiString aSaveStr = ga->Save();
1198 //cout << "Saving: " << aSO->GetID() << " "<< ga->Type() << " value: " << aSaveStr << endl;
1199 size[0] = (hdf_int32) strlen(aSaveStr.ToCString()) + 1;
1200 HDFdataset *hdf_dataset = new HDFdataset((char*)ga->Type().ToCString(), hdf_group_sobject,HDF_STRING,size,1);
1201 hdf_dataset->CreateOnDisk();
1202 hdf_dataset->WriteOnDisk((char*)aSaveStr.ToCString());
1203 hdf_dataset->CloseOnDisk();
1204 hdf_dataset=0; //will be deleted by hdf_sco_group destructor
1208 //===========================================================================
1209 //Function : ReadAttributes
1210 //===========================================================================
1211 static void ReadAttributes(const Handle(SALOMEDSImpl_Study)& theStudy,
1212 const Handle(SALOMEDSImpl_SObject)& aSO,
1213 HDFdataset* hdf_dataset)
1215 hdf_dataset->OpenOnDisk();
1217 Handle(TDF_Attribute) anAttr;
1219 char* current_string = new char[hdf_dataset->GetSize()];
1220 hdf_dataset->ReadFromDisk(current_string);
1222 if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) {
1223 anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
1224 } else if (!strcmp(hdf_dataset->GetName(),"AttributeReference") ||
1225 !strcmp(hdf_dataset->GetName(),"Reference")) { // Old format maintainance
1226 theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
1227 delete(current_string);
1228 hdf_dataset->CloseOnDisk();
1231 anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
1234 if (!anAttr.IsNull()) {
1236 Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr);
1237 ga->Load(current_string);
1238 //cout << "Reading: " << aSO->GetID() << " "<< ga->Type() << " value: " << current_string << endl;
1241 delete(current_string);
1242 hdf_dataset->CloseOnDisk();
1245 //============================================================================
1246 //Function : BuildlTree
1247 //============================================================================
1248 static void BuildTree (const Handle(SALOMEDSImpl_Study)& theStudy, HDFgroup* hdf_current_group)
1250 hdf_current_group->OpenOnDisk();
1251 Handle(SALOMEDSImpl_SObject) aSO;
1252 char* Entry = hdf_current_group->GetName();
1253 if (strcmp(Entry,"STUDY_STRUCTURE") == 0) {
1254 aSO = theStudy->CreateObjectID("0:1");
1257 aSO = theStudy->CreateObjectID(Entry);
1260 char name[HDF_NAME_MAX_LEN+1];
1261 Standard_Integer nbsons = hdf_current_group->nInternalObjects();
1262 for (Standard_Integer i=0; i<nbsons; i++) {
1263 hdf_current_group->InternalObjectIndentify(i,name);
1264 if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
1265 hdf_object_type type = hdf_current_group->InternalObjectType(name);
1267 if (type == HDF_DATASET) {
1268 HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group);
1269 ReadAttributes(theStudy,aSO,new_dataset);
1270 new_dataset = 0; // will be deleted by father destructor
1273 else if (type == HDF_GROUP) {
1274 HDFgroup* new_group = new HDFgroup(name,hdf_current_group);
1275 BuildTree (theStudy, new_group);
1276 new_group = 0; // will be deleted by father destructor
1279 hdf_current_group->CloseOnDisk();
1283 //============================================================================
1284 //Function : Translate_IOR_to_persistentID
1285 //============================================================================
1286 static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)& so,
1287 SALOMEDSImpl_Driver* engine,
1291 TDF_ChildIterator itchild(so->GetLabel());
1292 TCollection_AsciiString ior_string, persistent_string, curid;
1294 for (; itchild.More(); itchild.Next()) {
1295 Handle(SALOMEDSImpl_SObject) current = SALOMEDSImpl_Study::SObject(itchild.Value());
1296 Handle(SALOMEDSImpl_AttributeIOR) IOR;
1297 if (current->GetLabel().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), IOR)) {
1298 ior_string = IOR->Value();
1300 persistent_string = engine->IORToLocalPersistentID (current, ior_string, isMultiFile, isASCII);
1301 SALOMEDSImpl_AttributePersistentRef::Set(current->GetLabel(), persistent_string);
1303 Translate_IOR_to_persistentID (current, engine, isMultiFile, isASCII);