0024157: Parallelization of assembly part of BO
[occt.git] / src / CDM / CDM_MetaData.cxx
CommitLineData
b311480e 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
5//
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.
10//
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.
13//
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.
20
7fd59977 21
22
23#include <CDM_MetaData.ixx>
24#include <CDM_MetaDataLookUpTable.hxx>
25
26static CDM_MetaDataLookUpTable& getLookUpTable(){
27 static CDM_MetaDataLookUpTable theLookUpTable;
28 return theLookUpTable;
29}
30CDM_MetaData::CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath,const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly):
31myIsRetrieved(Standard_False),
32myFolder(aFolder),
33myName(aName),
34myHasVersion(Standard_False),
35myFileName(aFileName),
36myPath(aPath),
37myDocumentVersion(0),
38myIsReadOnly(ReadOnly)
39{}
40
41CDM_MetaData::CDM_MetaData(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath,const TCollection_ExtendedString& aVersion,const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly):
42myIsRetrieved(Standard_False),
43myFolder(aFolder),
44myName(aName),
45myVersion(aVersion),
46myHasVersion(Standard_True),
47myFileName(aFileName),
48myPath(aPath),
49myDocumentVersion(0),
50myIsReadOnly(ReadOnly)
51{}
52
53Standard_Boolean CDM_MetaData::IsRetrieved() const {
54 return myIsRetrieved;
55}
56
57Handle(CDM_Document) CDM_MetaData::Document() const {
58 return myDocument;
59}
60
61void CDM_MetaData::SetDocument(const Handle(CDM_Document)& aDocument) {
62 myIsRetrieved = Standard_True;
63 myDocument = aDocument.operator->();
64}
65void CDM_MetaData::UnsetDocument() {
66 myIsRetrieved = Standard_False;
67}
68Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath,const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly) {
69 Handle(CDM_MetaData) theMetaData;
70 TCollection_ExtendedString aConventionalPath=aPath;
71 aConventionalPath.ChangeAll('\\','/');
72 if(!getLookUpTable().IsBound(aConventionalPath)) {
73 theMetaData = new CDM_MetaData(aFolder,aName,aPath,aFileName,ReadOnly);
74 getLookUpTable().Bind(aConventionalPath,theMetaData);
75 }
76 else
77 theMetaData = getLookUpTable()(aConventionalPath);
78
79 return theMetaData;
80}
81Handle(CDM_MetaData) CDM_MetaData::LookUp(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aPath, const TCollection_ExtendedString& aVersion, const TCollection_ExtendedString& aFileName,const Standard_Boolean ReadOnly) {
82 Handle(CDM_MetaData) theMetaData;
83 TCollection_ExtendedString aConventionalPath=aPath;
84 aConventionalPath.ChangeAll('\\','/');
85 if(!getLookUpTable().IsBound(aConventionalPath)) {
86 theMetaData = new CDM_MetaData(aFolder,aName,aPath,aVersion,aFileName,ReadOnly);
87 getLookUpTable().Bind(aConventionalPath,theMetaData);
88 }
89 else
90 theMetaData = getLookUpTable()(aConventionalPath);
91
92 return theMetaData;
93}
94
95TCollection_ExtendedString CDM_MetaData::Folder() const {
96 return myFolder;
97}
98TCollection_ExtendedString CDM_MetaData::Name() const {
99 return myName;
100}
101TCollection_ExtendedString CDM_MetaData::Version() const {
102 Standard_NoSuchObject_Raise_if(!myHasVersion,"Document has no version");
103 return myVersion;
104}
105Standard_Boolean CDM_MetaData::HasVersion() const {
106 return myHasVersion;
107}
108
109TCollection_ExtendedString CDM_MetaData::FileName() const {
110 return myFileName;
111}
112TCollection_ExtendedString CDM_MetaData::Path() const {
113 return myPath;
114}
115Standard_OStream& CDM_MetaData::Print(Standard_OStream& anOStream) const {
116 anOStream << "*CDM_MetaData*";
117 anOStream << myFolder << "," << myName;
118 if(HasVersion()) anOStream << "," << myVersion ;
119 anOStream << "; Physical situation: ";
120 anOStream << myFileName;
121 anOStream << endl;
122 return anOStream;
123}
124Standard_OStream& CDM_MetaData::operator << (Standard_OStream& anOStream) {
125 return Print(anOStream);
126}
127const CDM_MetaDataLookUpTable& CDM_MetaData::LookUpTable() {
128 return getLookUpTable();
129}
130Standard_Integer CDM_MetaData::DocumentVersion(const Handle(CDM_Application)& anApplication) {
131 if(myDocumentVersion==0) myDocumentVersion=anApplication->DocumentVersion(this);
132 return myDocumentVersion;
133}
134Standard_Boolean CDM_MetaData::IsReadOnly() const {
135 return myIsReadOnly;
136}
137void CDM_MetaData::SetIsReadOnly() {
138 myIsReadOnly=Standard_True;
139}
140
141void CDM_MetaData::UnsetIsReadOnly() {
142 myIsReadOnly=Standard_False;
143}