0027726: List of formats supported by TDocStd_Application
authorskv <skv@opencascade.com>
Fri, 29 Jul 2016 08:57:56 +0000 (11:57 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 25 Aug 2016 08:18:52 +0000 (11:18 +0300)
Minor corrections and implementation of ABV remark

src/CDF/CDF_Application.cxx
src/CDF/CDF_Application.hxx
src/TDocStd/TDocStd_Application.cxx
src/TDocStd/TDocStd_Application.hxx

index 3f61b10..31ad366 100644 (file)
@@ -418,7 +418,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
 {
   // check map of readers
   Handle(PCDM_RetrievalDriver) aReader;
-  if (myReaders.Find (theFormat, aReader))
+  if (myReaders.FindFromKey (theFormat, aReader))
     return aReader;
 
   // support of legacy method of loading reader as plugin
@@ -426,7 +426,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
   aResourceName += ".RetrievalPlugin";
   if (!UTL::Find(Resources(), aResourceName))
   {
-    myReaders.Bind(theFormat, aReader);
+    myReaders.Add(theFormat, aReader);
     Standard_SStream aMsg; 
     aMsg << "Could not found the item:" << aResourceName <<(char)0;
     myRetrievableStatus = PCDM_RS_WrongResource;
@@ -449,7 +449,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
   } 
   catch (Standard_Failure)
   {
-    myReaders.Bind(theFormat, aReader);
+    myReaders.Add(theFormat, aReader);
     myRetrievableStatus = PCDM_RS_WrongResource;
     Standard_Failure::Caught()->Reraise();
   }    
@@ -462,7 +462,7 @@ Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_Extended
   }
 
   // record in map
-  myReaders.Bind (theFormat, aReader);
+  myReaders.Add(theFormat, aReader);
   return aReader;
 }
 
@@ -474,7 +474,7 @@ Handle(PCDM_StorageDriver) CDF_Application::WriterFromFormat(const TCollection_E
 {  
   // check map of writers
   Handle(PCDM_StorageDriver) aDriver;
-  if (myWriters.Find (theFormat, aDriver))
+  if (myWriters.FindFromKey(theFormat, aDriver))
     return aDriver;
 
   // support of legacy method of loading reader as plugin
@@ -482,7 +482,7 @@ Handle(PCDM_StorageDriver) CDF_Application::WriterFromFormat(const TCollection_E
   aResourceName += ".StoragePlugin";  
   if(!UTL::Find(Resources(), aResourceName))
   {
-    myWriters.Bind (theFormat, aDriver);
+    myWriters.Add(theFormat, aDriver);
     Standard_SStream aMsg; 
     aMsg << "Could not found the resource definition:" << aResourceName <<(char)0;
     Standard_NoSuchObject::Raise(aMsg);
@@ -504,7 +504,7 @@ Handle(PCDM_StorageDriver) CDF_Application::WriterFromFormat(const TCollection_E
   } 
   catch (Standard_Failure)
   {
-    myWriters.Bind (theFormat, aDriver);
+    myWriters.Add(theFormat, aDriver);
     myRetrievableStatus = PCDM_RS_WrongResource;
     Standard_Failure::Caught()->Reraise();
   }    
@@ -518,7 +518,7 @@ Handle(PCDM_StorageDriver) CDF_Application::WriterFromFormat(const TCollection_E
   }
 
   // record in map
-  myWriters.Bind(theFormat, aDriver);
+  myWriters.Add(theFormat, aDriver);
   return aDriver;
 }
 
index 926f47e..60ed7e7 100644 (file)
@@ -24,7 +24,7 @@
 #include <TColStd_SequenceOfExtendedString.hxx>
 #include <CDF_TypeOfActivation.hxx>
 #include <Standard_IStream.hxx>
-#include <NCollection_DataMap.hxx>
+#include <NCollection_IndexedDataMap.hxx>
 
 class Standard_NoSuchObject;
 class CDF_Session;
@@ -164,8 +164,8 @@ protected:
   Standard_EXPORT CDF_Application();
 
   PCDM_ReaderStatus myRetrievableStatus;
-  NCollection_DataMap<TCollection_ExtendedString, Handle(PCDM_RetrievalDriver)> myReaders;
-  NCollection_DataMap<TCollection_ExtendedString, Handle(PCDM_StorageDriver)> myWriters;
+  NCollection_IndexedDataMap<TCollection_ExtendedString, Handle(PCDM_RetrievalDriver)> myReaders;
+  NCollection_IndexedDataMap<TCollection_ExtendedString, Handle(PCDM_StorageDriver)> myWriters;
 
 private:
 
index 6dc0854..681abe2 100644 (file)
@@ -129,8 +129,46 @@ void TDocStd_Application::DefineFormat (const TCollection_AsciiString& theFormat
     theWriter->SetFormat(theFormat);
 
   // register drivers
-  myReaders.Bind (theFormat, theReader);
-  myWriters.Bind (theFormat, theWriter);
+  myReaders.Add(theFormat, theReader);
+  myWriters.Add(theFormat, theWriter);
+}
+
+//=======================================================================
+//function : ReadingFormats
+//purpose  :
+//=======================================================================
+
+void TDocStd_Application::ReadingFormats(TColStd_SequenceOfAsciiString &theFormats)
+{
+       theFormats.Clear();
+
+  NCollection_IndexedDataMap<TCollection_ExtendedString, Handle(PCDM_RetrievalDriver)>::Iterator
+    anIter(myReaders);
+  for (; anIter.More(); anIter.Next()) {
+    Handle(PCDM_RetrievalDriver) aDriver = anIter.Value();
+    if (aDriver.IsNull() == Standard_False) {
+      theFormats.Append(anIter.Key());
+    }
+  }
+}
+
+//=======================================================================
+//function : WritingFormats
+//purpose  :
+//=======================================================================
+
+void TDocStd_Application::WritingFormats(TColStd_SequenceOfAsciiString &theFormats)
+{
+  theFormats.Clear();
+
+  NCollection_IndexedDataMap<TCollection_ExtendedString, Handle(PCDM_StorageDriver)>::Iterator
+    anIter(myWriters);
+  for (; anIter.More(); anIter.Next()) {
+    Handle(PCDM_StorageDriver) aDriver = anIter.Value();
+    if (aDriver.IsNull() == Standard_False) {
+      theFormats.Append(anIter.Key());
+    }
+  }
 }
 
 //=======================================================================
index 6cdb9db..eae5f95 100644 (file)
@@ -26,7 +26,7 @@
 #include <Standard_CString.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_IStream.hxx>
-#include <TColStd_SequenceOfExtendedString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
 #include <PCDM_ReaderStatus.hxx>
 #include <PCDM_StoreStatus.hxx>
 
@@ -149,7 +149,17 @@ public:
                                      const TCollection_AsciiString& theExtension,
                                      const Handle(PCDM_RetrievalDriver)& theReader,
                                      const Handle(PCDM_StorageDriver)& theWriter);
-  
+
+  //! Returns the sequence of reading formats supported by the application.
+  //!
+  //! @param theFormats - sequence of reading formats. Output parameter.
+  Standard_EXPORT void ReadingFormats(TColStd_SequenceOfAsciiString &theFormats);
+
+  //! Returns the sequence of writing formats supported by the application.
+  //!
+  //! @param theFormats - sequence of writing formats. Output parameter.
+  Standard_EXPORT void WritingFormats(TColStd_SequenceOfAsciiString &theFormats);
+
   //! returns the number of documents handled by the current applicative session.
   Standard_EXPORT Standard_Integer NbDocuments() const;