0025748: Parallel version of progress indicator
[occt.git] / src / XmlLDrivers / XmlLDrivers_DocumentRetrievalDriver.cxx
index c3f647c..9d6512d 100644 (file)
@@ -17,7 +17,7 @@
 #include <CDM_Application.hxx>
 #include <CDM_Document.hxx>
 #include <Message_Messenger.hxx>
-#include <Message_ProgressSentry.hxx>
+#include <Message_ProgressScope.hxx>
 #include <CDM_MetaData.hxx>
 #include <LDOM_DocumentType.hxx>
 #include <LDOM_LDOMImplementation.hxx>
@@ -178,7 +178,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read
                                           (const TCollection_ExtendedString& theFileName,
                                            const Handle(CDM_Document)&       theNewDocument,
                                            const Handle(CDM_Application)&    theApplication,
-                                           const Handle(Message_ProgressIndicator)& theProgress)
+                                           const Message_ProgressRange&      theRange)
 {
   myReaderStatus = PCDM_RS_DriverFailure;
   myFileName = theFileName;
@@ -188,7 +188,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read
 
   if (aFileStream.is_open() && aFileStream.good())
   {
-    Read (aFileStream, NULL, theNewDocument, theApplication, theProgress);
+    Read (aFileStream, NULL, theNewDocument, theApplication, theRange);
   }
   else
   {
@@ -210,7 +210,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&              t
                                                 const Handle(Storage_Data)&    /*theStorageData*/,
                                                 const Handle(CDM_Document)&    theNewDocument,
                                                 const Handle(CDM_Application)& theApplication,
-                                                const Handle(Message_ProgressIndicator)& theProgress)
+                                                const Message_ProgressRange&   theRange)
 {
   Handle(Message_Messenger) aMessageDriver = theApplication -> MessageDriver();
   ::take_time (~0, " +++++ Start RETRIEVE procedures ++++++", aMessageDriver);
@@ -232,7 +232,7 @@ void XmlLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&              t
   const XmlObjMgt_Element anElement= aParser.getDocument().getDocumentElement();
   ::take_time (0, " +++++ Fin parsing XML :       ", aMessageDriver);
 
-  ReadFromDomDocument (anElement, theNewDocument, theApplication, theProgress);
+  ReadFromDomDocument (anElement, theNewDocument, theApplication, theRange);
 }
 
 //=======================================================================
@@ -246,7 +246,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
                                 (const XmlObjMgt_Element&       theElement,
                                  const Handle(CDM_Document)&    theNewDocument,
                                  const Handle(CDM_Application)& theApplication,
-                                 const Handle(Message_ProgressIndicator)& theProgress)
+                                const Message_ProgressRange&    theRange)
 {
   const Handle(Message_Messenger) aMsgDriver =
     theApplication -> MessageDriver();
@@ -431,10 +431,10 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
       }
     }
   }
-  Message_ProgressSentry aPS(theProgress, "Reading document", 0, 2, 1);
+  Message_ProgressScope aPS(theRange, "Reading document", 2);
   // 2. Read Shapes section
   if (myDrivers.IsNull()) myDrivers = AttributeDrivers (aMsgDriver);  
-  const Handle(XmlMDF_ADriver) aNSDriver = ReadShapeSection(theElement, aMsgDriver, theProgress);
+  const Handle(XmlMDF_ADriver) aNSDriver = ReadShapeSection(theElement, aMsgDriver, aPS.Next());
   if(!aNSDriver.IsNull())
     ::take_time (0, " +++++ Fin reading Shapes :    ", aMsgDriver);
 
@@ -443,7 +443,6 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
     myReaderStatus = PCDM_RS_UserBreak;
     return;
   }
-  aPS.Next();
 
   // 2.1. Keep document format version in RT
   Handle(Storage_HeaderData) aHeaderData = new Storage_HeaderData();
@@ -459,7 +458,7 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
     TCollection_ExtendedString aMessage ("PasteDocument");
     aMsgDriver ->Send (aMessage.ToExtString(), Message_Trace);
 #endif
-    if (!MakeDocument(theElement, theNewDocument, theProgress))
+    if (!MakeDocument(theElement, theNewDocument, aPS.Next()))
       myReaderStatus = PCDM_RS_MakeFailure;
     else
       myReaderStatus = PCDM_RS_OK;
@@ -474,7 +473,6 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
     myReaderStatus = PCDM_RS_UserBreak;
     return;
   }
-  aPS.Next();
 
   //    Wipe off the shapes written to the <shapes> section
   ShapeSetCleaning(aNSDriver);
@@ -493,14 +491,14 @@ void XmlLDrivers_DocumentRetrievalDriver::ReadFromDomDocument
 Standard_Boolean XmlLDrivers_DocumentRetrievalDriver::MakeDocument
                                     (const XmlObjMgt_Element&    theElement,
                                      const Handle(CDM_Document)& theTDoc,
-                                     const Handle(Message_ProgressIndicator)& theProgress)
+                                     const Message_ProgressRange& theRange)
 {
   Standard_Boolean aResult = Standard_False;
   Handle(TDocStd_Document) TDOC = Handle(TDocStd_Document)::DownCast(theTDoc);
   if (!TDOC.IsNull()) 
   {
     Handle(TDF_Data) aTDF = new TDF_Data();
-    aResult = XmlMDF::FromTo (theElement, aTDF, myRelocTable, myDrivers, theProgress);
+    aResult = XmlMDF::FromTo (theElement, aTDF, myRelocTable, myDrivers, theRange);
     if (aResult) {
       TDOC->SetData (aTDF);
       TDocStd_Owner::SetDocument (aTDF, TDOC);
@@ -559,7 +557,7 @@ static void take_time (const Standard_Integer isReset, const char * aHeader,
 Handle(XmlMDF_ADriver) XmlLDrivers_DocumentRetrievalDriver::ReadShapeSection(
                                const XmlObjMgt_Element&       /*theElement*/,
                                const Handle(Message_Messenger)& /*aMsgDriver*/,
-                               const Handle(Message_ProgressIndicator)& /*theProgress*/)
+                               const Message_ProgressRange&    /*theRange*/)
 {
   Handle(XmlMDF_ADriver) aDriver;
   //empty; to be redefined