0025748: Parallel version of progress indicator
[occt.git] / src / BinLDrivers / BinLDrivers_DocumentStorageDriver.cxx
index 0cf0878..0e5b7db 100644 (file)
@@ -42,7 +42,7 @@
 #include <TDF_Label.hxx>
 #include <TDF_Tool.hxx>
 #include <TDocStd_Document.hxx>
-#include <Message_ProgressSentry.hxx>
+#include <Message_ProgressScope.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(BinLDrivers_DocumentStorageDriver,PCDM_StorageDriver)
 
@@ -65,7 +65,7 @@ BinLDrivers_DocumentStorageDriver::BinLDrivers_DocumentStorageDriver ()
 void BinLDrivers_DocumentStorageDriver::Write
                           (const Handle(CDM_Document)&       theDocument,
                            const TCollection_ExtendedString& theFileName,
-                           const Handle(Message_ProgressIndicator)& theProgress)
+                           const Message_ProgressRange&      theRange)
 {
   SetIsError(Standard_False);
   SetStoreStatus(PCDM_SS_OK);
@@ -77,7 +77,7 @@ void BinLDrivers_DocumentStorageDriver::Write
 
   if (aFileStream.is_open() && aFileStream.good())
   {
-    Write(theDocument, aFileStream, theProgress);
+    Write(theDocument, aFileStream, theRange);
   }
   else
   {
@@ -91,9 +91,9 @@ void BinLDrivers_DocumentStorageDriver::Write
 //purpose  :
 //=======================================================================
 
-void BinLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)& theDoc, 
-                                               Standard_OStream& theOStream,
-                                               const Handle(Message_ProgressIndicator)& theProgress)
+void BinLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)&  theDoc, 
+                                               Standard_OStream&            theOStream,
+                                               const Message_ProgressRange& theRange)
 {
   myMsgDriver = theDoc->Application()->MessageDriver();
   myMapUnsupported.Clear();
@@ -140,26 +140,26 @@ void BinLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)& theDo
     myRelocTable.Clear();
     myPAtt.Init();
 
-    Message_ProgressSentry aPS(theProgress, "Writing document", 0, 3, 1);
+    Message_ProgressScope aPS(theRange, "Writing document", 3);
 
 //  Write Doc structure
-    WriteSubTree (aData->Root(), theOStream, theProgress); // Doc is written
+    WriteSubTree (aData->Root(), theOStream, aPS.Next()); // Doc is written
     if (!aPS.More())
     {
       SetIsError(Standard_True);
       SetStoreStatus(PCDM_SS_UserBreak);
       return;
     }
-    aPS.Next();
+
 //  4. Write Shapes section
-    WriteShapeSection (aShapesSection, theOStream, theProgress);
+    WriteShapeSection (aShapesSection, theOStream, aPS.Next());
     if (!aPS.More())
     {
        SetIsError(Standard_True);
        SetStoreStatus(PCDM_SS_UserBreak);
        return;
     }
-    aPS.Next();
+
     // Write application-defined sections
     for (anIterS.Init (mySections); anIterS.More(); anIterS.Next()) {
       BinLDrivers_DocumentSection& aSection = anIterS.ChangeValue();
@@ -228,16 +228,16 @@ void BinLDrivers_DocumentStorageDriver::UnsupportedAttrMsg
 //=======================================================================
 
 void BinLDrivers_DocumentStorageDriver::WriteSubTree
-                        (const TDF_Label&          theLabel,
-                         Standard_OStream&         theOS,
-                         const Handle(Message_ProgressIndicator)& theProgress)
+                        (const TDF_Label&             theLabel,
+                         Standard_OStream&            theOS,
+                         const Message_ProgressRange& theRange)
 {
   // Skip empty labels
   if (!myEmptyLabels.IsEmpty() && myEmptyLabels.First() == theLabel) {
     myEmptyLabels.RemoveFirst();
     return;
   }
-  Message_ProgressSentry aPS(theProgress, "Writing sub tree", 0, 2, 1, 1);
+  Message_ProgressScope aPS(theRange, "Writing sub tree", 2, true);
   // Write label header: tag
   Standard_Integer aTag = theLabel.Tag();
 #if DO_INVERSE
@@ -298,8 +298,7 @@ void BinLDrivers_DocumentStorageDriver::WriteSubTree
       SetStoreStatus(PCDM_SS_UserBreak);
       return;
     }
-    aPS.Next();
-    WriteSubTree (aChildLab, theOS, theProgress);
+    WriteSubTree (aChildLab, theOS, aPS.Next());
   }
 
   // Write the end label marker
@@ -547,7 +546,7 @@ void BinLDrivers_DocumentStorageDriver::WriteSection
 void BinLDrivers_DocumentStorageDriver::WriteShapeSection
                                 (BinLDrivers_DocumentSection&   theSection,
                                  Standard_OStream&              theOS,
-                                 const Handle(Message_ProgressIndicator)& /*theProgress*/)
+                                 const Message_ProgressRange& /*theRange*/)
 {
   const Standard_Size aShapesSectionOffset = (Standard_Size) theOS.tellp();
   theSection.Write (theOS, aShapesSectionOffset);