Salome HOME
Test case bugs/N4. A fix by PKV.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ImportDriver.cxx
index b81e779cf9f9c8a4d8da8c10a3ee80f097c817fb..748a5a735993b0e7cb6c3204d0a023016353bfc1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -18,7 +18,6 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
 
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
 
-#include "utilities.h"
-
 #include <TopoDS_Shape.hxx>
 
+#include <TCollection_HAsciiString.hxx>
+
+#include "utilities.h"
+
 #include <Standard_Failure.hxx>
 #include <StdFail_NotDone.hxx>
 
@@ -57,6 +58,10 @@ typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
                                   TCollection_AsciiString&,
                                   const TDF_Label&);
 
+typedef Handle(TCollection_HAsciiString) (*pGetValue)(const TCollection_AsciiString&,
+                                                      const TCollection_AsciiString&,
+                                                      TCollection_AsciiString&);
+
 //=======================================================================
 //function : GetID
 //purpose  :
@@ -67,7 +72,6 @@ const Standard_GUID& GEOMImpl_ImportDriver::GetID()
   return aImportDriver;
 }
 
-
 //=======================================================================
 //function : GEOMImpl_ImportDriver
 //purpose  :
@@ -97,6 +101,8 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
 
   // load plugin library
   LibHandle anImportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051
+
+  // Get Import method
   funcPoint fp = 0;
   if ( anImportLib )
     fp = (funcPoint)GetProc( anImportLib, "Import" );
@@ -129,6 +135,53 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
   return 1;
 }
 
+//=======================================================================
+//function : ReadValue
+//purpose  :
+//=======================================================================
+TCollection_AsciiString GEOMImpl_ImportDriver::ReadValue(const TCollection_AsciiString& theFileName,
+                                                         const TCollection_AsciiString& theLibName,
+                                                         const TCollection_AsciiString& theParameterName,
+                                                         TCollection_AsciiString& theError)
+{
+  TCollection_AsciiString aValue;
+
+  if (theFileName.IsEmpty() || theLibName.IsEmpty() || theParameterName.IsEmpty())
+    return aValue;
+
+  // load plugin library
+  LibHandle anImportLib = LoadLib(theLibName.ToCString()); //This is workaround of BUG OCC13051
+  if (!anImportLib) {
+    theError = theLibName + " library was not installed";
+    return aValue;
+  }
+
+  // Get GetValue method
+  pGetValue pGV = (pGetValue)GetProc(anImportLib, "GetValue");
+
+  if (!pGV) {
+    theError = theLibName + " library doesn't support GetValue method";
+    return aValue;
+  }
+
+  Handle(TCollection_HAsciiString) aHValue = pGV(theFileName, theParameterName, theError);
+
+  if (aHValue.IsNull()) {
+    if (theError.IsEmpty())
+      theError = theFileName + " doesn't contain requested parameter";
+    return aValue;
+  }
+
+  aValue = aHValue->String();
+
+  // unload plugin library
+  // commented by enk:
+  // the bug was occured: using ACIS Import/Export plugin
+  //UnLoadLib( anImportLib ); //This is workaround of BUG OCC13051
+
+  return aValue;
+}
+
 
 //=======================================================================
 //function :  GEOMImpl_ImportDriver_Type_