void UndoPostponed(in long theWay);
- boolean DumpStudy(in string thePath, in string theBaseName, in boolean isPublished);
+ boolean DumpStudy(in string thePath,
+ in string theBaseName,
+ in boolean isPublished,
+ in boolean isMultiFile);
/*! \brief Get an AttributeParameter used to store common parameters for given %theSavePoint.
the data model of component
*/
TMPFile DumpPython(in Object theStudy,
- in boolean isPublished,
+ in boolean isPublished,
+ in boolean isMultiFile,
out boolean isValidScript);
Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript)
{
- const char* aScript = "def RebuildData(theStudy): pass";
+ const char* aScript = isMultiFile ? "def RebuildData(theStudy): pass" : "";
char* aBuffer = new char[strlen(aScript)+1];
strcpy(aBuffer, aScript);
CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
#-------------------------------------------------------------------------
- def DumpPython(self, theStudy, isPublished):
- aBuffer = "def RebuildData(theStudy): pass\n\0"
+ def DumpPython(self, theStudy, isPublished, isMultiFile):
+ aBuffer = "\0"
+ if isMultiFile :
+ aBuffer = "def RebuildData(theStudy): pass\n\0"
return (aBuffer, 1)
#-------------------------------------------------------------------------
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
// CORBA operations for Salome_file
Engines::TMPFile* Engines_Parallel_Component_i::DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript)
{
- const char* aScript = "def RebuildData(theStudy): pass";
+ const char* aScript = isMultiFile ? "def RebuildData(theStudy): pass" : "";
char* aBuffer = new char[strlen(aScript)+1];
strcpy(aBuffer, aScript);
CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
// CORBA operations for Salome_file
SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(SALOMEDSImpl_Study* theStudy,
bool isPublished,
+ bool isMultiFile,
bool& isValidScript,
long& theStreamLength)
{
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;
virtual SALOMEDSImpl_TMPFile* DumpPython(SALOMEDSImpl_Study* theStudy,
bool isPublished,
+ bool isMultiFile,
bool& isValidScript,
long& theStreamLength);
};
else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
}
-bool SALOMEDS_Study::DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished)
+bool SALOMEDS_Study::DumpStudy(const std::string& thePath,
+ const std::string& theBaseName,
+ bool isPublished,
+ bool isMultiFile)
{
//SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
- bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished);
+ bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, isMultiFile);
return ret;
}
virtual _PTR(UseCaseBuilder) GetUseCaseBuilder();
virtual void Close();
virtual void EnableUseCaseAutoFilling(bool isEnabled);
- virtual bool DumpStudy(const std::string& thePath,const std::string& theBaseName,bool isPublished);
+ virtual bool DumpStudy(const std::string& thePath,const std::string& theBaseName,bool isPublished,bool isMultiFile);
virtual _PTR(AttributeParameter) GetCommonParameters(const std::string& theID, int theSavePoint);
virtual _PTR(AttributeParameter) GetModuleParameters(const std::string& theID,
const std::string& theModuleName, int theSavePoint);
//============================================================================
CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
const char* theBaseName,
- CORBA::Boolean isPublished)
+ CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile)
{
SALOMEDS::Locker lock;
std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
- CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
+ CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
delete factory;
return ret;
}
virtual char* GetDefaultScript(const char* theModuleName, const char* theShift);
- virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished);
+ virtual CORBA::Boolean DumpStudy(const char* thePath,
+ const char* theBaseName,
+ CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile);
virtual SALOMEDSImpl_Study* GetImpl() { return _impl; }
CPPUNIT_ASSERT(va2.size() == 1); // +AttributeTreeNode
//Check method DumpStudy
- study->DumpStudy(".", "SRN", false);
+ study->DumpStudy(".", "SRN", false, false);
std::fstream f("SRN.py");
char buffer[128];
virtual void EnableUseCaseAutoFilling(bool isEnabled) = 0;
virtual bool DumpStudy(const std::string& thePath,
const std::string& theBaseName,
- bool isPublished) = 0;
+ bool isPublished,
+ bool isMultiFile) = 0;
virtual _PTR(AttributeParameter) GetCommonParameters(const std::string& theID, int theSavePoint) = 0;
virtual _PTR(AttributeParameter) GetModuleParameters(const std::string& theID,
const std::string& theModuleName, int theSavePoint) = 0;
virtual SALOMEDSImpl_TMPFile* DumpPython(SALOMEDSImpl_Study* theStudy,
bool isPublished,
+ bool isMultiFile,
bool& isValidScript,
long& theStreamLength) = 0;
};
return out;
}
+static std::string GetComponentHeader(const char* theComponentName)
+{
+ std::stringstream txt;
+ txt << "###" << std::endl;
+ txt << "### " << theComponentName << " component" << std::endl;
+ txt << "###" << std::endl;
+ return txt.str();
+}
+
//============================================================================
/*! Function : DumpStudy
* Purpose :
bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
const std::string& theBaseName,
bool isPublished,
+ bool isMultiFile,
SALOMEDSImpl_DriverFactory* theFactory)
{
_errorCode = "";
bool isValidScript;
long aStreamLength = 0;
- SALOMEDSImpl_TMPFile* aStream = aDriver->DumpPython(this, isPublished, isValidScript, aStreamLength);
+ SALOMEDSImpl_TMPFile* aStream = aDriver->DumpPython(this, isPublished, isMultiFile, isValidScript, aStreamLength);
if ( !isValidScript )
isOk = false;
- //Create a file that will contain the component specific script
- std::fstream fp2;
+ std::stringstream sfp2;
+
+ //Output the Python script generated by the component in the newly created file.
+ if ( isMultiFile )
+ sfp2 << GetDumpStudyComment( aCompType.c_str() ) << std::endl;
+ else
+ sfp2 << GetComponentHeader( aCompType.c_str() ) << std::endl;
+ sfp2 << aStream->Data();
+
+ if ( isMultiFile ) {
+ //Create a file that will contain the component specific script
+ std::fstream fp2;
#ifdef WIN32
- aFileName=thePath+std::string("\\");
+ aFileName=thePath+std::string("\\");
#else
- aFileName=thePath+std::string("/");
+ aFileName=thePath+std::string("/");
#endif
- std::string aScriptName;
- aScriptName += theBaseName;
- aScriptName += "_";
- aScriptName += aCompType;
-
- aFileName += aScriptName+ std::string(".py");
- aSeqOfFileNames.push_back(aFileName);
-
- fp2.open(aFileName.c_str(), std::ios::out);
-
+ std::string aScriptName;
+ aScriptName += theBaseName;
+ aScriptName += "_";
+ aScriptName += aCompType;
+
+ aFileName += aScriptName+ std::string(".py");
+ aSeqOfFileNames.push_back(aFileName);
+
+ fp2.open(aFileName.c_str(), std::ios::out);
+
#ifdef WIN32
- isOpened = fp2.is_open();
+ isOpened = fp2.is_open();
#else
- isOpened = fp2.rdbuf()->is_open();
+ isOpened = fp2.rdbuf()->is_open();
#endif
-
- if(!isOpened) {
- _errorCode = std::string("Can't create a file ")+aFileName;
- SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false);
- return false;
- }
+
+ if(!isOpened) {
+ _errorCode = std::string("Can't create a file ")+aFileName;
+ SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false);
+ return false;
+ }
- std::stringstream sfp2;
-
- //Output the Python script generated by the component in the newly created file.
- sfp2 << GetDumpStudyComment( aCompType.c_str() ) << std::endl;
- sfp2 << aStream->Data();
-
- // replace '\t' symbols
- fp2 << replace_tabs( sfp2.str() );
+ // replace '\t' symbols
+ fp2 << replace_tabs( sfp2.str() );
- fp2.close();
+ fp2.close();
- if(aStream) delete aStream;
+ //Add to the main script a call to RebuildData of the generated by the component the Python script
+ sfp << "import " << aScriptName << std::endl;
+ sfp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << std::endl;
+ }
+ else
+ sfp << sfp2.str();
- //Add to the main script a call to RebuildData of the generated by the component the Python script
- sfp << "import " << aScriptName << std::endl;
- sfp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << std::endl;
+ if(aStream) delete aStream;
}
sfp << std::endl;
virtual bool HasCurrentContext() { return !_current.IsNull(); }
virtual bool DumpStudy(const std::string& thePath,
- const std::string& theBaseName,
- bool isPublished,
- SALOMEDSImpl_DriverFactory* theFactory);
+ const std::string& theBaseName,
+ bool isPublished,
+ bool isMultiFile,
+ SALOMEDSImpl_DriverFactory* theFactory);
static std::string GetDumpStudyComment(const char* theComponentName = 0);