]> OCCT Git - occt-copy.git/commitdiff
0029014: Managing Binary Format Version Is Not Possible for Own TDF_Attributes
authorBenjamin Bihler <benjamin.bihler@compositence.de>
Fri, 18 Aug 2017 07:40:19 +0000 (10:40 +0300)
committerkgv <kgv@opencascade.com>
Mon, 4 Dec 2017 18:08:43 +0000 (21:08 +0300)
CDM_Application has been extended to provide application name and version.

Application name and version is stored by BinLDrivers_DocumentStorageDriver.

BinLDrivers_DocumentStorageDriver propagates application name and version
by passing it to BinMDataStd.

Made BinObjMgt_RRelocationTable store a handle to the header data of the file
begin read in to make it accessible by binary attribute drivers.

Undone storing application name and version as static fields in BinMDataStd
which is bad style and not thread-safe.

Moved method implementations to .cxx files.

Clearing a BinObjMgt_RRelocationTable now nullifies the reference to the
file header data and BinLDrivers_DocumentRetrievalDriver therefore sets
the reference after the relocation table has been cleared before reading
in the document subtree.

src/BinLDrivers/BinLDrivers_DocumentRetrievalDriver.cxx
src/BinLDrivers/BinLDrivers_DocumentStorageDriver.cxx
src/BinObjMgt/BinObjMgt_RRelocationTable.cxx [new file with mode: 0644]
src/BinObjMgt/BinObjMgt_RRelocationTable.hxx
src/BinObjMgt/FILES
src/CDM/CDM_Application.cxx
src/CDM/CDM_Application.hxx

index 955037d27c4957bd7877c95c54eb9f979ff29ae9..ccc4e1f5abec62066e165a7815f7ed4d1002d36c 100644 (file)
@@ -222,6 +222,7 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
 
   // 2a. Retrieve data from the stream:
   myRelocTable.Clear();
+  myRelocTable.SetHeaderData(aHeaderData);
   mySections.Clear();
   myPAtt.Init();
   Handle(TDF_Data) aData = new TDF_Data();
@@ -531,4 +532,3 @@ Standard_Boolean BinLDrivers_DocumentRetrievalDriver::CheckDocumentVersion(
   }
   return Standard_True;
 }
-
index 04baf70745e2ee79e34817cd9daa18e67f90b100..a8313f614c533ac3bc61a5b124a570db5e2e9f03 100644 (file)
@@ -429,6 +429,11 @@ void BinLDrivers_DocumentStorageDriver::WriteInfoSection
   Standard_Integer aObjNb = 1;
   Standard_Integer aShemaVer = 1;
 
+  // Store the name and version of the application that has created the
+  // document.
+  theData->SetApplicationVersion(theDoc->Application()->Version());
+  theData->SetApplicationName(theDoc->Application()->Name());
+
   aHeader.einfo += FSD_BinaryFile::WriteInfo (theOStream,
                                               aObjNb,
                                               BinLDrivers::StorageVersion(),
diff --git a/src/BinObjMgt/BinObjMgt_RRelocationTable.cxx b/src/BinObjMgt/BinObjMgt_RRelocationTable.cxx
new file mode 100644 (file)
index 0000000..f06f67a
--- /dev/null
@@ -0,0 +1,49 @@
+// Created on: 2017-08-22
+// Created by: Benjamin BIHLER
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <BinObjMgt_RRelocationTable.hxx>
+
+//=======================================================================
+//function : GetHeaderData
+//purpose  : getter for the file header data
+//=======================================================================
+
+const Handle(Storage_HeaderData)& BinObjMgt_RRelocationTable::GetHeaderData() const
+{
+  return myHeaderData;
+}
+
+//=======================================================================
+//function : SetHeaderData
+//purpose  : setter for the file header data
+//=======================================================================
+
+void BinObjMgt_RRelocationTable::SetHeaderData(
+  const Handle(Storage_HeaderData)& theHeaderData)
+{
+  myHeaderData = theHeaderData;
+}
+
+//=======================================================================
+//function : Clear
+//purpose  : The relocation table is cleared before/after reading in a document.
+//         : In this case the reference to the file header data should also be
+//         : cleared, because it is specific to the document.
+//=======================================================================
+void BinObjMgt_RRelocationTable::Clear(const Standard_Boolean doReleaseMemory)
+{
+  myHeaderData.Nullify();
+  TColStd_DataMapOfIntegerTransient::Clear(doReleaseMemory);
+}
index 85199347a7baff51c1365404ec666231e33e8de3..11de88e5513d51b889e9f27f9c7be8888422e3c2 100644 (file)
 #define _BinObjMgt_RRelocationTable_HeaderFile
 
 #include <TColStd_DataMapOfIntegerTransient.hxx>
+#include <Storage_HeaderData.hxx>
 
-typedef TColStd_DataMapOfIntegerTransient BinObjMgt_RRelocationTable;
+//! Retrieval relocation table is modeled as a child class of
+//! TColStd_DataMapOfIntegerTransient that stores a handle to the file
+//! header section. With that attribute drivers have access to the file header
+//! section.
+class BinObjMgt_RRelocationTable : public TColStd_DataMapOfIntegerTransient
+{
+public:
 
+  //! Returns a handle to the header data of the file that is begin read
+  Standard_EXPORT const Handle(Storage_HeaderData)& GetHeaderData() const;
+
+  //! Sets the storage header data.
+  //!
+  //! @param theHeaderData header data of the file that is begin read
+  Standard_EXPORT void SetHeaderData(
+      const Handle(Storage_HeaderData)& theHeaderData);
+
+  Standard_EXPORT void Clear(const Standard_Boolean doReleaseMemory = Standard_True);
+
+
+
+protected:
+
+
+
+private:
+
+  Handle(Storage_HeaderData) myHeaderData;
+};
 
 #endif // _BinObjMgt_RRelocationTable_HeaderFile
index bb324114b2d250e180ca86b1a15d8cc080817dd7..7954116694fdac9a3af385551aa9850369aa6e2d 100755 (executable)
@@ -7,5 +7,6 @@ BinObjMgt_PExtChar.hxx
 BinObjMgt_PInteger.hxx
 BinObjMgt_PReal.hxx
 BinObjMgt_PShortReal.hxx
+BinObjMgt_RRelocationTable.cxx
 BinObjMgt_RRelocationTable.hxx
 BinObjMgt_SRelocationTable.hxx
index 5b3d536fd27e7f90fdd6ffb65988e138463faff7..f61332d97155d5c899625a3655fa0c3d17246093 100644 (file)
@@ -103,3 +103,25 @@ void CDM_Application::EndOfUpdate
   message+=aDocument->Presentation();
   Write(message.ToExtString());
 }
+
+//=======================================================================
+//function : Name
+//purpose  : returns the application name
+//=======================================================================
+
+TCollection_ExtendedString CDM_Application::Name() const
+{
+  // Default: empty
+  return TCollection_ExtendedString();
+}
+
+//=======================================================================
+//function : Version
+//purpose  : returns the application version
+//=======================================================================
+
+TCollection_AsciiString CDM_Application::Version() const
+{
+  // Default: empty
+  return TCollection_AsciiString();
+}
index 028a9feca9f3be0b0e9d33e4c22d09b5170d3781..3720527b6f1149fd9b189d232b7108bc94103007 100644 (file)
 #include <Standard_Boolean.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_ExtString.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+
 class CDM_Reference;
 class CDM_MetaData;
 class CDM_Document;
 class Resource_Manager;
 class CDM_MessageDriver;
-class TCollection_ExtendedString;
 
 
 class CDM_Application;
@@ -60,6 +62,11 @@ public:
   //! writes the string in the application MessagerDriver.
   Standard_EXPORT void Write (const Standard_ExtString aString);
 
+  //! Returns the application name.
+  Standard_EXPORT virtual TCollection_ExtendedString Name() const;
+
+  //! Returns the application version.
+  Standard_EXPORT virtual TCollection_AsciiString Version() const;
 
 friend class CDM_Reference;
 friend class CDM_MetaData;