42cf5bc1 |
1 | // Created on: 1996-11-25 |
2 | // Created by: Christophe LEYNADIER |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Storage_BaseDriver_HeaderFile |
18 | #define _Storage_BaseDriver_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Storage_OpenMode.hxx> |
25 | #include <TCollection_AsciiString.hxx> |
26 | #include <Storage_Error.hxx> |
27 | #include <Standard_Boolean.hxx> |
4ff92abe |
28 | #include <Storage_Data.hxx> |
42cf5bc1 |
29 | #include <Storage_Position.hxx> |
30 | #include <Standard_Integer.hxx> |
31 | #include <TColStd_SequenceOfAsciiString.hxx> |
32 | #include <TColStd_SequenceOfExtendedString.hxx> |
33 | #include <Standard_Character.hxx> |
34 | #include <Standard_ExtCharacter.hxx> |
35 | #include <Standard_Real.hxx> |
36 | #include <Standard_ShortReal.hxx> |
37 | class Storage_StreamTypeMismatchError; |
38 | class Storage_StreamFormatError; |
39 | class Storage_StreamWriteError; |
40 | class Storage_StreamExtCharParityError; |
41 | class TCollection_AsciiString; |
42 | class TCollection_ExtendedString; |
43 | |
44 | |
45 | //! Root class for drivers. A driver assigns a physical container |
46 | //! to data to be stored or retrieved, for instance a file. |
47 | //! The FSD package provides two derived concrete classes : |
48 | //! - FSD_File is a general driver which defines a |
49 | //! file as the container of data. |
50 | class Storage_BaseDriver |
51 | { |
52 | public: |
53 | |
54 | DEFINE_STANDARD_ALLOC |
55 | |
56 | |
57 | Standard_EXPORT void Delete(); |
58 | Standard_EXPORT virtual ~Storage_BaseDriver(){Delete();} |
59 | |
60 | Standard_EXPORT virtual Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode) = 0; |
61 | |
62 | TCollection_AsciiString Name() const; |
63 | |
64 | Storage_OpenMode OpenMode() const; |
4ff92abe |
65 | |
66 | Standard_EXPORT static TCollection_AsciiString ReadMagicNumber (Standard_IStream& theIStream); |
42cf5bc1 |
67 | |
68 | //! returns True if we are at end of the stream |
69 | Standard_EXPORT virtual Standard_Boolean IsEnd() = 0; |
70 | |
71 | //! return position in the file. Return -1 upon error. |
72 | Standard_EXPORT virtual Storage_Position Tell() = 0; |
73 | |
74 | Standard_EXPORT virtual Storage_Error BeginWriteInfoSection() = 0; |
75 | |
76 | Standard_EXPORT virtual void WriteInfo (const Standard_Integer nbObj, const TCollection_AsciiString& dbVersion, const TCollection_AsciiString& date, const TCollection_AsciiString& schemaName, const TCollection_AsciiString& schemaVersion, const TCollection_ExtendedString& appName, const TCollection_AsciiString& appVersion, const TCollection_ExtendedString& objectType, const TColStd_SequenceOfAsciiString& userInfo) = 0; |
77 | |
78 | Standard_EXPORT virtual Storage_Error EndWriteInfoSection() = 0; |
79 | |
80 | Standard_EXPORT virtual Storage_Error BeginReadInfoSection() = 0; |
81 | |
82 | Standard_EXPORT virtual void ReadInfo (Standard_Integer& nbObj, TCollection_AsciiString& dbVersion, TCollection_AsciiString& date, TCollection_AsciiString& schemaName, TCollection_AsciiString& schemaVersion, TCollection_ExtendedString& appName, TCollection_AsciiString& appVersion, TCollection_ExtendedString& objectType, TColStd_SequenceOfAsciiString& userInfo) = 0; |
4ff92abe |
83 | |
84 | Standard_EXPORT virtual void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData) = 0; |
42cf5bc1 |
85 | |
86 | Standard_EXPORT virtual Storage_Error EndReadInfoSection() = 0; |
87 | |
88 | Standard_EXPORT virtual Storage_Error BeginWriteCommentSection() = 0; |
89 | |
90 | Standard_EXPORT virtual void WriteComment (const TColStd_SequenceOfExtendedString& userComments) = 0; |
91 | |
92 | Standard_EXPORT virtual Storage_Error EndWriteCommentSection() = 0; |
93 | |
94 | Standard_EXPORT virtual Storage_Error BeginReadCommentSection() = 0; |
95 | |
96 | Standard_EXPORT virtual void ReadComment (TColStd_SequenceOfExtendedString& userComments) = 0; |
97 | |
98 | Standard_EXPORT virtual Storage_Error EndReadCommentSection() = 0; |
99 | |
100 | Standard_EXPORT virtual Storage_Error BeginWriteTypeSection() = 0; |
101 | |
102 | Standard_EXPORT virtual void SetTypeSectionSize (const Standard_Integer aSize) = 0; |
103 | |
104 | Standard_EXPORT virtual void WriteTypeInformations (const Standard_Integer typeNum, const TCollection_AsciiString& typeName) = 0; |
105 | |
106 | Standard_EXPORT virtual Storage_Error EndWriteTypeSection() = 0; |
107 | |
108 | Standard_EXPORT virtual Storage_Error BeginReadTypeSection() = 0; |
109 | |
110 | Standard_EXPORT virtual Standard_Integer TypeSectionSize() = 0; |
111 | |
112 | Standard_EXPORT virtual void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName) = 0; |
113 | |
114 | Standard_EXPORT virtual Storage_Error EndReadTypeSection() = 0; |
115 | |
116 | Standard_EXPORT virtual Storage_Error BeginWriteRootSection() = 0; |
117 | |
118 | Standard_EXPORT virtual void SetRootSectionSize (const Standard_Integer aSize) = 0; |
119 | |
120 | Standard_EXPORT virtual void WriteRoot (const TCollection_AsciiString& rootName, const Standard_Integer aRef, const TCollection_AsciiString& aType) = 0; |
121 | |
122 | Standard_EXPORT virtual Storage_Error EndWriteRootSection() = 0; |
123 | |
124 | Standard_EXPORT virtual Storage_Error BeginReadRootSection() = 0; |
125 | |
126 | Standard_EXPORT virtual Standard_Integer RootSectionSize() = 0; |
127 | |
128 | Standard_EXPORT virtual void ReadRoot (TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType) = 0; |
129 | |
130 | Standard_EXPORT virtual Storage_Error EndReadRootSection() = 0; |
131 | |
132 | Standard_EXPORT virtual Storage_Error BeginWriteRefSection() = 0; |
133 | |
134 | Standard_EXPORT virtual void SetRefSectionSize (const Standard_Integer aSize) = 0; |
135 | |
136 | Standard_EXPORT virtual void WriteReferenceType (const Standard_Integer reference, const Standard_Integer typeNum) = 0; |
137 | |
138 | Standard_EXPORT virtual Storage_Error EndWriteRefSection() = 0; |
139 | |
140 | Standard_EXPORT virtual Storage_Error BeginReadRefSection() = 0; |
141 | |
142 | Standard_EXPORT virtual Standard_Integer RefSectionSize() = 0; |
143 | |
144 | Standard_EXPORT virtual void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum) = 0; |
145 | |
146 | Standard_EXPORT virtual Storage_Error EndReadRefSection() = 0; |
147 | |
148 | Standard_EXPORT virtual Storage_Error BeginWriteDataSection() = 0; |
149 | |
150 | Standard_EXPORT virtual void WritePersistentObjectHeader (const Standard_Integer aRef, const Standard_Integer aType) = 0; |
151 | |
152 | Standard_EXPORT virtual void BeginWritePersistentObjectData() = 0; |
153 | |
154 | Standard_EXPORT virtual void BeginWriteObjectData() = 0; |
155 | |
156 | Standard_EXPORT virtual void EndWriteObjectData() = 0; |
157 | |
158 | Standard_EXPORT virtual void EndWritePersistentObjectData() = 0; |
159 | |
160 | Standard_EXPORT virtual Storage_Error EndWriteDataSection() = 0; |
161 | |
162 | Standard_EXPORT virtual Storage_Error BeginReadDataSection() = 0; |
163 | |
164 | Standard_EXPORT virtual void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType) = 0; |
165 | |
166 | Standard_EXPORT virtual void BeginReadPersistentObjectData() = 0; |
167 | |
168 | Standard_EXPORT virtual void BeginReadObjectData() = 0; |
169 | |
170 | Standard_EXPORT virtual void EndReadObjectData() = 0; |
171 | |
172 | Standard_EXPORT virtual void EndReadPersistentObjectData() = 0; |
173 | |
174 | Standard_EXPORT virtual Storage_Error EndReadDataSection() = 0; |
175 | |
176 | Standard_EXPORT virtual void SkipObject() = 0; |
177 | |
178 | Standard_EXPORT virtual Storage_BaseDriver& PutReference (const Standard_Integer aValue) = 0; |
179 | |
180 | Standard_EXPORT virtual Storage_BaseDriver& PutCharacter (const Standard_Character aValue) = 0; |
181 | Storage_BaseDriver& operator << (const Standard_Character aValue) |
182 | { |
183 | return PutCharacter(aValue); |
184 | } |
185 | |
186 | Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue) = 0; |
187 | Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue) |
188 | { |
189 | return PutExtCharacter(aValue); |
190 | } |
191 | |
192 | Standard_EXPORT virtual Storage_BaseDriver& PutInteger (const Standard_Integer aValue) = 0; |
193 | Storage_BaseDriver& operator << (const Standard_Integer aValue) |
194 | { |
195 | return PutInteger(aValue); |
196 | } |
197 | |
198 | Standard_EXPORT virtual Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue) = 0; |
199 | Storage_BaseDriver& operator << (const Standard_Boolean aValue) |
200 | { |
201 | return PutBoolean(aValue); |
202 | } |
203 | |
204 | Standard_EXPORT virtual Storage_BaseDriver& PutReal (const Standard_Real aValue) = 0; |
205 | Storage_BaseDriver& operator << (const Standard_Real aValue) |
206 | { |
207 | return PutReal(aValue); |
208 | } |
209 | |
210 | Standard_EXPORT virtual Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue) = 0; |
211 | Storage_BaseDriver& operator << (const Standard_ShortReal aValue) |
212 | { |
213 | return PutShortReal(aValue); |
214 | } |
215 | |
216 | Standard_EXPORT virtual Storage_BaseDriver& GetReference (Standard_Integer& aValue) = 0; |
217 | |
218 | Standard_EXPORT virtual Storage_BaseDriver& GetCharacter (Standard_Character& aValue) = 0; |
219 | Storage_BaseDriver& operator >> (Standard_Character& aValue) |
220 | { |
221 | return GetCharacter(aValue); |
222 | } |
223 | |
224 | Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue) = 0; |
225 | Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue) |
226 | { |
227 | return GetExtCharacter(aValue); |
228 | } |
229 | |
230 | Standard_EXPORT virtual Storage_BaseDriver& GetInteger (Standard_Integer& aValue) = 0; |
231 | Storage_BaseDriver& operator >> (Standard_Integer& aValue) |
232 | { |
233 | return GetInteger(aValue); |
234 | } |
235 | |
236 | Standard_EXPORT virtual Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue) = 0; |
237 | Storage_BaseDriver& operator >> (Standard_Boolean& aValue) |
238 | { |
239 | return GetBoolean(aValue); |
240 | } |
241 | |
242 | Standard_EXPORT virtual Storage_BaseDriver& GetReal (Standard_Real& aValue) = 0; |
243 | Storage_BaseDriver& operator >> (Standard_Real& aValue) |
244 | { |
245 | return GetReal(aValue); |
246 | } |
247 | |
248 | Standard_EXPORT virtual Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue) = 0; |
249 | Storage_BaseDriver& operator >> (Standard_ShortReal& aValue) |
250 | { |
251 | return GetShortReal(aValue); |
252 | } |
253 | |
254 | Standard_EXPORT virtual Storage_Error Close() = 0; |
255 | |
256 | |
257 | |
258 | |
259 | protected: |
260 | |
261 | |
262 | Standard_EXPORT Storage_BaseDriver(); |
263 | |
264 | void SetName (const TCollection_AsciiString& aName); |
265 | |
266 | void SetOpenMode (const Storage_OpenMode aMode); |
267 | |
268 | |
269 | |
270 | |
271 | private: |
272 | |
273 | |
274 | |
275 | Storage_OpenMode myOpenMode; |
276 | TCollection_AsciiString myName; |
277 | |
278 | |
279 | }; |
280 | |
281 | |
282 | #include <Storage_BaseDriver.lxx> |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | #endif // _Storage_BaseDriver_HeaderFile |