Salome HOME
Issue 0013373: EDF PAL 273 : Option Single/Multi file dump
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Driver_i.cxx
index 4d851194c51f40817cb654bfa3d11a759b6c2a8c..b5d0b241f47e31060c1928d5f1a51b8eb4729623 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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,7 @@
 //  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 "SALOMEDS_Driver_i.hxx"
 #include "SALOMEDS_TMPFile_i.hxx"
 #include "utilities.h"
 #include "SALOMEDS.hxx"
 #include <stdlib.h>
 
-using namespace std;  
-
 SALOMEDS_Driver_i::~SALOMEDS_Driver_i()
 {
 }
 
 SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::Save(const SALOMEDSImpl_SComponent& theComponent,
-                                     const string& theURL,
-                                     long& theStreamLength,
-                                     bool isMultiFile)
+                                      const std::string& theURL,
+                                      long& theStreamLength,
+                                      bool isMultiFile)
 {  
   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
   CORBA::String_var url = CORBA::string_dup(theURL.c_str());
@@ -52,9 +50,9 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::Save(const SALOMEDSImpl_SComponent& the
 }
 
 SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::SaveASCII(const SALOMEDSImpl_SComponent& theComponent,
-                                                  const string& theURL,
-                                                  long& theStreamLength,
-                                                  bool isMultiFile)
+                                                   const std::string& theURL,
+                                                   long& theStreamLength,
+                                                   bool isMultiFile)
 {
   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
   CORBA::String_var url = CORBA::string_dup(theURL.c_str());
@@ -69,10 +67,10 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::SaveASCII(const SALOMEDSImpl_SComponent
 }
   
 bool SALOMEDS_Driver_i::Load(const SALOMEDSImpl_SComponent& theComponent,
-                            const unsigned char* theStream,
-                            const long theStreamLength,
-                            const string& theURL,
-                            bool isMultiFile)
+                             const unsigned char* theStream,
+                             const long theStreamLength,
+                             const std::string& theURL,
+                             bool isMultiFile)
 {
   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
   CORBA::String_var url = CORBA::string_dup(theURL.c_str());
@@ -92,10 +90,10 @@ bool SALOMEDS_Driver_i::Load(const SALOMEDSImpl_SComponent& theComponent,
 }
 
 bool SALOMEDS_Driver_i::LoadASCII(const SALOMEDSImpl_SComponent& theComponent,
-                                 const unsigned char* theStream,
-                                 const long theStreamLength,
-                                 const string& theURL,
-                                 bool isMultiFile)
+                                  const unsigned char* theStream,
+                                  const long theStreamLength,
+                                  const std::string& theURL,
+                                  bool isMultiFile)
 {
   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb);
   CORBA::String_var url = CORBA::string_dup(theURL.c_str());
@@ -125,10 +123,10 @@ void SALOMEDS_Driver_i::Close(const SALOMEDSImpl_SComponent& theComponent)
 
 
 
-string SALOMEDS_Driver_i::IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject,
-                                                const string& IORString,
-                                                bool isMultiFile,
-                                                bool isASCII)
+std::string SALOMEDS_Driver_i::IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject,
+                                                 const std::string& IORString,
+                                                 bool isMultiFile,
+                                                 bool isASCII)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theSObject, _orb);
   CORBA::String_var ior = CORBA::string_dup(IORString.c_str());
@@ -137,21 +135,21 @@ string SALOMEDS_Driver_i::IORToLocalPersistentID(const SALOMEDSImpl_SObject& the
   CORBA::String_var pers_string =_driver->IORToLocalPersistentID(so.in(), ior.in(), isMultiFile, isASCII);
   SALOMEDS::lock();
 
-  return string(pers_string);
+  return std::string(pers_string);
 }
 
 
-string SALOMEDS_Driver_i::LocalPersistentIDToIOR(const SALOMEDSImpl_SObject& theObject,
-                                                const string& aLocalPersistentID,
-                                                bool isMultiFile,
-                                                bool isASCII)
+std::string SALOMEDS_Driver_i::LocalPersistentIDToIOR(const SALOMEDSImpl_SObject& theObject,
+                                                 const std::string& aLocalPersistentID,
+                                                 bool isMultiFile,
+                                                 bool isASCII)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
   CORBA::String_var pers_string = CORBA::string_dup(aLocalPersistentID.c_str());
   SALOMEDS::unlock();
   CORBA::String_var IOR = _driver->LocalPersistentIDToIOR(so.in(), pers_string.in(), isMultiFile, isASCII);
   SALOMEDS::lock();
-  return string(IOR);
+  return std::string(IOR);
 }
 
 bool SALOMEDS_Driver_i::CanCopy(const SALOMEDSImpl_SObject& theObject)
@@ -160,7 +158,7 @@ bool SALOMEDS_Driver_i::CanCopy(const SALOMEDSImpl_SObject& theObject)
 
   SALOMEDS::unlock();
   bool isOk = _driver->CanCopy(so.in());
-  so->Destroy();
+  so->UnRegister();
   SALOMEDS::lock();
 
   return isOk;
@@ -168,8 +166,8 @@ bool SALOMEDS_Driver_i::CanCopy(const SALOMEDSImpl_SObject& theObject)
 
 
 SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::CopyFrom(const SALOMEDSImpl_SObject& theObject, 
-                                                 int& theObjectID,
-                                                 long& theStreamLength)
+                                                  int& theObjectID,
+                                                  long& theStreamLength)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
 
@@ -184,7 +182,7 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::CopyFrom(const SALOMEDSImpl_SObject& th
   return aTMPFile;
 }
 
-bool SALOMEDS_Driver_i::CanPaste(const string& theComponentName, int theObjectID)
+bool SALOMEDS_Driver_i::CanPaste(const std::string& theComponentName, int theObjectID)
 {
   SALOMEDS::unlock();
   bool canPaste = _driver->CanPaste(theComponentName.c_str(), theObjectID);
@@ -192,10 +190,10 @@ bool SALOMEDS_Driver_i::CanPaste(const string& theComponentName, int theObjectID
   return canPaste;
 }
 
-string SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream,
-                                   const long theStreamLength,
-                                   int theObjectID,
-                                   const SALOMEDSImpl_SObject& theObject)
+std::string SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream,
+                                    const long theStreamLength,
+                                    int theObjectID,
+                                    const SALOMEDSImpl_SObject& theObject)
 {
   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb);
   CORBA::Octet* anOctetBuf =  (CORBA::Octet*)theStream;
@@ -210,21 +208,22 @@ string SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream,
   SALOMEDS::SObject_var ret_so = _driver->PasteInto(aStream.in(), theObjectID, so.in());
   SALOMEDS::lock();
 
-  return string(ret_so->GetID());
+  return std::string(ret_so->GetID());
 }
 
 SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(SALOMEDSImpl_Study* theStudy, 
-                                                   bool isPublished, 
-                                                   bool& isValidScript,
-                                                   long& theStreamLength)
+                                                    bool isPublished, 
+                                                    bool isMultiFile,
+                                                    bool& isValidScript,
+                                                    long& theStreamLength)
 {
-  SALOMEDS_Study_i *  st_servant = new SALOMEDS_Study_i (theStudy, _orb);
+  SALOMEDS_Study_i *  st_servant = SALOMEDS_Study_i::GetStudyServant(theStudy, _orb);//new SALOMEDS_Study_i (theStudy, _orb);
   SALOMEDS::Study_var st  = SALOMEDS::Study::_narrow(st_servant->_this());
-  Engines::Component_ptr aComponent = Engines::Component::_narrow(_driver);
+  Engines::EngineComponent_ptr aComponent = Engines::EngineComponent::_narrow(_driver);
 
   SALOMEDS::unlock();
   CORBA::Boolean aValidScript, aPublished = isPublished;
-  Engines::TMPFile_var aStream = aComponent->DumpPython(st.in(), aPublished, aValidScript);
+  Engines::TMPFile_var aStream = aComponent->DumpPython(st.in(), aPublished, isMultiFile, aValidScript);
   SALOMEDSImpl_TMPFile* aTMPFile = new Engines_TMPFile_i(aStream._retn());
   theStreamLength = aTMPFile->Size();
   isValidScript = aValidScript;
@@ -237,11 +236,11 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(SALOMEDSImpl_Study* theStudy
 //                                          SALOMEDS_DriverFactory
 //###############################################################################################################
 
-SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const string& theComponentType)
+SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const std::string& theComponentType)
 {
   CORBA::Object_var obj;
 
-  string aFactoryType;
+  std::string aFactoryType;
   if (theComponentType == "SUPERV") aFactoryType = "SuperVisionContainer";
   else aFactoryType = "FactoryServer";
 
@@ -261,7 +260,7 @@ SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const string& the
   return NULL;
 }
 
-SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByIOR(const string& theIOR)
+SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByIOR(const std::string& theIOR)
 {
   CORBA::Object_var obj;
   obj = _orb->string_to_object(theIOR.c_str());