1 // Created on: 1997-12-01
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <CDM_Application.hxx>
19 #include <CDM_Document.hxx>
20 #include <CDM_MessageDriver.hxx>
21 #include <CDM_MetaData.hxx>
22 #include <OSD_Path.hxx>
23 #include <PCDM_Reference.hxx>
24 #include <PCDM_ReferenceIterator.hxx>
25 #include <PCDM_RetrievalDriver.hxx>
26 #include <Standard_Type.hxx>
27 #include <Storage_Data.hxx>
34 //=======================================================================
35 //function : PCDM_ReferenceIterator
37 //=======================================================================
39 PCDM_ReferenceIterator::PCDM_ReferenceIterator (const Handle(CDM_MessageDriver)& theMsgDriver) :
42 myMessageDriver = theMsgDriver;
45 //=======================================================================
46 //function : LoadReferences
48 //=======================================================================
50 void PCDM_ReferenceIterator::LoadReferences(const Handle(CDM_Document)& aDocument,
51 const Handle(CDM_MetaData)& aMetaData,
52 const Handle(CDM_Application)& anApplication,
53 const Standard_Boolean UseStorageConfiguration) {
54 for (Init(aMetaData);More();Next()) {
55 aDocument->CreateReference(MetaData(UseStorageConfiguration),ReferenceIdentifier(),
56 anApplication,DocumentVersion(),UseStorageConfiguration);
60 //=======================================================================
63 //=======================================================================
65 void PCDM_ReferenceIterator::Init(const Handle(CDM_MetaData)& theMetaData) {
69 PCDM_RetrievalDriver::References(theMetaData->FileName(), myReferences,
74 //=======================================================================
77 //=======================================================================
79 Standard_Boolean PCDM_ReferenceIterator::More() const {
80 return myIterator <= myReferences.Length();
83 //=======================================================================
86 //=======================================================================
88 void PCDM_ReferenceIterator::Next() {
92 //=======================================================================
95 //=======================================================================
97 Handle(CDM_MetaData) PCDM_ReferenceIterator::MetaData(const Standard_Boolean ) const {
99 TCollection_ExtendedString theFolder,theName;
100 TCollection_ExtendedString theFile=myReferences(myIterator).FileName();
101 TCollection_ExtendedString f(theFile);
104 Standard_Integer i= f.SearchFromEnd("/");
105 TCollection_ExtendedString n = f.Split(i);
106 f.Trunc(f.Length()-1);
110 OSD_Path p = UTL::Path(f);
111 Standard_ExtCharacter chr;
112 TCollection_ExtendedString dir, dirRet, name;
117 for ( int i = 1; i <= dir.Length (); ++i ) {
119 chr = dir.Value ( i );
124 dirRet += _TEXT( "/" );
129 dirRet += _TEXT( ".." );
138 theName = UTL::Name(p); theName+= UTL::Extension(p);
141 return CDM_MetaData::LookUp(theFolder,theName,theFile,theFile,UTL::IsReadOnly(theFile));
143 //=======================================================================
144 //function : ReferenceIdentifier
146 //=======================================================================
148 Standard_Integer PCDM_ReferenceIterator::ReferenceIdentifier() const {
149 return myReferences(myIterator).ReferenceIdentifier();
151 //=======================================================================
152 //function : DocumentVersion
154 //=======================================================================
156 Standard_Integer PCDM_ReferenceIterator::DocumentVersion() const {
157 return myReferences(myIterator).DocumentVersion();