Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-01 08:59:54

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 <Standard_Transient.hxx>
0023 #include <NCollection_IndexedMap.hxx>
0024 #include <TDF_Label.hxx>
0025 #include <NCollection_List.hxx>
0026 #include <NCollection_Map.hxx>
0027 #include <NCollection_DynamicArray.hxx>
0028 #include <BinLDrivers_DocumentSection.hxx>
0029 #include <PCDM_StorageDriver.hxx>
0030 #include <Standard_OStream.hxx>
0031 #include <Standard_Type.hxx>
0032 #include <TDocStd_FormatVersion.hxx>
0033 class BinMDF_ADriverTable;
0034 class Message_Messenger;
0035 class CDM_Document;
0036 class TDF_Label;
0037 class TCollection_AsciiString;
0038 class BinLDrivers_DocumentSection;
0039 class BinObjMgt_Position;
0040 
0041 //! persistent implementation of storage a document in a binary file
0042 class BinLDrivers_DocumentStorageDriver : public PCDM_StorageDriver
0043 {
0044 
0045 public:
0046   //! Constructor
0047   Standard_EXPORT BinLDrivers_DocumentStorageDriver();
0048 
0049   //! Write <theDocument> to the binary file <theFileName>
0050   Standard_EXPORT void Write(
0051     const occ::handle<CDM_Document>&  theDocument,
0052     const TCollection_ExtendedString& theFileName,
0053     const Message_ProgressRange&      theRange = Message_ProgressRange()) override;
0054 
0055   //! Write <theDocument> to theOStream
0056   Standard_EXPORT void Write(
0057     const occ::handle<CDM_Document>& theDocument,
0058     Standard_OStream&                theOStream,
0059     const Message_ProgressRange&     theRange = Message_ProgressRange()) override;
0060 
0061   Standard_EXPORT virtual occ::handle<BinMDF_ADriverTable> AttributeDrivers(
0062     const occ::handle<Message_Messenger>& theMsgDriver);
0063 
0064   //! Create a section that should be written after the OCAF data
0065   Standard_EXPORT void AddSection(const TCollection_AsciiString& theName,
0066                                   const bool                     isPostRead = true);
0067 
0068   //! Return true if document should be stored in quick mode for partial reading
0069   Standard_EXPORT bool IsQuickPart(const int theVersion) const;
0070 
0071   DEFINE_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
0072 
0073 protected:
0074   //! Write the tree under <theLabel> to the stream <theOS>
0075   Standard_EXPORT void WriteSubTree(
0076     const TDF_Label&             theData,
0077     Standard_OStream&            theOS,
0078     const bool&                  theQuickPart,
0079     const Message_ProgressRange& theRange = Message_ProgressRange());
0080 
0081   //! define the procedure of writing a section to file.
0082   Standard_EXPORT virtual void WriteSection(const TCollection_AsciiString& /*theName*/,
0083                                             const occ::handle<CDM_Document>& /*theDoc*/,
0084                                             Standard_OStream& /*theOS*/);
0085 
0086   //! defines the procedure of writing a shape section to file
0087   Standard_EXPORT virtual void WriteShapeSection(
0088     BinLDrivers_DocumentSection& theDocSection,
0089     Standard_OStream&            theOS,
0090     const TDocStd_FormatVersion  theDocVer,
0091     const Message_ProgressRange& theRange = Message_ProgressRange());
0092 
0093   //! Enables writing in the quick part access mode.
0094   Standard_EXPORT virtual void EnableQuickPartWriting(
0095     const occ::handle<Message_Messenger>& /*theMessageDriver*/,
0096     const bool /*theValue*/)
0097   {
0098   }
0099 
0100   //! clears the writing-cash data in drivers if any.
0101   Standard_EXPORT virtual void Clear();
0102 
0103   occ::handle<BinMDF_ADriverTable>                        myDrivers;
0104   NCollection_IndexedMap<occ::handle<Standard_Transient>> myRelocTable;
0105   occ::handle<Message_Messenger>                          myMsgDriver;
0106 
0107 private:
0108   Standard_EXPORT void FirstPass(const TDF_Label& theRoot);
0109 
0110   //! Returns true if <L> and its sub-labels do not contain
0111   //! attributes to store
0112   Standard_EXPORT bool FirstPassSubTree(const TDF_Label&             L,
0113                                         NCollection_List<TDF_Label>& ListOfEmptyL);
0114 
0115   //! Write info section using FSD_BinaryFile driver
0116   Standard_EXPORT void WriteInfoSection(const occ::handle<CDM_Document>& theDocument,
0117                                         Standard_OStream&                theOStream);
0118 
0119   Standard_EXPORT void UnsupportedAttrMsg(const occ::handle<Standard_Type>& theType);
0120 
0121   //! Writes sizes along the file where it is needed for quick part mode
0122   Standard_EXPORT void WriteSizes(Standard_OStream& theOS);
0123 
0124   BinObjMgt_Persistent                                    myPAtt;
0125   NCollection_List<TDF_Label>                             myEmptyLabels;
0126   NCollection_Map<occ::handle<Standard_Transient>>        myMapUnsupported;
0127   NCollection_IndexedMap<occ::handle<Standard_Transient>> myTypesMap;
0128   NCollection_DynamicArray<BinLDrivers_DocumentSection>   mySections;
0129   TCollection_ExtendedString                              myFileName;
0130   //! Sizes of labels and some attributes that will be stored in the second pass
0131   NCollection_List<occ::handle<BinObjMgt_Position>> mySizesToWrite;
0132 };
0133 
0134 #endif // _BinLDrivers_DocumentStorageDriver_HeaderFile