0030480: Visualization - Clear of Select3D_SensitiveGroup does not update internal...
[occt.git] / src / Storage / Storage_HeaderData.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <Standard_ErrorHandler.hxx>
17 #include <Storage_HeaderData.hxx>
18 #include <Storage_BaseDriver.hxx>
19 #include <Storage_StreamTypeMismatchError.hxx>
20 #include <Storage_StreamExtCharParityError.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <TCollection_ExtendedString.hxx>
23
24 IMPLEMENT_STANDARD_RTTIEXT(Storage_HeaderData,Standard_Transient)
25
26 Storage_HeaderData::Storage_HeaderData() : myNBObj(0), myErrorStatus(Storage_VSOk)
27 {
28 }
29
30 Standard_Boolean Storage_HeaderData::Read (Storage_BaseDriver& theDriver)
31 {
32   // Check driver open mode
33   if (theDriver.OpenMode() != Storage_VSRead
34    && theDriver.OpenMode() != Storage_VSReadWrite)
35   {
36     myErrorStatus = Storage_VSModeError;
37     myErrorStatusExt = "OpenMode";
38     return Standard_False;
39   }
40
41   // Read info section
42   myErrorStatus = theDriver.BeginReadInfoSection();
43   if (myErrorStatus != Storage_VSOk)
44   {
45     myErrorStatusExt = "BeginReadInfoSection";
46     return Standard_False;
47   }
48
49   {
50     try
51     {
52       OCC_CATCH_SIGNALS
53       theDriver.ReadInfo (myNBObj,
54                           myStorageVersion,
55                           myDate,
56                           mySchemaName,
57                           mySchemaVersion,
58                           myApplicationName,
59                           myApplicationVersion,
60                           myDataType,
61                           myUserInfo);
62     }
63     catch (Storage_StreamTypeMismatchError)
64     {
65       myErrorStatus = Storage_VSTypeMismatch;
66       myErrorStatusExt = "ReadInfo";
67       return Standard_False;
68     }
69     catch (Storage_StreamExtCharParityError)
70     {
71       myErrorStatus = Storage_VSExtCharParityError;
72       myErrorStatusExt = "ReadInfo";
73       return Standard_False;
74     }
75   }
76
77   myErrorStatus = theDriver.EndReadInfoSection();
78   if (myErrorStatus != Storage_VSOk)
79   {
80     myErrorStatusExt = "EndReadInfoSection";
81     return Standard_False;
82   }
83
84   // Read comment section
85   myErrorStatus = theDriver.BeginReadCommentSection();
86   if (myErrorStatus != Storage_VSOk)
87   {
88     myErrorStatusExt = "BeginReadCommentSection";
89     return Standard_False;
90   }
91
92   {
93     try
94     {
95       OCC_CATCH_SIGNALS
96       theDriver.ReadComment (myComments);
97     }
98     catch (Storage_StreamTypeMismatchError)
99     {
100       myErrorStatus = Storage_VSTypeMismatch;
101       myErrorStatusExt = "ReadComment";
102       return Standard_False;
103     }
104     catch (Storage_StreamExtCharParityError)
105     {
106       myErrorStatus = Storage_VSExtCharParityError;
107       myErrorStatusExt = "ReadComment";
108       return Standard_False;
109     }
110   }
111
112   myErrorStatus = theDriver.EndReadCommentSection();
113   if (myErrorStatus != Storage_VSOk)
114   {
115     myErrorStatusExt = "EndReadCommentSection";
116     return Standard_False;
117   }
118
119   return Standard_True;
120 }
121
122 TCollection_AsciiString Storage_HeaderData::CreationDate() const
123 {
124   return myDate;
125 }
126
127 void Storage_HeaderData::SetSchemaVersion(const TCollection_AsciiString& aVersion) 
128 {
129   mySchemaVersion = aVersion;
130 }
131
132 TCollection_AsciiString Storage_HeaderData::SchemaVersion() const
133 {
134   return mySchemaVersion;
135 }
136
137 void Storage_HeaderData::SetSchemaName(const TCollection_AsciiString& aSchemaName) 
138 {
139   mySchemaName = aSchemaName;
140 }
141
142 TCollection_AsciiString Storage_HeaderData::SchemaName() const
143 {
144   return mySchemaName;
145 }
146
147 void Storage_HeaderData::SetApplicationVersion(const TCollection_AsciiString& aVersion) 
148 {
149   myApplicationVersion = aVersion;
150 }
151
152 TCollection_AsciiString Storage_HeaderData::ApplicationVersion() const
153 {
154   return myApplicationVersion;
155 }
156
157 void Storage_HeaderData::SetApplicationName(const TCollection_ExtendedString& aName) 
158 {
159   myApplicationName = aName;
160 }
161
162 TCollection_ExtendedString Storage_HeaderData::ApplicationName() const
163 {
164   return myApplicationName;
165 }
166
167 void Storage_HeaderData::SetDataType(const TCollection_ExtendedString& aName) 
168 {
169   myDataType = aName;
170 }
171
172 TCollection_ExtendedString Storage_HeaderData::DataType() const
173 {
174   return myDataType;
175 }
176
177 void Storage_HeaderData::AddToUserInfo(const TCollection_AsciiString& theUserInfo) 
178 {
179   myUserInfo.Append(theUserInfo);
180 }
181
182 const TColStd_SequenceOfAsciiString& Storage_HeaderData::UserInfo() const
183 {
184   return myUserInfo;
185 }
186
187 void Storage_HeaderData::AddToComments(const TCollection_ExtendedString& aComments) 
188 {
189   myComments.Append(aComments);
190 }
191
192 const TColStd_SequenceOfExtendedString& Storage_HeaderData::Comments() const
193 {
194   return myComments;
195 }
196
197 Standard_Integer Storage_HeaderData::NumberOfObjects() const
198 {
199   return myNBObj;
200 }
201
202 void Storage_HeaderData::SetNumberOfObjects(const Standard_Integer anObjectNumber) 
203 {
204   myNBObj = anObjectNumber;
205 }
206
207 void Storage_HeaderData::SetStorageVersion(const TCollection_AsciiString& v)
208 {
209   myStorageVersion = v;
210 }
211
212 void Storage_HeaderData::SetCreationDate(const TCollection_AsciiString& d)
213 {
214   myDate = d;
215 }
216
217 TCollection_AsciiString Storage_HeaderData::StorageVersion() const
218 {
219   return myStorageVersion;
220 }
221
222 Storage_Error  Storage_HeaderData::ErrorStatus() const
223 {
224   return myErrorStatus;
225 }
226
227 void Storage_HeaderData::SetErrorStatus(const Storage_Error anError)
228 {
229   myErrorStatus = anError;
230 }
231
232 TCollection_AsciiString Storage_HeaderData::ErrorStatusExtension() const
233 {
234   return myErrorStatusExt;
235 }
236
237 void Storage_HeaderData::SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt)
238 {
239   myErrorStatusExt = anErrorExt;
240 }
241
242 void Storage_HeaderData::ClearErrorStatus()
243 {
244   myErrorStatus = Storage_VSOk;
245   myErrorStatusExt.Clear();
246 }
247