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>
20 #include <Standard_Type.hxx>
22 #include <BinObjMgt_Persistent.hxx>
23 #include <BinObjMgt_SRelocationTable.hxx>
24 #include <TDF_LabelList.hxx>
25 #include <TColStd_MapOfTransient.hxx>
26 #include <TColStd_IndexedMapOfTransient.hxx>
27 #include <BinLDrivers_VectorOfDocumentSection.hxx>
28 #include <PCDM_StorageDriver.hxx>
29 #include <Standard_OStream.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <Standard_Type.hxx>
32 #include <TDocStd_FormatVersion.hxx>
33 class BinMDF_ADriverTable;
34 class Message_Messenger;
35 class TCollection_ExtendedString;
38 class TCollection_AsciiString;
39 class BinLDrivers_DocumentSection;
40 class BinObjMgt_Position;
43 class BinLDrivers_DocumentStorageDriver;
44 DEFINE_STANDARD_HANDLE(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
46 //! persistent implementation of storage a document in a binary file
47 class BinLDrivers_DocumentStorageDriver : public PCDM_StorageDriver
54 Standard_EXPORT BinLDrivers_DocumentStorageDriver();
56 //! Write <theDocument> to the binary file <theFileName>
57 Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument,
58 const TCollection_ExtendedString& theFileName,
59 const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
61 //! Write <theDocument> to theOStream
62 Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument,
63 Standard_OStream& theOStream,
64 const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
66 Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
68 //! Create a section that should be written after the OCAF data
69 Standard_EXPORT void AddSection (const TCollection_AsciiString& theName, const Standard_Boolean isPostRead = Standard_True);
71 //! Return true if document should be stored in quick mode for partial reading
72 Standard_EXPORT Standard_Boolean IsQuickPart (const Standard_Integer theVersion) const;
75 DEFINE_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver,PCDM_StorageDriver)
80 //! Write the tree under <theLabel> to the stream <theOS>
81 Standard_EXPORT void WriteSubTree (const TDF_Label& theData,
82 Standard_OStream& theOS,
83 const Standard_Boolean& theQuickPart,
84 const Message_ProgressRange& theRange = Message_ProgressRange());
86 //! define the procedure of writing a section to file.
87 Standard_EXPORT virtual void WriteSection (const TCollection_AsciiString& /*theName*/,
88 const Handle(CDM_Document)& /*theDoc*/,
89 Standard_OStream& /*theOS*/);
91 //! defines the procedure of writing a shape section to file
92 Standard_EXPORT virtual void WriteShapeSection (BinLDrivers_DocumentSection& theDocSection,
93 Standard_OStream& theOS,
94 const TDocStd_FormatVersion theDocVer,
95 const Message_ProgressRange& theRange = Message_ProgressRange());
97 //! Enables writing in the quick part access mode.
98 Standard_EXPORT virtual void EnableQuickPartWriting (
99 const Handle(Message_Messenger)& /*theMessageDriver*/, const Standard_Boolean /*theValue*/) {}
101 //! clears the writing-cash data in drivers if any.
102 Standard_EXPORT virtual void Clear();
104 Handle(BinMDF_ADriverTable) myDrivers;
105 BinObjMgt_SRelocationTable myRelocTable;
106 Handle(Message_Messenger) myMsgDriver;
110 Standard_EXPORT void FirstPass (const TDF_Label& theRoot);
112 //! Returns true if <L> and its sub-labels do not contain
113 //! attributes to store
114 Standard_EXPORT Standard_Boolean FirstPassSubTree (const TDF_Label& L, TDF_LabelList& ListOfEmptyL);
116 //! Write info section using FSD_BinaryFile driver
117 Standard_EXPORT void WriteInfoSection (const Handle(CDM_Document)& theDocument, Standard_OStream& theOStream);
119 Standard_EXPORT void UnsupportedAttrMsg (const Handle(Standard_Type)& theType);
121 //! Writes sizes along the file where it is needed for quick part mode
122 Standard_EXPORT void WriteSizes (Standard_OStream& theOS);
124 BinObjMgt_Persistent myPAtt;
125 TDF_LabelList myEmptyLabels;
126 TColStd_MapOfTransient myMapUnsupported;
127 TColStd_IndexedMapOfTransient myTypesMap;
128 BinLDrivers_VectorOfDocumentSection mySections;
129 TCollection_ExtendedString myFileName;
130 //! Sizes of labels and some attributes that will be stored in the second pass
131 NCollection_List<Handle(BinObjMgt_Position)> mySizesToWrite;
134 #endif // _BinLDrivers_DocumentStorageDriver_HeaderFile