1 // Created on: 1997-10-22
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <CDM_Reference.ixx>
26 CDM_Reference::CDM_Reference(const Handle(CDM_Document)& aFromDocument, const Handle(CDM_Document)& aToDocument, const Standard_Integer aReferenceIdentifier, const Standard_Integer aToDocumentVersion):
27 myToDocument(aToDocument),
28 myFromDocument(aFromDocument.operator->()),
29 myReferenceIdentifier(aReferenceIdentifier),
30 myDocumentVersion(aToDocumentVersion)
33 CDM_Reference::CDM_Reference(const Handle(CDM_Document)& aFromDocument, const Handle(CDM_MetaData)& aToDocument, const Standard_Integer aReferenceIdentifier, const Handle(CDM_Application)& anApplication, const Standard_Integer aToDocumentVersion, const Standard_Boolean UseStorageConfiguration):
34 myFromDocument(aFromDocument.operator->()),
35 myReferenceIdentifier(aReferenceIdentifier),
36 myApplication(anApplication),
37 myMetaData(aToDocument),
38 myDocumentVersion(aToDocumentVersion),
39 myUseStorageConfiguration(UseStorageConfiguration)
42 Handle(CDM_Document) CDM_Reference::FromDocument() {
43 return myFromDocument;
46 Handle(CDM_Document) CDM_Reference::ToDocument() {
47 if(myToDocument.IsNull()) {
48 myToDocument=myApplication->Retrieve(myMetaData,myUseStorageConfiguration);
49 myApplication.Nullify();
53 Standard_Integer CDM_Reference::ReferenceIdentifier() {
54 return myReferenceIdentifier;
58 void CDM_Reference::Update(const Handle(CDM_MetaData)& aMetaData) {
59 if(myToDocument.IsNull()) {
60 if(myMetaData == aMetaData) {
61 myToDocument=myMetaData->Document();
62 myToDocument->AddFromReference(this);
63 myApplication.Nullify();
68 Standard_Boolean CDM_Reference::IsUpToDate() const {
69 Standard_Integer theActualDocumentVersion;
70 if(myToDocument.IsNull())
71 theActualDocumentVersion=myMetaData->DocumentVersion(myApplication);
73 theActualDocumentVersion=myToDocument->Modifications();
75 return myDocumentVersion==theActualDocumentVersion;
77 void CDM_Reference::SetIsUpToDate() {
79 Standard_Integer theActualDocumentVersion;
80 if(myToDocument.IsNull())
81 theActualDocumentVersion=myMetaData->DocumentVersion(myApplication);
83 theActualDocumentVersion=myToDocument->Modifications();
85 if(theActualDocumentVersion != -1) myDocumentVersion=theActualDocumentVersion;
87 void CDM_Reference::UnsetToDocument(const Handle(CDM_MetaData)& aMetaData, const Handle(CDM_Application)& anApplication) {
88 myToDocument.Nullify();
89 myApplication=anApplication;
93 Standard_Integer CDM_Reference::DocumentVersion() const {
94 return myDocumentVersion;
96 Standard_Boolean CDM_Reference::IsOpened() const {
97 if(myToDocument.IsNull()) return Standard_False;
98 return myToDocument->IsOpened();
100 Standard_Boolean CDM_Reference::IsReadOnly() const {
101 if(myToDocument.IsNull()) return myMetaData->IsReadOnly();
102 return myToDocument->IsReadOnly();
104 Handle(CDM_Document) CDM_Reference::Document() const {
107 Handle(CDM_MetaData) CDM_Reference::MetaData() const {
110 Handle(CDM_Application) CDM_Reference::Application() const {
111 return myApplication;
114 Standard_Boolean CDM_Reference::UseStorageConfiguration() const {
115 return myUseStorageConfiguration;
117 Standard_Boolean CDM_Reference::IsInSession() const {
118 return !myToDocument.IsNull();
120 Standard_Boolean CDM_Reference::IsStored() const {
121 return !myMetaData.IsNull();