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;
42 class BinLDrivers_DocumentStorageDriver;
43 DEFINE_STANDARD_HANDLE(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
45 //! persistent implementation of storage a document in a binary file
46 class BinLDrivers_DocumentStorageDriver : public PCDM_StorageDriver
53 Standard_EXPORT BinLDrivers_DocumentStorageDriver();
55 //! Write <theDocument> to the binary file <theFileName>
56 Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument,
57 const TCollection_ExtendedString& theFileName,
58 const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
60 //! Write <theDocument> to theOStream
61 Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument,
62 Standard_OStream& theOStream,
63 const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
65 Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers (const Handle(Message_Messenger)& theMsgDriver);
67 //! Create a section that should be written after the OCAF data
68 Standard_EXPORT void AddSection (const TCollection_AsciiString& theName, const Standard_Boolean isPostRead = Standard_True);
73 DEFINE_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver,PCDM_StorageDriver)
78 //! Write the tree under <theLabel> to the stream <theOS>
79 Standard_EXPORT void WriteSubTree (const TDF_Label& theData,
80 Standard_OStream& theOS,
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 Handle(BinMDF_ADriverTable) myDrivers;
95 BinObjMgt_SRelocationTable myRelocTable;
96 Handle(Message_Messenger) myMsgDriver;
100 Standard_EXPORT void FirstPass (const TDF_Label& theRoot);
102 //! Returns true if <L> and its sub-labels do not contain
103 //! attributes to store
104 Standard_EXPORT Standard_Boolean FirstPassSubTree (const TDF_Label& L, TDF_LabelList& ListOfEmptyL);
106 //! Write info section using FSD_BinaryFile driver
107 Standard_EXPORT void WriteInfoSection (const Handle(CDM_Document)& theDocument, Standard_OStream& theOStream);
109 Standard_EXPORT void UnsupportedAttrMsg (const Handle(Standard_Type)& theType);
111 BinObjMgt_Persistent myPAtt;
112 TDF_LabelList myEmptyLabels;
113 TColStd_MapOfTransient myMapUnsupported;
114 TColStd_IndexedMapOfTransient myTypesMap;
115 BinLDrivers_VectorOfDocumentSection mySections;
116 TCollection_ExtendedString myFileName;
120 #endif // _BinLDrivers_DocumentStorageDriver_HeaderFile