{
}
-std::string SALOME_NotebookDriver::GetFileName( SALOMEDS::SComponent_ptr theComponent, bool isMultiFile ) const
+std::string SALOME_NotebookDriver::GetFileName( SALOMEDS::Study_ptr theStudy, bool isMultiFile ) const
{
// Prepare a file name to open
std::string aNameWithExt;
if( isMultiFile )
- aNameWithExt = SALOMEDS_Tool::GetNameFromPath( theComponent->GetStudy()->URL() ).c_str();
+ aNameWithExt = SALOMEDS_Tool::GetNameFromPath( theStudy->URL() ).c_str();
aNameWithExt += "_Notebook.dat";
return aNameWithExt;
}
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
aSeq->length( 1 );
- std::string aNameWithExt = GetFileName( theComponent, isMultiFile );
+ std::string aNameWithExt = GetFileName( theComponent->GetStudy(), isMultiFile );
aSeq[0] = CORBA::string_dup( aNameWithExt.c_str() );
// Build a full file name of temporary file
std::string aFullName = std::string( aTmpDir.c_str() ) + aNameWithExt;
// Save Notebook component into this file
- theComponent->GetStudy()->GetNotebook()->Save( aFullName.c_str() );
-
- // Convert a file to the byte stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream( aTmpDir.c_str(), aSeq.in(), isMultiFile );
+ if( theComponent->GetStudy()->GetNotebook()->Save( aFullName.c_str() ) )
+ // Convert a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream( aTmpDir.c_str(), aSeq.in(), isMultiFile );
// Remove the created file and tmp directory
if( !isMultiFile )
SALOMEDS_Tool::PutStreamToFiles( theStream, aTmpDir.c_str(), isMultiFile );
// Prepare a file name to open
- std::string aNameWithExt = GetFileName( theComponent, isMultiFile );
+ std::string aNameWithExt = GetFileName( theComponent->GetStudy(), isMultiFile );
std::string aFullName = std::string( aTmpDir.c_str() ) + aNameWithExt;
// Open document
SALOMEDS::SObject_var aRes;
return aRes._retn();
}
+
+Engines::TMPFile* SALOME_NotebookDriver::DumpPython( SALOMEDS::Study_ptr theStudy, bool& isValid ) const
+{
+ Engines::TMPFile_var aStreamFile;
+
+ // Get a temporary directory to store a file
+ std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
+
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length( 1 );
+
+ std::string aNameWithExt = GetFileName( theStudy, false );
+ aSeq[0] = CORBA::string_dup( aNameWithExt.c_str() );
+
+ // Build a full file name of temporary file
+ std::string aFullName = std::string( aTmpDir.c_str() ) + aNameWithExt;
+
+ // Dump Notebook component into python file
+ isValid = theStudy->GetNotebook()->DumpPython( aFullName.c_str() );
+ if( isValid )
+ // Convert a file to the byte stream
+ aStreamFile = (Engines::TMPFile*)SALOMEDS_Tool::PutFilesToStream( aTmpDir.c_str(), aSeq.in(), false );
+
+ // Remove the created file and tmp directory
+ SALOMEDS_Tool::RemoveTemporaryFiles( aTmpDir.c_str(), aSeq.in(), true );
+
+ // Return the created byte stream
+ return aStreamFile._retn();
+}
#define SALOME_NOTEBOOK_DRIVER_HEADER
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOME_Component)
#include <string>
class SALOME_NotebookDriver : public POA_SALOMEDS::Driver
SALOME_NotebookDriver();
virtual ~SALOME_NotebookDriver();
- virtual SALOMEDS::TMPFile* Save ( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile );
- virtual SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile );
- virtual CORBA::Boolean Load ( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
- const char* theURL, bool isMultiFile );
- virtual CORBA::Boolean LoadASCII( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
- const char* theURL, bool isMultiFile );
- virtual void Close ( SALOMEDS::SComponent_ptr theComponent );
+ virtual SALOMEDS::TMPFile* Save ( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile );
+ virtual SALOMEDS::TMPFile* SaveASCII ( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile );
+ virtual CORBA::Boolean Load ( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
+ const char* theURL, bool isMultiFile );
+ virtual CORBA::Boolean LoadASCII ( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
+ const char* theURL, bool isMultiFile );
+ Engines::TMPFile* DumpPython( SALOMEDS::Study_ptr theStudy, bool& isValid ) const;
+ virtual void Close ( SALOMEDS::SComponent_ptr theComponent );
virtual char* ComponentDataType();
virtual char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject, const char* theIOR,
virtual CORBA::Boolean CanPaste ( const char* theComponentName, CORBA::Long theObjectID );
virtual SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject );
-
protected:
- std::string GetFileName( SALOMEDS::SComponent_ptr theComponent, bool isMultiFile ) const;
+ std::string GetFileName( SALOMEDS::Study_ptr theStudy, bool isMultiFile ) const;
};
#endif