From: apo Date: Thu, 12 Jul 2007 11:28:24 +0000 (+0000) Subject: Implementation of muti-save mode support for ASCII mode persistent X-Git-Tag: T_MULTIPR_INDUS_Persistence~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6aa57fa8f37b928f7f1b47b998b67ab037a9a58e;p=modules%2Fvisu.git Implementation of muti-save mode support for ASCII mode persistent --- diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 73545389..36438e8f 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -220,6 +220,20 @@ namespace VISU } + //---------------------------------------------------------------------------- + SALOMEDS::ListOfFileNames* + GetListOfFileNames(const Result_i::TFileNames& theFileNames) + { + SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames; + if(!theFileNames.empty()){ + aListOfFileNames->length(theFileNames.size()); + for(int aCounter = theFileNames.size(); aCounter > 0; aCounter--) + aListOfFileNames[aCounter-1] = theFileNames[aCounter-1].c_str(); + } + return aListOfFileNames._retn(); + } + + //---------------------------------------------------------------------------- VISU_Gen_i ::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, @@ -379,29 +393,21 @@ namespace VISU if(Result_i* aResult = dynamic_cast(GetServant(anObj).in())){ aResult->Save(theComponent, theURL, - theIsMultiFile, + theIsMultiFile, + false, aFileNames, aFiles); } } - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<length(aFileNames.size()); - for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--) - aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str(); - } - - SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames; - if(!aFiles.empty()){ - aListOfFiles->length(aFiles.size()); - for(int aCounter = aFiles.size(); aCounter > 0; aCounter--) - aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str(); - } - SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0); + if(aFileNames.empty()) + return aStreamFile._retn(); + + SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames); + SALOMEDS::ListOfFileNames_var aListOfFiles = GetListOfFileNames(aFiles); + if(theIsMultiFile) aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFiles.in(), theIsMultiFile); else @@ -415,39 +421,41 @@ namespace VISU SALOMEDS::TMPFile* VISU_Gen_i ::SaveASCII(SALOMEDS::SComponent_ptr theComponent, - const char* theTmpDir, + const char* theURL, bool theIsMultiFile) { - std::string aTmpDir = theIsMultiFile ? theTmpDir : SALOMEDS_Tool::GetTmpDir(); - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<GetStudy(); SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent); for (; anIter->More(); anIter->Next()) { - SALOMEDS::SObject_var gotBranch = anIter->Value(); - CORBA::Object_var anObj = SObjectToObject(gotBranch); - if(CORBA::is_nil(anObj)) - continue; + SALOMEDS::SObject_var aSObject = anIter->Value(); + CORBA::Object_var anObj = SObjectToObject(aSObject); if(Result_i* aResult = dynamic_cast(GetServant(anObj).in())){ - std::string aFileName; - if(aResult->SaveASCII(theComponent, aTmpDir, theIsMultiFile, aFileName)){ - TCollection_AsciiString aString(const_cast(aFileName.c_str())); - aFileNames.Append(aString); - } + aResult->Save(theComponent, + anURL, + theIsMultiFile, + true, + aFileNames, + aFiles); } } + if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - aFileNames.size() - "< 0){ - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(aFileNames.Length()); - for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) - aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), theIsMultiFile); - if(!theIsMultiFile) - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); - } + if(aFileNames.empty()) + return aStreamFile._retn(); + + SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(anURL, aListOfFileNames.in(), theIsMultiFile); + + if(!theIsMultiFile) + SALOMEDS_Tool::RemoveTemporaryFiles(anURL, aListOfFileNames, true); + return aStreamFile._retn(); } diff --git a/src/VISU_I/VISU_MultiResult_i.cc b/src/VISU_I/VISU_MultiResult_i.cc index 7c094e26..e89e5d81 100644 --- a/src/VISU_I/VISU_MultiResult_i.cc +++ b/src/VISU_I/VISU_MultiResult_i.cc @@ -35,6 +35,7 @@ #include "MULTIPR_API.hxx" #include "SALOMEDS_Tool.hxx" +#include "HDFascii.hxx" #include #include @@ -578,14 +579,14 @@ VISU::MultiResult_i ::Save(SALOMEDS::SComponent_ptr theComponent, const std::string& theURL, bool theIsMultiFile, + bool theIsASCII, TFileNames& theFileNames, TFileNames& theFiles) { - INITMSG(MYDEBUG, "MultiResult_i::Save - this = "<(aPathToCopy.c_str()), true); + theFileNames.push_back(aFileName); theFiles.push_back(aFile); } @@ -675,7 +680,7 @@ VISU::MultiResult_i { std::string aBase, aSuffix; SplitName(GetName(), aBase, aSuffix); - BEGMSG(MYDEBUG, "aBase = '"<(aPathToCopy.c_str()), true); + theFileNames.push_back(aFileName); theFiles.push_back(aFile); return true; @@ -639,48 +642,6 @@ VISU::Result_i } -//--------------------------------------------------------------- -bool -VISU::Result_i -::SaveASCII(SALOMEDS::SComponent_ptr theComponent, - const std::string& theTmpDir, - bool theIsMultiFile, - std::string& theFileName) -{ - switch(GetCreationId()){ - case Result_i::eImportFile: - case Result_i::eCopyAndImportFile: { - std::string aPrefix; - if (theIsMultiFile) { - CORBA::String_var anURL = GetStudyDocument()->URL(); - aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in()); - } - theFileName = aPrefix + "_" + GetName(); - - QString aTmpDir = QDir::convertSeparators(theTmpDir.c_str()); - QString aCommand; - aCommand.sprintf("%s %s%s", - GetFileInfo().filePath().latin1(), - aTmpDir.latin1(), - theFileName.c_str()); - aCommand = QDir::convertSeparators( aCommand ); - aCommand.prepend( COPY_COMMAND ); - - if(system(aCommand.latin1())){ - if(MYDEBUG) MESSAGE("Result_i::SaveASCII - Can't execute the command :"<(aStudyPath.latin1()), true); - return true; - }} - - return false; -} - - //--------------------------------------------------------------- CORBA::Boolean VISU::Result_i diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index d1ceb6f2..b0131f86 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -292,15 +292,9 @@ namespace VISU Save(SALOMEDS::SComponent_ptr theComponent, const std::string& theURL, bool theIsMultiFile, + bool theIsASCII, TFileNames& theFileNames, - TFileNames& theFullFileNames); - - virtual - bool - SaveASCII(SALOMEDS::SComponent_ptr theComponent, - const std::string& theURL, - bool theIsMultiFile, - std::string& theFileName); + TFileNames& theFiles); //--------------------------------------------------------------- virtual