Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:59

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 
0040 class BinLDrivers_DocumentStorageDriver;
0041 DEFINE_STANDARD_HANDLE(BinLDrivers_DocumentStorageDriver, PCDM_StorageDriver)
0042 
0043 //! persistent implementation of storage a document in a binary file
0044 class BinLDrivers_DocumentStorageDriver : public PCDM_StorageDriver
0045 {
0046 
0047 public:
0048 
0049   
0050   //! Constructor
0051   Standard_EXPORT BinLDrivers_DocumentStorageDriver();
0052     
0053   //! Write <theDocument> to the binary file <theFileName>
0054   Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument, 
0055                                       const TCollection_ExtendedString& theFileName, 
0056                                       const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0057 
0058   //! Write <theDocument> to theOStream
0059   Standard_EXPORT virtual void Write (const Handle(CDM_Document)& theDocument, 
0060                                       Standard_OStream& theOStream, 
0061                                       const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0062   
0063   Standard_EXPORT virtual Handle(BinMDF_ADriverTable) AttributeDrivers (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, const Standard_Boolean isPostRead = Standard_True);
0067 
0068   //! Return true if document should be stored in quick mode for partial reading
0069   Standard_EXPORT Standard_Boolean IsQuickPart (const Standard_Integer theVersion) const;
0070 
0071 
0072   DEFINE_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver,PCDM_StorageDriver)
0073 
0074 protected:
0075 
0076   
0077   //! Write the tree under <theLabel> to the stream <theOS>
0078   Standard_EXPORT void WriteSubTree (const TDF_Label& theData,
0079                                      Standard_OStream& theOS,
0080                                      const Standard_Boolean& theQuickPart,
0081                                      const Message_ProgressRange& theRange = Message_ProgressRange());
0082   
0083   //! define the procedure of writing a section to file.
0084   Standard_EXPORT virtual void WriteSection (const TCollection_AsciiString& /*theName*/,
0085                                              const Handle(CDM_Document)&    /*theDoc*/, 
0086                                              Standard_OStream&              /*theOS*/);
0087   
0088   //! defines the procedure of writing a shape  section to file
0089   Standard_EXPORT virtual void WriteShapeSection (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*/, const Standard_Boolean /*theValue*/) {}
0097 
0098   //! clears the writing-cash data in drivers if any.
0099   Standard_EXPORT virtual void Clear();
0100 
0101   Handle(BinMDF_ADriverTable) myDrivers;
0102   BinObjMgt_SRelocationTable myRelocTable;
0103   Handle(Message_Messenger) myMsgDriver;
0104 
0105 private:
0106 
0107   Standard_EXPORT void FirstPass (const TDF_Label& theRoot);
0108   
0109   //! Returns true if <L> and its sub-labels do not contain
0110   //! attributes to store
0111   Standard_EXPORT Standard_Boolean FirstPassSubTree (const TDF_Label& L, TDF_LabelList& ListOfEmptyL);
0112   
0113   //! Write info section using FSD_BinaryFile driver
0114   Standard_EXPORT void WriteInfoSection (const Handle(CDM_Document)& theDocument, Standard_OStream& theOStream);
0115   
0116   Standard_EXPORT void UnsupportedAttrMsg (const Handle(Standard_Type)& theType);
0117 
0118   //! Writes sizes along the file where it is needed for quick part mode
0119   Standard_EXPORT void WriteSizes (Standard_OStream& theOS);
0120 
0121   BinObjMgt_Persistent myPAtt;
0122   TDF_LabelList myEmptyLabels;
0123   TColStd_MapOfTransient myMapUnsupported;
0124   TColStd_IndexedMapOfTransient myTypesMap;
0125   BinLDrivers_VectorOfDocumentSection mySections;
0126   TCollection_ExtendedString myFileName;
0127   //! Sizes of labels and some attributes that will be stored in the second pass
0128   NCollection_List<Handle(BinObjMgt_Position)> mySizesToWrite;
0129 };
0130 
0131 #endif // _BinLDrivers_DocumentStorageDriver_HeaderFile