Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-04 08:44:52

0001 // Created on: 2002-10-29
0002 // Created by: Michael SAZONOV
0003 // Copyright (c) 2002-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BinLDrivers_DocumentStorageDriver_HeaderFile
0017 #define _BinLDrivers_DocumentStorageDriver_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 
0021 #include <BinObjMgt_Persistent.hxx>
0022 #include <BinObjMgt_SRelocationTable.hxx>
0023 #include <TDF_LabelList.hxx>
0024 #include <TColStd_MapOfTransient.hxx>
0025 #include <TColStd_IndexedMapOfTransient.hxx>
0026 #include <BinLDrivers_VectorOfDocumentSection.hxx>
0027 #include <PCDM_StorageDriver.hxx>
0028 #include <Standard_OStream.hxx>
0029 #include <Standard_Type.hxx>
0030 #include <TDocStd_FormatVersion.hxx>
0031 class BinMDF_ADriverTable;
0032 class Message_Messenger;
0033 class CDM_Document;
0034 class TDF_Label;
0035 class TCollection_AsciiString;
0036 class BinLDrivers_DocumentSection;
0037 class BinObjMgt_Position;
0038 
0039 class BinLDrivers_DocumentStorageDriver;
0040 DEFINE_STANDARD_HANDLE(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
0041 
0042 //! persistent implementation of storage a document in a binary file
0043 class BinLDrivers_DocumentStorageDriver : public PCDM_StorageDriver
0044 {
0045 
0046 public:
0047   //! Constructor
0048   Standard_EXPORT BinLDrivers_DocumentStorageDriver();
0049 
0050   //! Write <theDocument> to the binary file <theFileName>
0051   Standard_EXPORT virtual void Write(
0052     const Handle(CDM_Document)&       theDocument,
0053     const TCollection_ExtendedString& theFileName,
0054     const Message_ProgressRange&      theRange = Message_ProgressRange()) Standard_OVERRIDE;
0055 
0056   //! Write <theDocument> to theOStream
0057   Standard_EXPORT virtual void Write(
0058     const Handle(CDM_Document)&  theDocument,
0059     Standard_OStream&            theOStream,
0060     const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0061 
0062   Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers(
0063     const Handle(Message_Messenger)& theMsgDriver);
0064 
0065   //! Create a section that should be written after the OCAF data
0066   Standard_EXPORT void AddSection(const TCollection_AsciiString& theName,
0067                                   const Standard_Boolean         isPostRead = Standard_True);
0068 
0069   //! Return true if document should be stored in quick mode for partial reading
0070   Standard_EXPORT Standard_Boolean IsQuickPart(const Standard_Integer theVersion) const;
0071 
0072   DEFINE_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
0073 
0074 protected:
0075   //! Write the tree under <theLabel> to the stream <theOS>
0076   Standard_EXPORT void WriteSubTree(
0077     const TDF_Label&             theData,
0078     Standard_OStream&            theOS,
0079     const Standard_Boolean&      theQuickPart,
0080     const Message_ProgressRange& theRange = Message_ProgressRange());
0081 
0082   //! define the procedure of writing a section to file.
0083   Standard_EXPORT virtual void WriteSection(const TCollection_AsciiString& /*theName*/,
0084                                             const Handle(CDM_Document)& /*theDoc*/,
0085                                             Standard_OStream& /*theOS*/);
0086 
0087   //! defines the procedure of writing a shape  section to file
0088   Standard_EXPORT virtual void WriteShapeSection(
0089     BinLDrivers_DocumentSection& theDocSection,
0090     Standard_OStream&            theOS,
0091     const TDocStd_FormatVersion  theDocVer,
0092     const Message_ProgressRange& theRange = Message_ProgressRange());
0093 
0094   //! Enables writing in the quick part access mode.
0095   Standard_EXPORT virtual void EnableQuickPartWriting(
0096     const Handle(Message_Messenger)& /*theMessageDriver*/,
0097     const Standard_Boolean /*theValue*/)
0098   {
0099   }
0100 
0101   //! clears the writing-cash data in drivers if any.
0102   Standard_EXPORT virtual void Clear();
0103 
0104   Handle(BinMDF_ADriverTable) myDrivers;
0105   BinObjMgt_SRelocationTable  myRelocTable;
0106   Handle(Message_Messenger)   myMsgDriver;
0107 
0108 private:
0109   Standard_EXPORT void FirstPass(const TDF_Label& theRoot);
0110 
0111   //! Returns true if <L> and its sub-labels do not contain
0112   //! attributes to store
0113   Standard_EXPORT Standard_Boolean FirstPassSubTree(const TDF_Label& L,
0114                                                     TDF_LabelList&   ListOfEmptyL);
0115 
0116   //! Write info section using FSD_BinaryFile driver
0117   Standard_EXPORT void WriteInfoSection(const Handle(CDM_Document)& theDocument,
0118                                         Standard_OStream&           theOStream);
0119 
0120   Standard_EXPORT void UnsupportedAttrMsg(const Handle(Standard_Type)& theType);
0121 
0122   //! Writes sizes along the file where it is needed for quick part mode
0123   Standard_EXPORT void WriteSizes(Standard_OStream& theOS);
0124 
0125   BinObjMgt_Persistent                myPAtt;
0126   TDF_LabelList                       myEmptyLabels;
0127   TColStd_MapOfTransient              myMapUnsupported;
0128   TColStd_IndexedMapOfTransient       myTypesMap;
0129   BinLDrivers_VectorOfDocumentSection mySections;
0130   TCollection_ExtendedString          myFileName;
0131   //! Sizes of labels and some attributes that will be stored in the second pass
0132   NCollection_List<Handle(BinObjMgt_Position)> mySizesToWrite;
0133 };
0134 
0135 #endif // _BinLDrivers_DocumentStorageDriver_HeaderFile