-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 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
#include <SALOME_NamingService.hxx>
#include <SALOMEDS_Tool.hxx>
-#include <Utils_ORB_INIT.hxx>
-#include <Utils_SINGLETON.hxx>
+#include <ArgvKeeper.hxx>
+#include <OpUtil.hxx>
#include <Utils_SALOME_Exception.hxx>
#include <utilities.h>
Constructor
*/
SalomeApp_Engine_i::SalomeApp_Engine_i( const char* theComponentName )
- : myComponentName( theComponentName )
+ : myKeepFiles( false ), myComponentName( theComponentName )
{
MESSAGE("SalomeApp_Engine_i::SalomeApp_Engine_i(): myComponentName = " <<
qPrintable( myComponentName ) << ", this = " << this);
}
SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
+ const char* /*theURL*/,
bool isMultiFile)
{
SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
bool manuallySaved = false;
- if ( GetListOfFiles().empty() ) {
+ if ( GetListOfFiles(0).empty() ) // 0 means persistence file
+ {
// Save was probably called from outside GUI, so SetListOfFiles was not called!
// Try to get list of files from directly from data model
qPrintable( myComponentName ) <<
"it seems Save() was called from outside GUI" );
- // - Get app rnv
+ // - Get app
SalomeApp_Application* app =
dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
if ( !app )
if ( !name.isEmpty() )
names.push_back(name.toUtf8().data());
}
- SetListOfFiles( names );
+ SetListOfFiles( 0, names ); // 0 means persistence file
manuallySaved = true;
}
// listOfFiles must contain temporary directory name in its first item
// and names of files (relatively the temporary directory) in the others
- const int n = myListOfFiles.size() - 1;
+ ListOfFiles listOfFiles = GetListOfFiles( 0 ); // 0 means persistence file
+ const int n = (int)listOfFiles.size() - 1; //!< TODO: conversion from size_t to int
if (n > 0) { // there are some files, containing persistent data of the component
- std::string aTmpDir = myListOfFiles[0];
+ std::string aTmpDir = listOfFiles[0];
// Create a list to store names of created files
ListOfFiles aSeq;
aSeq.reserve(n);
for (int i = 0; i < n; i++)
- aSeq.push_back(CORBA::string_dup(myListOfFiles[i + 1].c_str()));
+ aSeq.push_back(CORBA::string_dup(listOfFiles[i + 1].c_str()));
// Convert a file to the byte stream
aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq, isMultiFile);
// Remove the files and tmp directory, created by the component storage procedure
- if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true);
+ SalomeApp_Application* app =
+ dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ study->RemoveTemporaryFiles( myComponentName.toStdString().c_str(), isMultiFile );
}
if ( manuallySaved )
- SetListOfFiles( ListOfFiles());
+ SetListOfFiles(0, ListOfFiles()); // 0 means persistence file
return aStreamFile._retn();
}
SALOMEDS_Tool::PutStreamToFiles(theFile, aTmpDir.c_str(), isMultiFile);
// Store list of file names to be used by the component loading procedure
- const int n = aSeq.size() + 1;
+ const int n = (int)aSeq.size() + 1; //!< TODO: conversion from size_t to int
ListOfFiles listOfFiles (n);
listOfFiles[0] = aTmpDir;
for (int i = 1; i < n; i++)
listOfFiles[i] = std::string(aSeq[i - 1]);
- SetListOfFiles(listOfFiles);
+ SetListOfFiles(0, listOfFiles); // 0 means persistence file
+ keepFiles( true );
return true;
}
-SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles()
+SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles(int type)
{
- return myListOfFiles;
+ return myListOfFiles.count(type) ? myListOfFiles[type] : ListOfFiles();
}
-void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles)
+void SalomeApp_Engine_i::SetListOfFiles (int type, const ListOfFiles& theListOfFiles)
{
- myListOfFiles = theListOfFiles;
+ myListOfFiles[type] = theListOfFiles;
}
/*!
* DumpPython implementation for light modules
*/
-Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean& isValidScript)
+Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean /*isPublished*/,
+ CORBA::Boolean /*isMultiFile*/,
+ CORBA::Boolean& isValidScript)
{
MESSAGE("SalomeApp_Engine_i::DumpPython(): myComponentName = "<<
qPrintable( myComponentName ) << ", this = " << this);
aStreamFile[0] = '\0';
isValidScript = true;
+ ListOfFiles listOfFiles = GetListOfFiles( 1 ); // 1 means dump file
+
// listOfFiles must contain temporary directory name in its first item
// and names of files (relatively the temporary directory) in the others
- if ( myListOfFiles.size() < 2 )
+ if ( listOfFiles.size() < 2 )
return aStreamFile._retn();
// there are some files, containing persistent data of the component
- QString aTmpPath( myListOfFiles.front().c_str() );
+ QString aTmpPath( listOfFiles.front().c_str() );
QDir aTmpDir( aTmpPath );
if ( !aTmpDir.exists() )
return aStreamFile._retn();
QStringList aFilePaths;
QList<qint64> aFileSizes;
qint64 aBuffSize = 0;
- ListOfFiles::const_iterator aFIt = myListOfFiles.begin();
- ListOfFiles::const_iterator aFEnd = myListOfFiles.end();
+ ListOfFiles::const_iterator aFIt = listOfFiles.begin();
+ ListOfFiles::const_iterator aFEnd = listOfFiles.end();
aFIt++;
for (; aFIt != aFEnd; aFIt++){
QString aFileName( (*aFIt).c_str() );
if ( CORBA::is_nil( _orb ) ) {
Qtx::CmdLineArgs args;
- ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
- _orb = init( args.argc(), args.argv() );
+ SetArgcArgv( args.argc(), args.argv() );
+ _orb = KERNEL::GetRefToORB();
}
return _orb;
/*!
\return
*/
-SALOME_NamingService* SalomeApp_Engine_i::namingService()
+SALOME_NamingService_Abstract* SalomeApp_Engine_i::namingService()
{
- static SALOME_NamingService _ns(orb());
- return &_ns;
+ return SalomeApp_Application::namingService();
}
/*!