anAttrName.SetValue("User data")
-#Add a new case 'Case1' to the component 'User data'
-aBuilder.AddDirectory("/User data/Case1")
-
-#Set a study context to '/User data/Case1'
-aStudy.SetContext("/User data/Case1")
-
-#Print the current study context
-print aStudy.GetContext()
-
-#Add a sub directory 'aSubCase' to 'Case1' (under the current context)
-aBuilder.AddDirectory("aSubCase")
-
-
-#Add a new case 'Case2' to component 'User data'
-aBuilder.AddDirectory("/User data/Case2")
-
studyName = salome.myStudy._get_Name()
# open study from file /home/user/MyStudy.hdf
-study = salome.myStudy.OpenStudy("/home/user/MyStudy.hdf")
+salome.myStudy.Open("/home/user/MyStudy.hdf")
# save study
-salome.myStudy.Save(study, False) # not using multifile save mode
+salome.myStudy.Save(False, False) # not using multifile save mode
# save study in ASCII format
-salome.myStudy.SaveASCII(study, True) # using multifile save mode
+salome.myStudy.Save(True, True) # using multifile save mode
# save study with the new file path
-salome.myStudy.SaveAs("/home/user/MyStudy.hdf", study, False)
+salome.myStudy.SaveAs("/home/user/MyStudy.hdf", False, False)
# save study with the new file path in ASCII format
-salome.myStudy.SaveAsASCII("/home/user/MyStudy.hdf", study, False)
+salome.myStudy.SaveAs("/home/user/MyStudy.hdf", False, True)
# clear study
salome.myStudy.Clear()
void RemoveReference(in SObject anObject) ;
-/*!
- Adds a directory in the %Study.
- \param theName String parameter defining the name of the directory.
-
-<em>See \ref example23 for an example of this method usage in batchmode of %SALOME application.</em>
-
-*/
- void AddDirectory(in string theName) raises(LockProtection);
-
/*! \brief Identification of the %SObject's substructure.
Identification of the %SObject's substructure by GUID.
//! Invalid study reference
exception StudyInvalidReference {};
-//! Invalid study context
- exception StudyInvalidContext {};
//! Invalid study component
exception StudyInvalidComponent {};
//! Invalid directory of the %study exception
*/
string GetObjectPath(in Object theObject) raises(StudyInvalidReference);
-/*! \brief Set the context of the %Study.
-
- \param thePath String parameter defining the context of the study.
-
-<em>See \ref example23 for an example of this method usage in batchmode of %SALOME application.</em>
-*/
- void SetContext(in string thePath) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get the context of the %Study.
-
-<em>See \ref example23 for an example of this method usage in batchmode of %SALOME application.</em>
-*/
- string GetContext() raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of objects corresponding to the context.
-
- \note If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
-*/
- ListOfStrings GetObjectNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of directories and subdirectories corresponding to the context.
-
- \note If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
-*/
- ListOfStrings GetDirectoryNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of Files corresponding to the context.
-
- \note If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
-*/
- ListOfStrings GetFileNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of Components corresponding to the context.
-
- \note If the parameter <VAR>theContext</VAR> is empty, then the current context will be used.
-*/
- ListOfStrings GetComponentNames(in string theContext) raises(StudyInvalidReference);
/*! \brief Create a new iterator of child levels of the given %SObject.
\param aSO The given %SObject
*/
boolean Open (in URLPath aStudyUrl) raises (SALOME::SALOME_Exception);
-/*! \brief Saving the study in a HDF file (or files).
+/*! \brief Saving the study in a file (or files).
Saves a study.
\param theMultiFile If this parameter is True the study will be saved in several files.
+ \param theASCII If this parameter is True the study will be saved in ASCII format, otherwise in HDF format.
*/
- boolean Save(in boolean theMultiFile) raises(StudyInvalidReference);
+ boolean Save(in boolean theMultiFile, in boolean theASCII) raises(StudyInvalidReference);
-/*! \brief Saving a study in a ASCII file (or files).
-
- Saves a study in an ASCII format file (or files).
- \param theMultiFile If this parameter is True the study will be saved in several files.
-*/
- boolean SaveASCII(in boolean theMultiFile) raises(StudyInvalidReference);
-/*! \brief Saving the study in a specified HDF file (or files).
+/*! \brief Saving the study in a specified file (or files).
Saves the study in a specified file (or files).
\param aUrl The path to the definite file in whcih the study will be saved
- \param aStudy The study which will be saved
\param theMultiFile If this parameter is True the study will be saved in several files.
+ \param theASCII If this parameter is True the study will be saved in ASCII format, otherwise in HDF format.
<em>See \ref example1 for an example of this method usage in batchmode of %SALOME application.</em>
*/
boolean SaveAs(in URLPath aUrl, // if the file already exists
- in boolean theMultiFile) // overwrite (as option)
+ in boolean theMultiFile, // overwrite (as option)
+ in boolean theASCII)
raises(StudyInvalidReference);
-/*! \brief Saving the study in a specified ASCII file (or files).
-
- Saves the study in a specified ASCII file (or files).
-
- \param aUrl The path to the definite file in whcih the study will be saved
- \param aStudy The study which will be saved
- \param theMultiFile If this parameter is True the study will be saved in several files.
-*/
- boolean SaveAsASCII(in URLPath aUrl, // if the file already exists
- in boolean theMultiFile) // overwrite (as option)
- raises(StudyInvalidReference);
/*!
Returns True, if the given %SObject can be copied to the clipboard.
*/
DumpStudy(myStudy);
// Save as
- myStudy->SaveAs("/home/edeville/Study1.hdf", false);
+ myStudy->SaveAs("/home/edeville/Study1.hdf", false, false);
// Get Persistent Reference of the study test
name = myStudy->GetPersistentReference();
return true;
}
-bool SALOMEDS_Study::Save(bool theMultiFile)
+bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
{
//SRN: Pure CORBA save as the save operation require CORBA in any case
- return _corba_impl->Save(theMultiFile);
+ return _corba_impl->Save(theMultiFile, theASCII);
}
-bool SALOMEDS_Study::SaveASCII(bool theMultiFile)
+bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII)
{
//SRN: Pure CORBA save as the save operation require CORBA in any case
- return _corba_impl->SaveASCII(theMultiFile);
-}
-
-bool SALOMEDS_Study::SaveAs(const std::string& theUrl, bool theMultiFile)
-{
- //SRN: Pure CORBA save as the save operation require CORBA in any case
- return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile);
-}
-
-bool SALOMEDS_Study::SaveAsASCII(const std::string& theUrl, bool theMultiFile)
-{
- //SRN: Pure CORBA save as the save operation require CORBA in any case
- return _corba_impl->SaveAsASCII((char*)theUrl.c_str(), theMultiFile);
+ return _corba_impl->SaveAs((char*)theUrl.c_str(), theMultiFile, theASCII);
}
SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
return aPath;
}
-void SALOMEDS_Study::SetContext(const std::string& thePath)
-{
- if (_isLocal) {
- SALOMEDS::Locker lock;
- _local_impl->SetContext(thePath);
- }
- else _corba_impl->SetContext((char*)thePath.c_str());
-}
-
-std::string SALOMEDS_Study::GetContext()
-{
- std::string aPath;
- if (_isLocal) {
- SALOMEDS::Locker lock;
- aPath = _local_impl->GetContext();
- }
- else aPath = _corba_impl->GetContext();
- return aPath;
-}
-
-std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
-{
- std::vector<std::string> aVector;
- int aLength, i;
- if (_isLocal) {
- SALOMEDS::Locker lock;
- aVector = _local_impl->GetObjectNames(theContext);
- }
- else {
- SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
- aLength = aSeq->length();
- for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
- }
- return aVector;
-}
-
-std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
-{
- std::vector<std::string> aVector;
- int aLength, i;
- if (_isLocal) {
- SALOMEDS::Locker lock;
- aVector = _local_impl->GetDirectoryNames(theContext);
- }
- else {
- SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
- aLength = aSeq->length();
- for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
- }
- return aVector;
-}
-
-std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
-{
- std::vector<std::string> aVector;
- int aLength, i;
- if (_isLocal) {
- SALOMEDS::Locker lock;
- aVector = _local_impl->GetFileNames(theContext);
- }
- else {
- SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
- aLength = aSeq->length();
-
- for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
- }
- return aVector;
-}
-
-std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
-{
- std::vector<std::string> aVector;
- int aLength, i;
- if (_isLocal) {
- SALOMEDS::Locker lock;
- aVector = _local_impl->GetComponentNames(theContext);
- }
- else {
- SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
- aLength = aSeq->length();
- for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
- }
- return aVector;
-}
-
_PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
{
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
virtual bool Open(const std::string& theStudyUrl);
- virtual bool Save(bool theMultiFile);
- virtual bool SaveASCII(bool theMultiFile);
- virtual bool SaveAs(const std::string& theUrl, bool theMultiFile);
- virtual bool SaveAsASCII(const std::string& theUrl, bool theMultiFile);
+ virtual bool Save(bool theMultiFile, bool theASCII);
+ virtual bool SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII);
virtual bool CanCopy(const _PTR(SObject)& theSO);
virtual bool Copy(const _PTR(SObject)& theSO);
virtual _PTR(SObject) FindObjectIOR(const std::string& anObjectIOR);
virtual _PTR(SObject) FindObjectByPath(const std::string& thePath);
virtual std::string GetObjectPath(const _PTR(SObject)& theSO);
- virtual void SetContext(const std::string& thePath);
- virtual std::string GetContext();
- virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
- virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
- virtual std::vector<std::string> GetFileNames(const std::string& theContext);
- virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
virtual _PTR(ChildIterator) NewChildIterator(const _PTR(SObject)& theSO);
virtual _PTR(SComponentIterator) NewComponentIterator();
virtual _PTR(StudyBuilder) NewBuilder();
return _PTR(SObject)(aSO);
}
-void SALOMEDS_StudyBuilder::AddDirectory(const std::string& thePath)
-{
- if (_isLocal) {
- CheckLocked();
- SALOMEDS::Locker lock;
-
- _local_impl->AddDirectory((char*)thePath.c_str());
- if (_local_impl->IsError()) {
- std::string anErrorCode = _local_impl->GetErrorCode();
- if (anErrorCode == "StudyNameAlreadyUsed") throw SALOMEDS::Study::StudyNameAlreadyUsed();
- if (anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory();
- if (anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent();
- }
- }
- else _corba_impl->AddDirectory((char*)thePath.c_str());
-}
-
void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR)
{
if(!theSCO) return;
virtual void RemoveComponent(const _PTR(SComponent)& theSCO);
virtual _PTR(SObject) NewObject(const _PTR(SObject)& theFatherObject);
virtual _PTR(SObject) NewObjectToTag(const _PTR(SObject)& theFatherObject, int theTag);
- virtual void AddDirectory(const std::string& thePath);
virtual void LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR);
virtual void Load(const _PTR(SObject)& theSCO);
virtual void RemoveObject(const _PTR(SObject)& theSO);
_impl->RemoveReference(aSO);
}
-
-//============================================================================
-/*! Function : AddDirectory
- * Purpose : adds a new directory with a path = thePath
- */
-//============================================================================
-void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath)
-{
- SALOMEDS::Locker lock;
- CheckLocked();
- if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory();
- if(!_impl->AddDirectory(std::string(thePath))) {
- std::string anErrorCode = _impl->GetErrorCode();
- if(anErrorCode == "StudyNameAlreadyUsed") throw SALOMEDS::Study::StudyNameAlreadyUsed();
- if(anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory();
- if(anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent();
- }
-}
-
-
//============================================================================
/*! Function : SetGUID
* Purpose :
*/
virtual SALOMEDS::SObject_ptr NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, CORBA::Long atag);
- /*!
- The methods adds a new subdirectory, the path can be absolute or relative (then the current context is used)
- */
- virtual void AddDirectory(const char* thePath);
-
virtual void LoadWith(SALOMEDS::SComponent_ptr sco, SALOMEDS::Driver_ptr Engine)
throw(SALOME::SALOME_Exception);
virtual void Load(SALOMEDS::SObject_ptr sco);
* Purpose : Save a Study to it's persistent reference
*/
//============================================================================
-CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
+CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
{
SALOMEDS::Locker lock;
if (_closed)
throw SALOMEDS::Study::StudyInvalidReference();
- return _impl->Save(_factory, theMultiFile);
-}
-
-CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
-{
- SALOMEDS::Locker lock;
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
- return _impl->SaveASCII(_factory, theMultiFile);
+ return _impl->Save(_factory, theMultiFile, theASCII);
}
//=============================================================================
* Purpose : Save a study to the persistent reference aUrl
*/
//============================================================================
-CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
-{
- SALOMEDS::Locker lock;
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
- return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
-}
-
-CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
+CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
{
SALOMEDS::Locker lock;
if (_closed)
throw SALOMEDS::Study::StudyInvalidReference();
- return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
+ return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
}
//============================================================================
return CORBA::string_dup(aPath.c_str());
}
-
-//============================================================================
-/*! Function : SetContext
- * Purpose : Sets the current context
- */
-//============================================================================
-void SALOMEDS_Study_i::SetContext(const char* thePath)
-{
- SALOMEDS::Locker lock;
-
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
-
- _impl->SetContext(std::string((char*)thePath));
- if (_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
- throw SALOMEDS::Study::StudyInvalidContext();
-}
-
-//============================================================================
-/*! Function : GetContext
- * Purpose : Gets the current context
- */
-//============================================================================
-char* SALOMEDS_Study_i::GetContext()
-{
- SALOMEDS::Locker lock;
-
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
-
- if (!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
-
- return CORBA::string_dup(_impl->GetContext().c_str());
-}
-
-//============================================================================
-/*! Function : GetObjectNames
- * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
-{
- SALOMEDS::Locker lock;
-
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
-
- SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
-
- if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
- throw SALOMEDS::Study::StudyInvalidContext();
-
- std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
- if (_impl->GetErrorCode() == "InvalidContext")
- throw SALOMEDS::Study::StudyInvalidContext();
-
- int aLength = aSeq.size();
- aResult->length(aLength);
- for (int anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
- }
-
- return aResult._retn();
-}
-
-//============================================================================
-/*! Function : GetDirectoryNames
- * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
-{
- SALOMEDS::Locker lock;
-
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
-
- SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
-
- if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
- throw SALOMEDS::Study::StudyInvalidContext();
-
- std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
- if (_impl->GetErrorCode() == "InvalidContext")
- throw SALOMEDS::Study::StudyInvalidContext();
-
- int aLength = aSeq.size();
- aResult->length(aLength);
- for (int anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
- }
-
- return aResult._retn();
-}
-
-//============================================================================
-/*! Function : GetFileNames
- * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
-{
- SALOMEDS::Locker lock;
-
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
-
- SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
-
- if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
- throw SALOMEDS::Study::StudyInvalidContext();
-
- std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
- if (_impl->GetErrorCode() == "InvalidContext")
- throw SALOMEDS::Study::StudyInvalidContext();
-
- int aLength = aSeq.size();
- aResult->length(aLength);
- for (int anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
- }
-
- return aResult._retn();
-}
-
-//============================================================================
-/*! Function : GetComponentNames
- * Purpose : method to get all components names
- * SRN: Note, theContext can be any, it doesn't matter
- */
-//============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
-{
- SALOMEDS::Locker lock;
-
- if (_closed)
- throw SALOMEDS::Study::StudyInvalidReference();
-
- SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
-
- std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
-
- int aLength = aSeq.size();
- aResult->length(aLength);
- for(int anIndex = 0; anIndex < aLength; anIndex++) {
- aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
- }
-
- return aResult._retn();
-}
-
//============================================================================
/*! Function : NewChildIterator
* Purpose : Create a ChildIterator from an SObject
virtual bool Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception);
//! method to save a Study
- virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile);
- virtual CORBA::Boolean SaveASCII(CORBA::Boolean theMultiFile);
+ virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
//! method to save a Study to the persistent reference aUrl
/*!
\param char* arguments, the new URL of the study
*/
- virtual CORBA::Boolean SaveAs(const char* aUrl, CORBA::Boolean theMultiFile);
- virtual CORBA::Boolean SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile);
+ virtual CORBA::Boolean SaveAs(const char* aUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
//! method to copy the object
/*!
*/
virtual char* GetObjectPath(CORBA::Object_ptr theObject);
- //! method to set a context: root ('/') is UserData component
- /*!
- */
- virtual void SetContext(const char* thePath);
-
- //! method to get a context
- /*!
- */
- virtual char* GetContext();
-
- //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
- /*!
- */
- virtual SALOMEDS::ListOfStrings* GetObjectNames(const char* theContext);
-
- //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
- /*!
- */
- virtual SALOMEDS::ListOfStrings* GetDirectoryNames(const char* theContext);
-
- //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
- /*!
- */
- virtual SALOMEDS::ListOfStrings* GetFileNames(const char* theContext);
-
- //! method to get all components names
- /*!
- */
- virtual SALOMEDS::ListOfStrings* GetComponentNames(const char* theContext);
-
//! method to Create a ChildIterator from an SObject
/*!
\param aSO SObject_ptr arguments
//Try to find component with empty type
CPPUNIT_ASSERT(!study->FindComponent(""));
- //Check method GetComponentNames
- std::vector<std::string> components = study->GetComponentNames(""); //The context doesn't matter
- CPPUNIT_ASSERT(components.size() == 1 && components[0] == "sco1");
-
//Check method FindComponentID
_PTR(SComponent) sco3 = study->FindComponentID(sco1->GetID());
CPPUNIT_ASSERT(sco3 && sco3->GetID() == sco1->GetID());
path = study->GetObjectPath(emptySO);
CPPUNIT_ASSERT(path.empty());
- //Check method SetContext
- study->SetContext("/sco1");
- CPPUNIT_ASSERT(study->GetContext() == "/sco1");
-
//Check method FindObjectByPath
_PTR(SObject) so6 = study->FindObjectByPath("so1");
CPPUNIT_ASSERT(so6 && so6->GetID() == so1->GetID());
_PTR(SObject) tmp = study->FindObjectByPath(""); //Must return the Context SObject
CPPUNIT_ASSERT(tmp && tmp->GetID() == sco1->GetID());
- study->SetContext("/"); //Root
-
- //Check method GetObjectNames
- std::vector<std::string> vs = study->GetObjectNames("/sco1");
- CPPUNIT_ASSERT(vs.size() == 2);
-
- //Check method GetDirectoryNames
- _PTR(AttributeLocalID) locid_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributeLocalID");
- CPPUNIT_ASSERT(locid_attr_sco1);
- locid_attr_sco1->SetValue(16661); //DIRECTORYID
- _PTR(AttributeLocalID) locid_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeLocalID");
- CPPUNIT_ASSERT(locid_attr_so1);
- locid_attr_so1->SetValue(16661); //DIRECTORYID
- vs = study->GetDirectoryNames(""); //Empty context (the current is taken)
- CPPUNIT_ASSERT(vs.size() == 2);
-
- //Check method GetFileNames
- locid_attr_sco1->SetValue(26662); //FILELOCALID
- _PTR(AttributePersistentRef) persref_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributePersistentRef");
- CPPUNIT_ASSERT(persref_attr_sco1);
- persref_attr_sco1->SetValue("FILE: filename1");
- locid_attr_so1->SetValue(26662); //FILELOCALID
- _PTR(AttributePersistentRef) persref_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributePersistentRef");
- CPPUNIT_ASSERT(persref_attr_so1);
- persref_attr_so1->SetValue("FILE: filename2");
- vs = study->GetFileNames("");
- CPPUNIT_ASSERT(vs.size() == 2 && vs[0] == "filename1" && vs[1] == "filename2");
-
//Check method FindDependances
studyBuilder->Addreference(so2, so1);
studyBuilder->Addreference(sco1, so1);
CPPUNIT_ASSERT(date == "08/09/0010 07:06");
//Check method GetModificationsDate
- vs = study->GetModificationsDate();
+ std::vector<std::string> vs = study->GetModificationsDate();
CPPUNIT_ASSERT(vs.size() == 2 && vs[0] == "03/04/0005 02:01" && vs[1] == "08/09/0010 07:06");
//Check method GetCommonParameters
ior = _orb->object_to_string(drv);
sb2->DefineComponentInstance(sco, ior);
- study2->SaveAs("srn_SALOMEDS_UnitTests.hdf", false);
+ study2->SaveAs("srn_SALOMEDS_UnitTests.hdf", false, false);
study2->Clear();
_PTR(Study) study3(new SALOMEDS_Study(new SALOMEDSImpl_Study()));
system("rm -f srn_SALOMEDS_UnitTests.hdf");
- //Check method AddDirectory
- _PTR(AttributeName) na1 = sb3->FindOrCreateAttribute(aComp, "AttributeName");
- na1->SetValue("Component");
-
- isRaised = false;
- try {
- sb3->AddDirectory("/Component/Dir1");
- } catch(...) {
- isRaised = true;
- }
-
-
- CPPUNIT_ASSERT(!isRaised);
- _PTR(SObject) so5 = study3->FindObjectByPath("/Component/Dir1");
- CPPUNIT_ASSERT(so5);
-
- isRaised = false;
- try {
- sb3->AddDirectory("/Component/Dir1"); //Attempt to create the same directory
- } catch(...) {
- isRaised = true;
- }
- CPPUNIT_ASSERT(isRaised);
-
- isRaised = false;
- try {
- sb3->AddDirectory("/MyComponent/Dir1"); //Attempt to create the invalid directory
- } catch(...) {
- isRaised = true;
- }
- CPPUNIT_ASSERT(isRaised);
-
study3->Clear();
}
virtual _PTR(SObject) FindObjectIOR(const std::string& anObjectIOR) = 0;
virtual _PTR(SObject) FindObjectByPath(const std::string& thePath) = 0;
virtual std::string GetObjectPath(const _PTR(SObject)& theSO) = 0;
- virtual void SetContext(const std::string& thePath) = 0;
- virtual std::string GetContext() = 0;
- virtual std::vector<std::string> GetObjectNames(const std::string& theContext) = 0;
- virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext) = 0;
- virtual std::vector<std::string> GetFileNames(const std::string& theContext) = 0;
- virtual std::vector<std::string> GetComponentNames(const std::string& theContext) = 0;
virtual _PTR(ChildIterator) NewChildIterator(const _PTR(SObject)& theSO) = 0;
virtual _PTR(SComponentIterator) NewComponentIterator() = 0;
virtual _PTR(StudyBuilder) NewBuilder() = 0;
virtual std::vector<std::string> GetModificationsDate() = 0;
virtual _PTR(UseCaseBuilder) GetUseCaseBuilder() = 0;
- virtual bool Save(bool theMultiFile) = 0;
- virtual bool SaveASCII(bool theMultiFile) = 0;
- virtual bool SaveAs(const std::string& theUrl, bool theMultiFile) = 0;
- virtual bool SaveAsASCII(const std::string& theUrl, bool theMultiFile) = 0;
+ virtual bool Save(bool theMultiFile, bool theASCII) = 0;
+ virtual bool SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII) = 0;
virtual bool CanCopy(const _PTR(SObject)& theSO) = 0;
virtual bool Copy(const _PTR(SObject)& theSO) = 0;
virtual void RemoveComponent(const _PTR(SComponent)& theSCO) = 0;
virtual _PTR(SObject) NewObject(const _PTR(SObject)& theFatherObject) = 0;
virtual _PTR(SObject) NewObjectToTag(const _PTR(SObject)& theFatherObject, int theTag) = 0;
- virtual void AddDirectory(const std::string& thePath) = 0;
virtual void LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR) = 0;
virtual void Load(const _PTR(SObject)& theSCO) = 0;
virtual void RemoveObject(const _PTR(SObject)& theSO) = 0;
*/
//============================================================================
bool SALOMEDSImpl_Study::Save(SALOMEDSImpl_DriverFactory* aFactory,
- bool theMultiFile)
+ bool theMultiFile,
+ bool theASCII)
{
_errorCode = "";
return false;
}
else {
- return Impl_SaveAs(url, aFactory, theMultiFile, false);
- }
-
- return false;
-}
-
-bool SALOMEDSImpl_Study::SaveASCII(SALOMEDSImpl_DriverFactory* aFactory,
- bool theMultiFile)
-{
- _errorCode = "";
-
- std::string url = URL();
- if (url.empty()) {
- _errorCode = "No path specified to save the study. Nothing done";
- return false;
- }
- else {
- return Impl_SaveAs(url, aFactory, theMultiFile, true);
+ return Impl_SaveAs(url, aFactory, theMultiFile, theASCII);
}
return false;
//============================================================================
bool SALOMEDSImpl_Study::SaveAs(const std::string& aUrl,
SALOMEDSImpl_DriverFactory* aFactory,
- bool theMultiFile)
+ bool theMultiFile,
+ bool theASCII)
{
_errorCode = "";
- return Impl_SaveAs(aUrl, aFactory, theMultiFile, false);
-}
-
-bool SALOMEDSImpl_Study::SaveAsASCII(const std::string& aUrl,
- SALOMEDSImpl_DriverFactory* aFactory,
- bool theMultiFile)
-{
- _errorCode = "";
- return Impl_SaveAs(aUrl, aFactory, theMultiFile, true);
+ return Impl_SaveAs(aUrl, aFactory, theMultiFile, theASCII);
}
//=============================================================================
bool isRelative = false;
if(aLength == 0) { //Empty path - return the current context
- return GetSObject(_current);
+ return aSO;
}
if(aPath[0] != '/') //Relative path
SALOMEDSImpl_AttributeName* anAttr;
if(isRelative) {
- if(_current.IsNull()) return aSO;
- anIterator.Init(_current, false);
+ return aSO;
}
else {
if(aPath.size() == 1 && aPath[0] == '/') { //Root
return GetObjectPath(so);
}
-
-//============================================================================
-/*! Function : SetContext
- * Purpose : Sets the current context
- */
-//============================================================================
-bool SALOMEDSImpl_Study::SetContext(const std::string& thePath)
-{
- _errorCode = "";
- if(thePath.empty()) {
- _errorCode = "InvalidPath";
- return false;
- }
-
- std::string aPath(thePath), aContext("");
- bool isInvalid = false;
- SALOMEDSImpl_SObject aSO;
-
- if(aPath[0] != '/') { //Relative path
- aContext = GetContext();
- aContext += '/';
- aContext += aPath;
- }
- else
- aContext = aPath;
-
- try {
- aSO = FindObjectByPath(aContext);
- }
- catch( ... ) {
- isInvalid = true;
- }
-
- if(isInvalid || !aSO) {
- _errorCode = "InvalidContext";
- return false;
- }
-
- DF_Label aLabel = aSO.GetLabel();
- if(aLabel.IsNull()) {
- _errorCode = "InvalidContext";
- return false;
- }
- else
- _current = aLabel; //Set the current context
-
- return true;
-}
-
-//============================================================================
-/*! Function : GetContext
- * Purpose : Gets the current context
- */
-//============================================================================
-std::string SALOMEDSImpl_Study::GetContext()
-{
- _errorCode = "";
-
- if(_current.IsNull()) {
- _errorCode = "InvaidContext";
- return "";
- }
- SALOMEDSImpl_SObject so = GetSObject(_current);
- return GetObjectPath(so);
-}
-
-//============================================================================
-/*! Function : GetObjectNames
- * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetObjectNames(const std::string& theContext)
-{
- _errorCode = "";
-
- std::vector<std::string> aResultSeq;
- DF_Label aLabel;
- if (theContext.empty()) {
- aLabel = _current;
- } else {
- DF_Label aTmp = _current;
- SetContext(theContext);
- aLabel = _current;
- _current = aTmp;
- }
- if (aLabel.IsNull()) {
- _errorCode = "InvalidContext";
- return aResultSeq;
- }
-
- DF_ChildIterator anIter (aLabel, true); // iterate all subchildren at all sublevels
- for (; anIter.More(); anIter.Next()) {
- DF_Label aLabel = anIter.Value();
- SALOMEDSImpl_AttributeName* aName;
- if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
- aResultSeq.push_back(aName->Value());
- }
-
- return aResultSeq;
-}
-
-//============================================================================
-/*! Function : GetDirectoryNames
- * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetDirectoryNames(const std::string& theContext)
-{
- _errorCode = "";
-
- std::vector<std::string> aResultSeq;
- DF_Label aLabel;
- if (theContext.empty()) {
- aLabel = _current;
- } else {
- DF_Label aTmp = _current;
- SetContext(theContext);
- aLabel = _current;
- _current = aTmp;
- }
- if (aLabel.IsNull()) {
- _errorCode = "InvalidContext";
- return aResultSeq;
- }
-
- DF_ChildIterator anIter (aLabel, true); // iterate first-level children at all sublevels
- for (; anIter.More(); anIter.Next()) {
- DF_Label aLabel = anIter.Value();
- SALOMEDSImpl_AttributeLocalID* anID;
- if ((anID=(SALOMEDSImpl_AttributeLocalID*)aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID()))) {
- if (anID->Value() == DIRECTORYID) {
- SALOMEDSImpl_AttributeName* aName;
- if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
- aResultSeq.push_back(aName->Value());
- }
- }
- }
- }
-
- return aResultSeq;
-}
-
-//============================================================================
-/*! Function : GetFileNames
- * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetFileNames(const std::string& theContext)
-{
- _errorCode = "";
-
- std::vector<std::string> aResultSeq;
- DF_Label aLabel;
- if (theContext.empty()) {
- aLabel = _current;
- } else {
- DF_Label aTmp = _current;
- SetContext(theContext);
- aLabel = _current;
- _current = aTmp;
- }
- if (aLabel.IsNull()) {
- _errorCode = "InvalidContext";
- return aResultSeq;
- }
-
- DF_ChildIterator anIter (aLabel, true); // iterate all subchildren at all sublevels
- for (; anIter.More(); anIter.Next()) {
- DF_Label aLabel = anIter.Value();
- SALOMEDSImpl_AttributeLocalID* anID;
- if ((anID=(SALOMEDSImpl_AttributeLocalID*)aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID()))) {
- if (anID->Value() == FILELOCALID) {
- SALOMEDSImpl_AttributePersistentRef* aName;
- if ((aName=(SALOMEDSImpl_AttributePersistentRef*)aLabel.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID()))) {
- std::string aFileName = aName->Value();
- if (aFileName.size() > 0)
- aResultSeq.push_back(aFileName.substr(strlen(FILEID), aFileName.size()));
- }
- }
- }
- }
-
- return aResultSeq;
-}
-
-//============================================================================
-/*! Function : GetComponentNames
- * Purpose : method to get all components names
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetComponentNames(const std::string& theContext)
-{
- _errorCode = "";
-
- std::vector<std::string> aResultSeq;
- DF_ChildIterator anIter(_doc->Main(), false); // iterate all subchildren at first level
- for(; anIter.More(); anIter.Next()) {
- DF_Label aLabel = anIter.Value();
- SALOMEDSImpl_AttributeName* aName;
- if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
- aResultSeq.push_back(aName->Value());
- }
-
- return aResultSeq;
-}
-
//============================================================================
/*! Function : NewChildIterator
* Purpose : Create a ChildIterator from an SObject
DF_Document* _clipboard;
bool _Saved; // True if the Study is saved
std::string _URL; //URL of the persistent reference of the study
- DF_Label _current;
bool _autoFill;
std::string _errorCode;
std::vector<std::string> _lockers;
virtual bool Open(const std::string& aStudyUrl);
//! method to save a Study
- virtual bool Save(SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile);
-
- virtual bool SaveASCII(SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile);
+ virtual bool Save(SALOMEDSImpl_DriverFactory* aFactory,
+ bool theMultiFile,
+ bool theASCII);
//! method to save a Study to the persistent reference aUrl
virtual bool SaveAs(const std::string& aUrl,
SALOMEDSImpl_DriverFactory* aFactory,
- bool theMultiFile);
-
- virtual bool SaveAsASCII(const std::string& aUrl,
- SALOMEDSImpl_DriverFactory* aFactory,
- bool theMultiFile);
+ bool theMultiFile,
+ bool theASCII);
bool CopyLabel(SALOMEDSImpl_Driver* theEngine,
const int theSourceStartDepth,
std::string GetObjectPathByIOR(const std::string& theIOR);
- //! method to set a context: root ('/') is UserData component
- virtual bool SetContext(const std::string& thePath);
-
- //! method to get a context
- virtual std::string GetContext();
-
- //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
- virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
-
- //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
- virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
-
- //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
- virtual std::vector<std::string> GetFileNames(const std::string& theContext);
-
- //! method to get all components names
- virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
-
//! method to Create a ChildIterator from an SObject
virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO);
virtual DF_Attribute* GetAttribute(const std::string& theEntry,
const std::string& theType);
- virtual bool HasCurrentContext() { return !_current.IsNull(); }
-
virtual bool DumpStudy(const std::string& thePath,
const std::string& theBaseName,
bool isPublished,
return true;
}
-
-
-//============================================================================
-/*! Function : AddDirectory
- * Purpose : adds a new directory with a path = thePath
- */
-//============================================================================
-bool SALOMEDSImpl_StudyBuilder::AddDirectory(const std::string& thePath)
-{
- _errorCode = "";
- CheckLocked();
- if(thePath.empty()) {
- _errorCode = "Invalid path";
- return false;
- }
-
- std::string aPath(thePath), aContext(""), aFatherPath;
- DF_Label aLabel;
- SALOMEDSImpl_SObject anObject;
-
- try {
- anObject = _study->FindObjectByPath(thePath); //Check if the directory already exists
- }
- catch(...) { }
-
- if(anObject) {
- _errorCode = "StudyNameAlreadyUsed";
- return false;
- }
-
- if(aPath[0] != '/') { //Relative path
- aPath.insert(aPath.begin(), '/');
- aPath = _study->GetContext() + aPath;
- }
-
- std::vector<std::string> vs = SALOMEDSImpl_Tool::splitString(aPath, '/');
- if(vs.size() == 1)
- aFatherPath = "/";
- else {
- for(int i = 0, len = vs.size()-1; i<len; i++) {
- aFatherPath += "/";
- aFatherPath += vs[i];
- }
- }
-
- try {
- anObject = _study->FindObjectByPath(aFatherPath); //Check if the father directory exists
- }
- catch(...) { ; }
- if(!anObject) {
- _errorCode = "StudyInvalidDirectory";
- return false;
- }
-
- SALOMEDSImpl_SObject aNewObject = NewObject(anObject);
- aLabel = aNewObject.GetLabel();
- if(aLabel.IsNull()) {
- _errorCode = "StudyInvalidComponent";
- return false;
- }
-
- SALOMEDSImpl_AttributeName::Set(aLabel, vs.back());
-
- //Set LocalID attribute to identify the directory object
- SALOMEDSImpl_AttributeLocalID::Set(aLabel, DIRECTORYID);
-
- _doc->SetModified(true);
-
- return true;
-}
-
-
//============================================================================
/*! Function : SetGUID
* Purpose :
virtual SALOMEDSImpl_SObject NewObjectToTag(const SALOMEDSImpl_SObject& theFatherObject,
const int theTag);
- //! The methods adds a new subdirectory, the path can be absolute or relative (then the current context is used)
- virtual bool AddDirectory(const std::string& thePath);
-
virtual bool LoadWith(const SALOMEDSImpl_SComponent& sco, SALOMEDSImpl_Driver* Engine);
virtual bool Load(const SALOMEDSImpl_SObject& sco);
#include <iostream>
#include <fstream>
-#include <stdlib.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
// purpose : Removes files listed in theFileList
//============================================================================
void SALOMEDS_Tool::RemoveTemporaryFiles(const std::string& theDirectory,
- const std::list<std::string>& theFiles,
+ const ListOfFiles& theFiles,
const bool IsDirDeleted)
{
std::string aDirName = theDirectory;
- for(std::list<std::string>::const_iterator it = theFiles.begin(); it != theFiles.end(); it++) {
+ int i, aLength = theFiles.size();
+ for(i=1; i<=aLength; i++) {
std::string aFile(aDirName);
- aFile += *it;
+ aFile += theFiles[i-1];
if(!Exists(aFile)) continue;
#ifdef WIN32
{
SALOMEDS::TMPFile*
PutFilesToStream(const std::string& theFromDirectory,
- const std::list<std::string>& theFiles,
- const std::list<std::string>& theFileNames,
+ const std::vector<std::string>& theFiles,
+ const std::vector<std::string>& theFileNames,
const int theNamesOnly)
{
- int i = 0, aLength = theFiles.size();
+ int i, aLength = theFiles.size();
if(aLength == 0)
return (new SALOMEDS::TMPFile);
//Determine the required size of the buffer
- std::list<std::string>::const_iterator it_files = theFiles.begin();
- std::list<std::string>::const_iterator it_names = theFileNames.begin();
- for(; it_files != theFiles.end(); it_files++, it_names++, i++) {
+ for(i=0; i<aLength; i++) {
//Check if the file exists
if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero
- std::string aFullPath = aTmpDir + *it_files;
+ std::string aFullPath = aTmpDir + theFiles[i];
if(!Exists(aFullPath)) continue;
#ifdef WIN32
std::ifstream aFile(aFullPath.c_str(), std::ios::binary);
aFileSize[i] = aFile.tellg();
aBufferSize += aFileSize[i]; //Add a space to store the file
}
- aFileNameSize[i] = (*it_names).length()+1;
+ aFileNameSize[i] = theFileNames[i].length()+1;
aBufferSize += aFileNameSize[i]; //Add a space to store the file name
aBufferSize += (theNamesOnly)?4:12; //Add 4 bytes: a length of the file name,
// 8 bytes: length of the file itself
aCurrentPos = 4;
- it_files = theFiles.begin();
- it_names = theFileNames.begin();
- for(; it_files != theFiles.end(); it_files++, it_names++, i++) {
+ for(i=0; i<aLength; i++) {
std::ifstream *aFile;
if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
- std::string aFullPath = aTmpDir + *it_files;
+ std::string aFullPath = aTmpDir + theFiles[i];
if(!Exists(aFullPath)) continue;
#ifdef WIN32
aFile = new std::ifstream(aFullPath.c_str(), std::ios::binary);
aCurrentPos += 4;
//Copy the file name to the buffer
- memcpy((aBuffer + aCurrentPos), (*it_names).c_str(), aFileNameSize[i]);
+ memcpy((aBuffer + aCurrentPos), theFileNames[i].c_str(), aFileNameSize[i]);
aCurrentPos += aFileNameSize[i];
if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
SALOMEDS::TMPFile*
SALOMEDS_Tool::PutFilesToStream(const std::string& theFromDirectory,
- const std::list<std::string>& theFiles,
+ const ListOfFiles& theFiles,
const int theNamesOnly)
{
- std::list<std::string> aFileNames(theFiles);
+ ListOfFiles aFileNames(theFiles);
return ::PutFilesToStream(theFromDirectory,theFiles,aFileNames,theNamesOnly);
}
SALOMEDS::TMPFile*
-SALOMEDS_Tool::PutFilesToStream(const std::list<std::string>& theFiles,
- const std::list<std::string>& theFileNames)
+SALOMEDS_Tool::PutFilesToStream(const ListOfFiles& theFiles,
+ const ListOfFiles& theFileNames)
{
return ::PutFilesToStream("",theFiles,theFileNames,0);
}
// function : PutStreamToFile
// purpose : converts the stream "theStream" to the files
//============================================================================
-std::list<std::string>
+SALOMEDS_Tool::ListOfFiles
SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
const std::string& theToDirectory,
const int theNamesOnly)
{
- std::list<std::string> aFiles;
+ ListOfFiles aFiles;
if(theStream.length() == 0)
return aFiles;
//Copy the number of files in the stream
memcpy(&aNbFiles, aBuffer, sizeof(int));
+ aFiles.reserve(aNbFiles);
+
for(i=0; i<aNbFiles; i++) {
//Put a length of the file name to aFileNameSize
}
-
#include <string>
#include <list>
+#include <vector>
+#include <stdlib.h>
// IDL headers
class TOOLSDS_EXPORT SALOMEDS_Tool
{
public:
+
+ typedef std::vector<std::string> ListOfFiles;
// Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
// otherwise return /tmp/something/ for Unix or c:\something\ for WIN32
// Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
// if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
static void RemoveTemporaryFiles(const std::string& theDirectory,
- const std::list<std::string>& theFiles,
+ const ListOfFiles& theFiles,
const bool IsDirDeleted);
// Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory,
- const std::list<std::string>& theFiles,
+ const ListOfFiles& theFiles,
const int theNamesOnly = 0);
// Converts files listed in <theFiles> which will be named as pointed in the <theFileNames> into a byte sequence TMPFile
- static SALOMEDS::TMPFile* PutFilesToStream(const std::list<std::string>& theFiles,
- const std::list<std::string>& theFileNames);
+ static SALOMEDS::TMPFile* PutFilesToStream(const ListOfFiles& theFiles,
+ const ListOfFiles& theFileNames);
// Converts a byte sequence <theStream> to files and places them in <theToDirectory>
- static std::list<std::string> PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
+ static ListOfFiles PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
const std::string& theToDirectory,
const int theNamesOnly = 0);