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 | |
e6f550da |
56 | Standard_EXPORT virtual ~Storage_BaseDriver(); |
42cf5bc1 |
57 | |
58 | Standard_EXPORT virtual Storage_Error Open (const TCollection_AsciiString& aName, const Storage_OpenMode aMode) = 0; |
59 | |
60 | TCollection_AsciiString Name() const; |
61 | |
62 | Storage_OpenMode OpenMode() const; |
4ff92abe |
63 | |
64 | Standard_EXPORT static TCollection_AsciiString ReadMagicNumber (Standard_IStream& theIStream); |
42cf5bc1 |
65 | |
66 | //! returns True if we are at end of the stream |
67 | Standard_EXPORT virtual Standard_Boolean IsEnd() = 0; |
68 | |
69 | //! return position in the file. Return -1 upon error. |
70 | Standard_EXPORT virtual Storage_Position Tell() = 0; |
71 | |
72 | Standard_EXPORT virtual Storage_Error BeginWriteInfoSection() = 0; |
73 | |
74 | 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; |
75 | |
76 | Standard_EXPORT virtual Storage_Error EndWriteInfoSection() = 0; |
77 | |
78 | Standard_EXPORT virtual Storage_Error BeginReadInfoSection() = 0; |
79 | |
80 | 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 |
81 | |
82 | Standard_EXPORT virtual void ReadCompleteInfo (Standard_IStream& theIStream, Handle(Storage_Data)& theData) = 0; |
42cf5bc1 |
83 | |
84 | Standard_EXPORT virtual Storage_Error EndReadInfoSection() = 0; |
85 | |
86 | Standard_EXPORT virtual Storage_Error BeginWriteCommentSection() = 0; |
87 | |
88 | Standard_EXPORT virtual void WriteComment (const TColStd_SequenceOfExtendedString& userComments) = 0; |
89 | |
90 | Standard_EXPORT virtual Storage_Error EndWriteCommentSection() = 0; |
91 | |
92 | Standard_EXPORT virtual Storage_Error BeginReadCommentSection() = 0; |
93 | |
94 | Standard_EXPORT virtual void ReadComment (TColStd_SequenceOfExtendedString& userComments) = 0; |
95 | |
96 | Standard_EXPORT virtual Storage_Error EndReadCommentSection() = 0; |
97 | |
98 | Standard_EXPORT virtual Storage_Error BeginWriteTypeSection() = 0; |
99 | |
100 | Standard_EXPORT virtual void SetTypeSectionSize (const Standard_Integer aSize) = 0; |
101 | |
102 | Standard_EXPORT virtual void WriteTypeInformations (const Standard_Integer typeNum, const TCollection_AsciiString& typeName) = 0; |
103 | |
104 | Standard_EXPORT virtual Storage_Error EndWriteTypeSection() = 0; |
105 | |
106 | Standard_EXPORT virtual Storage_Error BeginReadTypeSection() = 0; |
107 | |
108 | Standard_EXPORT virtual Standard_Integer TypeSectionSize() = 0; |
109 | |
110 | Standard_EXPORT virtual void ReadTypeInformations (Standard_Integer& typeNum, TCollection_AsciiString& typeName) = 0; |
111 | |
112 | Standard_EXPORT virtual Storage_Error EndReadTypeSection() = 0; |
113 | |
114 | Standard_EXPORT virtual Storage_Error BeginWriteRootSection() = 0; |
115 | |
116 | Standard_EXPORT virtual void SetRootSectionSize (const Standard_Integer aSize) = 0; |
117 | |
118 | Standard_EXPORT virtual void WriteRoot (const TCollection_AsciiString& rootName, const Standard_Integer aRef, const TCollection_AsciiString& aType) = 0; |
119 | |
120 | Standard_EXPORT virtual Storage_Error EndWriteRootSection() = 0; |
121 | |
122 | Standard_EXPORT virtual Storage_Error BeginReadRootSection() = 0; |
123 | |
124 | Standard_EXPORT virtual Standard_Integer RootSectionSize() = 0; |
125 | |
126 | Standard_EXPORT virtual void ReadRoot (TCollection_AsciiString& rootName, Standard_Integer& aRef, TCollection_AsciiString& aType) = 0; |
127 | |
128 | Standard_EXPORT virtual Storage_Error EndReadRootSection() = 0; |
129 | |
130 | Standard_EXPORT virtual Storage_Error BeginWriteRefSection() = 0; |
131 | |
132 | Standard_EXPORT virtual void SetRefSectionSize (const Standard_Integer aSize) = 0; |
133 | |
134 | Standard_EXPORT virtual void WriteReferenceType (const Standard_Integer reference, const Standard_Integer typeNum) = 0; |
135 | |
136 | Standard_EXPORT virtual Storage_Error EndWriteRefSection() = 0; |
137 | |
138 | Standard_EXPORT virtual Storage_Error BeginReadRefSection() = 0; |
139 | |
140 | Standard_EXPORT virtual Standard_Integer RefSectionSize() = 0; |
141 | |
142 | Standard_EXPORT virtual void ReadReferenceType (Standard_Integer& reference, Standard_Integer& typeNum) = 0; |
143 | |
144 | Standard_EXPORT virtual Storage_Error EndReadRefSection() = 0; |
145 | |
146 | Standard_EXPORT virtual Storage_Error BeginWriteDataSection() = 0; |
147 | |
148 | Standard_EXPORT virtual void WritePersistentObjectHeader (const Standard_Integer aRef, const Standard_Integer aType) = 0; |
149 | |
150 | Standard_EXPORT virtual void BeginWritePersistentObjectData() = 0; |
151 | |
152 | Standard_EXPORT virtual void BeginWriteObjectData() = 0; |
153 | |
154 | Standard_EXPORT virtual void EndWriteObjectData() = 0; |
155 | |
156 | Standard_EXPORT virtual void EndWritePersistentObjectData() = 0; |
157 | |
158 | Standard_EXPORT virtual Storage_Error EndWriteDataSection() = 0; |
159 | |
160 | Standard_EXPORT virtual Storage_Error BeginReadDataSection() = 0; |
161 | |
162 | Standard_EXPORT virtual void ReadPersistentObjectHeader (Standard_Integer& aRef, Standard_Integer& aType) = 0; |
163 | |
164 | Standard_EXPORT virtual void BeginReadPersistentObjectData() = 0; |
165 | |
166 | Standard_EXPORT virtual void BeginReadObjectData() = 0; |
167 | |
168 | Standard_EXPORT virtual void EndReadObjectData() = 0; |
169 | |
170 | Standard_EXPORT virtual void EndReadPersistentObjectData() = 0; |
171 | |
172 | Standard_EXPORT virtual Storage_Error EndReadDataSection() = 0; |
173 | |
174 | Standard_EXPORT virtual void SkipObject() = 0; |
175 | |
176 | Standard_EXPORT virtual Storage_BaseDriver& PutReference (const Standard_Integer aValue) = 0; |
177 | |
178 | Standard_EXPORT virtual Storage_BaseDriver& PutCharacter (const Standard_Character aValue) = 0; |
179 | Storage_BaseDriver& operator << (const Standard_Character aValue) |
180 | { |
181 | return PutCharacter(aValue); |
182 | } |
183 | |
184 | Standard_EXPORT virtual Storage_BaseDriver& PutExtCharacter (const Standard_ExtCharacter aValue) = 0; |
185 | Storage_BaseDriver& operator << (const Standard_ExtCharacter aValue) |
186 | { |
187 | return PutExtCharacter(aValue); |
188 | } |
189 | |
190 | Standard_EXPORT virtual Storage_BaseDriver& PutInteger (const Standard_Integer aValue) = 0; |
191 | Storage_BaseDriver& operator << (const Standard_Integer aValue) |
192 | { |
193 | return PutInteger(aValue); |
194 | } |
195 | |
196 | Standard_EXPORT virtual Storage_BaseDriver& PutBoolean (const Standard_Boolean aValue) = 0; |
197 | Storage_BaseDriver& operator << (const Standard_Boolean aValue) |
198 | { |
199 | return PutBoolean(aValue); |
200 | } |
201 | |
202 | Standard_EXPORT virtual Storage_BaseDriver& PutReal (const Standard_Real aValue) = 0; |
203 | Storage_BaseDriver& operator << (const Standard_Real aValue) |
204 | { |
205 | return PutReal(aValue); |
206 | } |
207 | |
208 | Standard_EXPORT virtual Storage_BaseDriver& PutShortReal (const Standard_ShortReal aValue) = 0; |
209 | Storage_BaseDriver& operator << (const Standard_ShortReal aValue) |
210 | { |
211 | return PutShortReal(aValue); |
212 | } |
213 | |
214 | Standard_EXPORT virtual Storage_BaseDriver& GetReference (Standard_Integer& aValue) = 0; |
215 | |
216 | Standard_EXPORT virtual Storage_BaseDriver& GetCharacter (Standard_Character& aValue) = 0; |
217 | Storage_BaseDriver& operator >> (Standard_Character& aValue) |
218 | { |
219 | return GetCharacter(aValue); |
220 | } |
221 | |
222 | Standard_EXPORT virtual Storage_BaseDriver& GetExtCharacter (Standard_ExtCharacter& aValue) = 0; |
223 | Storage_BaseDriver& operator >> (Standard_ExtCharacter& aValue) |
224 | { |
225 | return GetExtCharacter(aValue); |
226 | } |
227 | |
228 | Standard_EXPORT virtual Storage_BaseDriver& GetInteger (Standard_Integer& aValue) = 0; |
229 | Storage_BaseDriver& operator >> (Standard_Integer& aValue) |
230 | { |
231 | return GetInteger(aValue); |
232 | } |
233 | |
234 | Standard_EXPORT virtual Storage_BaseDriver& GetBoolean (Standard_Boolean& aValue) = 0; |
235 | Storage_BaseDriver& operator >> (Standard_Boolean& aValue) |
236 | { |
237 | return GetBoolean(aValue); |
238 | } |
239 | |
240 | Standard_EXPORT virtual Storage_BaseDriver& GetReal (Standard_Real& aValue) = 0; |
241 | Storage_BaseDriver& operator >> (Standard_Real& aValue) |
242 | { |
243 | return GetReal(aValue); |
244 | } |
245 | |
246 | Standard_EXPORT virtual Storage_BaseDriver& GetShortReal (Standard_ShortReal& aValue) = 0; |
247 | Storage_BaseDriver& operator >> (Standard_ShortReal& aValue) |
248 | { |
249 | return GetShortReal(aValue); |
250 | } |
251 | |
252 | Standard_EXPORT virtual Storage_Error Close() = 0; |
253 | |
254 | |
255 | |
256 | |
257 | protected: |
258 | |
259 | |
260 | Standard_EXPORT Storage_BaseDriver(); |
261 | |
262 | void SetName (const TCollection_AsciiString& aName); |
263 | |
264 | void SetOpenMode (const Storage_OpenMode aMode); |
265 | |
266 | |
267 | |
268 | |
269 | private: |
270 | |
271 | |
272 | |
273 | Storage_OpenMode myOpenMode; |
274 | TCollection_AsciiString myName; |
275 | |
276 | |
277 | }; |
278 | |
279 | |
280 | #include <Storage_BaseDriver.lxx> |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | #endif // _Storage_BaseDriver_HeaderFile |