1 // Created on: 2002-10-29
2 // Created by: Michael SAZONOV
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BinLDrivers_DocumentStorageDriver_HeaderFile
17 #define _BinLDrivers_DocumentStorageDriver_HeaderFile
19 #include <Standard.hxx>
21 #include <BinObjMgt_Persistent.hxx>
22 #include <BinObjMgt_SRelocationTable.hxx>
23 #include <TDF_LabelList.hxx>
24 #include <TColStd_MapOfTransient.hxx>
25 #include <TColStd_IndexedMapOfTransient.hxx>
26 #include <BinLDrivers_VectorOfDocumentSection.hxx>
27 #include <PCDM_StorageDriver.hxx>
28 #include <Standard_OStream.hxx>
29 #include <Standard_Type.hxx>
30 #include <TDocStd_FormatVersion.hxx>
31 class BinMDF_ADriverTable;
32 class Message_Messenger;
35 class TCollection_AsciiString;
36 class BinLDrivers_DocumentSection;
37 class BinObjMgt_Position;
40 class BinLDrivers_DocumentStorageDriver;
41 DEFINE_STANDARD_HANDLE(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
43 //! persistent implementation of storage a document in a binary file
44 class BinLDrivers_DocumentStorageDriver : public PCDM_StorageDriver
51 Standard_EXPORT BinLDrivers_DocumentStorageDriver();
53 //! Write <theDocument> to the binary file <theFileName>
54 Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument,
55 const TCollection_ExtendedString& theFileName,
56 const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
58 //! Write <theDocument> to theOStream
59 Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument,
60 Standard_OStream& theOStream,
61 const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
63 Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
65 //! Create a section that should be written after the OCAF data
66 Standard_EXPORT void AddSection (const TCollection_AsciiString& theName, const Standard_Boolean isPostRead = Standard_True);
68 //! Return true if document should be stored in quick mode for partial reading
69 Standard_EXPORT Standard_Boolean IsQuickPart (const Standard_Integer theVersion) const;
72 DEFINE_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver,PCDM_StorageDriver)
77 //! Write the tree under <theLabel> to the stream <theOS>
78 Standard_EXPORT void WriteSubTree (const TDF_Label& theData,
79 Standard_OStream& theOS,
80 const Standard_Boolean& theQuickPart,
81 const Message_ProgressRange& theRange = Message_ProgressRange());
83 //! define the procedure of writing a section to file.
84 Standard_EXPORT virtual void WriteSection (const TCollection_AsciiString& /*theName*/,
85 const Handle(CDM_Document)& /*theDoc*/,
86 Standard_OStream& /*theOS*/);
88 //! defines the procedure of writing a shape section to file
89 Standard_EXPORT virtual void WriteShapeSection (BinLDrivers_DocumentSection& theDocSection,
90 Standard_OStream& theOS,
91 const TDocStd_FormatVersion theDocVer,
92 const Message_ProgressRange& theRange = Message_ProgressRange());
94 //! Enables writing in the quick part access mode.
95 Standard_EXPORT virtual void EnableQuickPartWriting (
96 const Handle(Message_Messenger)& /*theMessageDriver*/, const Standard_Boolean /*theValue*/) {}
98 //! clears the writing-cash data in drivers if any.
99 Standard_EXPORT virtual void Clear();
101 Handle(BinMDF_ADriverTable) myDrivers;
102 BinObjMgt_SRelocationTable myRelocTable;
103 Handle(Message_Messenger) myMsgDriver;
107 Standard_EXPORT void FirstPass (const TDF_Label& theRoot);
109 //! Returns true if <L> and its sub-labels do not contain
110 //! attributes to store
111 Standard_EXPORT Standard_Boolean FirstPassSubTree (const TDF_Label& L, TDF_LabelList& ListOfEmptyL);
113 //! Write info section using FSD_BinaryFile driver
114 Standard_EXPORT void WriteInfoSection (const Handle(CDM_Document)& theDocument, Standard_OStream& theOStream);
116 Standard_EXPORT void UnsupportedAttrMsg (const Handle(Standard_Type)& theType);
118 //! Writes sizes along the file where it is needed for quick part mode
119 Standard_EXPORT void WriteSizes (Standard_OStream& theOS);
121 BinObjMgt_Persistent myPAtt;
122 TDF_LabelList myEmptyLabels;
123 TColStd_MapOfTransient myMapUnsupported;
124 TColStd_IndexedMapOfTransient myTypesMap;
125 BinLDrivers_VectorOfDocumentSection mySections;
126 TCollection_ExtendedString myFileName;
127 //! Sizes of labels and some attributes that will be stored in the second pass
128 NCollection_List<Handle(BinObjMgt_Position)> mySizesToWrite;
131 #endif // _BinLDrivers_DocumentStorageDriver_HeaderFile