From: mpa Date: Wed, 18 Jan 2017 09:42:43 +0000 (+0300) Subject: SALOMEDS changes: X-Git-Tag: Before_python3_27062017~1^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ed19d8bc0100ac6f91024fe88d22e3cbc0b2cc18;p=modules%2Fkernel.git SALOMEDS changes: - combine Save, SaveASCII; SaveAs, SaveAsASCII methods - delete deprecated code from Study and StudyBuilder interfaces --- diff --git a/doc/salome/examples/example23 b/doc/salome/examples/example23 index da60ce0e9..b613c47c7 100644 --- a/doc/salome/examples/example23 +++ b/doc/salome/examples/example23 @@ -12,19 +12,3 @@ anAttrName = anAttr._narrow(SALOMEDS.AttributeName) 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") - diff --git a/doc/salome/kernel_salome.dox b/doc/salome/kernel_salome.dox index da0acb4fa..72ac05c46 100644 --- a/doc/salome/kernel_salome.dox +++ b/doc/salome/kernel_salome.dox @@ -97,19 +97,19 @@ documentation. 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() diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index d43d58e83..c193837db 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -238,15 +238,6 @@ module SALOMEDS void RemoveReference(in SObject anObject) ; -/*! - Adds a directory in the %Study. - \param theName String parameter defining the name of the directory. - -See \ref example23 for an example of this method usage in batchmode of %SALOME application. - -*/ - void AddDirectory(in string theName) raises(LockProtection); - /*! \brief Identification of the %SObject's substructure. Identification of the %SObject's substructure by GUID. @@ -379,8 +370,6 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin //! Invalid study reference exception StudyInvalidReference {}; -//! Invalid study context - exception StudyInvalidContext {}; //! Invalid study component exception StudyInvalidComponent {}; //! Invalid directory of the %study exception @@ -482,38 +471,6 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin */ string GetObjectPath(in Object theObject) raises(StudyInvalidReference); -/*! \brief Set the context of the %Study. - - \param thePath String parameter defining the context of the study. - -See \ref example23 for an example of this method usage in batchmode of %SALOME application. -*/ - void SetContext(in string thePath) raises (StudyInvalidReference, StudyInvalidContext); -/*! \brief Get the context of the %Study. - -See \ref example23 for an example of this method usage in batchmode of %SALOME application. -*/ - string GetContext() raises (StudyInvalidReference, StudyInvalidContext); -/*! \brief Get a list of names of objects corresponding to the context. - - \note If the parameter theContext 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 theContext 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 theContext 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 theContext 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 @@ -614,42 +571,27 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin */ 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. See \ref example1 for an example of this method usage in batchmode of %SALOME application. */ 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. */ diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index db409bbf5..1f5ef1d3a 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -194,7 +194,7 @@ static void Test(SALOMEDS::Study_ptr myStudy) 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(); diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index a23708898..3fb21699d 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -132,28 +132,16 @@ bool SALOMEDS_Study::Open(const std::string& theStudyUrl) 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) @@ -458,91 +446,6 @@ std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO) 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 SALOMEDS_Study::GetObjectNames(const std::string& theContext) -{ - std::vector 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 SALOMEDS_Study::GetDirectoryNames(const std::string& theContext) -{ - std::vector 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 SALOMEDS_Study::GetFileNames(const std::string& theContext) -{ - std::vector 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 SALOMEDS_Study::GetComponentNames(const std::string& theContext) -{ - std::vector 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(theSO.get()); diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 8d84ab6c2..d7231e139 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -57,10 +57,8 @@ public: 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); @@ -79,12 +77,6 @@ public: 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 GetObjectNames(const std::string& theContext); - virtual std::vector GetDirectoryNames(const std::string& theContext); - virtual std::vector GetFileNames(const std::string& theContext); - virtual std::vector GetComponentNames(const std::string& theContext); virtual _PTR(ChildIterator) NewChildIterator(const _PTR(SObject)& theSO); virtual _PTR(SComponentIterator) NewComponentIterator(); virtual _PTR(StudyBuilder) NewBuilder(); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index c43220b29..d76bc47fb 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -170,23 +170,6 @@ _PTR(SObject) SALOMEDS_StudyBuilder::NewObjectToTag(const _PTR(SObject)& theFath 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; diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx index b7e3a6160..a57ab0a51 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx @@ -55,7 +55,6 @@ public: 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); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index a31fda64c..9ba49a326 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -320,26 +320,6 @@ void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me) _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 : diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index d4c30fb74..07778737b 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -88,11 +88,6 @@ public: */ 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); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index ad532e303..cdd6dd3b9 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -404,20 +404,12 @@ bool SALOMEDS_Study_i::Open(const char* aUrl) * 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); } //============================================================================= @@ -425,20 +417,12 @@ CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile) * 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); } //============================================================================ @@ -802,157 +786,6 @@ char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject) 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 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 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 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 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 diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index cfe22e265..18a8f0d66 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -79,15 +79,13 @@ public: 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 /*! @@ -188,36 +186,6 @@ public: */ 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 diff --git a/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx b/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx index 4089fcc47..dbf65e2e6 100755 --- a/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx +++ b/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx @@ -87,10 +87,6 @@ void SALOMEDSTest::testStudy() //Try to find component with empty type CPPUNIT_ASSERT(!study->FindComponent("")); - //Check method GetComponentNames - std::vector 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()); @@ -157,10 +153,6 @@ void SALOMEDSTest::testStudy() 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()); @@ -170,34 +162,6 @@ void SALOMEDSTest::testStudy() _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 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); @@ -237,7 +201,7 @@ void SALOMEDSTest::testStudy() CPPUNIT_ASSERT(date == "08/09/0010 07:06"); //Check method GetModificationsDate - vs = study->GetModificationsDate(); + std::vector 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 diff --git a/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx b/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx index d1c6e9036..84df3faf9 100755 --- a/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx +++ b/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx @@ -180,7 +180,7 @@ void SALOMEDSTest::testStudyBuilder() 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())); @@ -211,37 +211,5 @@ void SALOMEDSTest::testStudyBuilder() 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(); } diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 46b598865..d4ae8e610 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -66,12 +66,6 @@ public: 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 GetObjectNames(const std::string& theContext) = 0; - virtual std::vector GetDirectoryNames(const std::string& theContext) = 0; - virtual std::vector GetFileNames(const std::string& theContext) = 0; - virtual std::vector 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; @@ -88,10 +82,8 @@ public: virtual std::vector 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; diff --git a/src/SALOMEDSClient/SALOMEDSClient_StudyBuilder.hxx b/src/SALOMEDSClient/SALOMEDSClient_StudyBuilder.hxx index 968a8e397..9889d2d0e 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_StudyBuilder.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_StudyBuilder.hxx @@ -43,7 +43,6 @@ public: 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; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index d10e3383e..1f3fefc89 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -296,7 +296,8 @@ bool SALOMEDSImpl_Study::Open(const std::string& aUrl) */ //============================================================================ bool SALOMEDSImpl_Study::Save(SALOMEDSImpl_DriverFactory* aFactory, - bool theMultiFile) + bool theMultiFile, + bool theASCII) { _errorCode = ""; @@ -306,24 +307,7 @@ bool SALOMEDSImpl_Study::Save(SALOMEDSImpl_DriverFactory* aFactory, 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; @@ -336,18 +320,11 @@ bool SALOMEDSImpl_Study::SaveASCII(SALOMEDSImpl_DriverFactory* aFactory, //============================================================================ 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); } //============================================================================= @@ -1493,7 +1470,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectByPath(const std::string& the bool isRelative = false; if(aLength == 0) { //Empty path - return the current context - return GetSObject(_current); + return aSO; } if(aPath[0] != '/') //Relative path @@ -1504,8 +1481,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectByPath(const std::string& the SALOMEDSImpl_AttributeName* anAttr; if(isRelative) { - if(_current.IsNull()) return aSO; - anIterator.Init(_current, false); + return aSO; } else { if(aPath.size() == 1 && aPath[0] == '/') { //Root @@ -1594,212 +1570,6 @@ std::string SALOMEDSImpl_Study::GetObjectPathByIOR(const std::string& theIOR) 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 SALOMEDSImpl_Study::GetObjectNames(const std::string& theContext) -{ - _errorCode = ""; - - std::vector 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 SALOMEDSImpl_Study::GetDirectoryNames(const std::string& theContext) -{ - _errorCode = ""; - - std::vector 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 SALOMEDSImpl_Study::GetFileNames(const std::string& theContext) -{ - _errorCode = ""; - - std::vector 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 SALOMEDSImpl_Study::GetComponentNames(const std::string& theContext) -{ - _errorCode = ""; - - std::vector 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 diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index 297a3c738..81504d301 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -64,7 +64,6 @@ private: 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 _lockers; @@ -111,18 +110,15 @@ public: 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, @@ -193,24 +189,6 @@ public: 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 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 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 GetFileNames(const std::string& theContext); - - //! method to get all components names - virtual std::vector GetComponentNames(const std::string& theContext); - //! method to Create a ChildIterator from an SObject virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO); @@ -265,8 +243,6 @@ public: 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, diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index 3a6853693..0da25ddc7 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -620,78 +620,6 @@ bool SALOMEDSImpl_StudyBuilder::RemoveReference(const SALOMEDSImpl_SObject& me) 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 vs = SALOMEDSImpl_Tool::splitString(aPath, '/'); - if(vs.size() == 1) - aFatherPath = "/"; - else { - for(int i = 0, len = vs.size()-1; iFindObjectByPath(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 : diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx index 86623d607..48209bcf7 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx @@ -64,9 +64,6 @@ public: 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); diff --git a/src/TOOLSDS/SALOMEDS_Tool.cxx b/src/TOOLSDS/SALOMEDS_Tool.cxx index 9f9ffd6b7..6c09e96b4 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.cxx +++ b/src/TOOLSDS/SALOMEDS_Tool.cxx @@ -44,7 +44,6 @@ #include #include -#include #include #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) @@ -132,14 +131,15 @@ std::string SALOMEDS_Tool::GetTmpDir() // purpose : Removes files listed in theFileList //============================================================================ void SALOMEDS_Tool::RemoveTemporaryFiles(const std::string& theDirectory, - const std::list& theFiles, + const ListOfFiles& theFiles, const bool IsDirDeleted) { std::string aDirName = theDirectory; - for(std::list::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 @@ -169,11 +169,11 @@ namespace { SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, - const std::list& theFiles, - const std::list& theFileNames, + const std::vector& theFiles, + const std::vector& theFileNames, const int theNamesOnly) { - int i = 0, aLength = theFiles.size(); + int i, aLength = theFiles.size(); if(aLength == 0) return (new SALOMEDS::TMPFile); @@ -189,14 +189,12 @@ namespace //Determine the required size of the buffer - std::list::const_iterator it_files = theFiles.begin(); - std::list::const_iterator it_names = theFileNames.begin(); - for(; it_files != theFiles.end(); it_files++, it_names++, i++) { + for(i=0; i& theFiles, + const ListOfFiles& theFiles, const int theNamesOnly) { - std::list aFileNames(theFiles); + ListOfFiles aFileNames(theFiles); return ::PutFilesToStream(theFromDirectory,theFiles,aFileNames,theNamesOnly); } SALOMEDS::TMPFile* -SALOMEDS_Tool::PutFilesToStream(const std::list& theFiles, - const std::list& theFileNames) +SALOMEDS_Tool::PutFilesToStream(const ListOfFiles& theFiles, + const ListOfFiles& theFileNames) { return ::PutFilesToStream("",theFiles,theFileNames,0); } @@ -299,12 +295,12 @@ SALOMEDS_Tool::PutFilesToStream(const std::list& theFiles, // function : PutStreamToFile // purpose : converts the stream "theStream" to the files //============================================================================ -std::list +SALOMEDS_Tool::ListOfFiles SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, const std::string& theToDirectory, const int theNamesOnly) { - std::list aFiles; + ListOfFiles aFiles; if(theStream.length() == 0) return aFiles; @@ -323,6 +319,8 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, //Copy the number of files in the stream memcpy(&aNbFiles, aBuffer, sizeof(int)); + aFiles.reserve(aNbFiles); + for(i=0; i #include +#include +#include // IDL headers @@ -50,6 +52,8 @@ class TOOLSDS_EXPORT SALOMEDS_Tool { public: + + typedef std::vector 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 @@ -59,20 +63,20 @@ public: // Removes files which are in , the files for deletion are listed in // if is true is also deleted if it is empty static void RemoveTemporaryFiles(const std::string& theDirectory, - const std::list& theFiles, + const ListOfFiles& theFiles, const bool IsDirDeleted); // Converts files listed in which are in into a byte sequence TMPFile static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, - const std::list& theFiles, + const ListOfFiles& theFiles, const int theNamesOnly = 0); // Converts files listed in which will be named as pointed in the into a byte sequence TMPFile - static SALOMEDS::TMPFile* PutFilesToStream(const std::list& theFiles, - const std::list& theFileNames); + static SALOMEDS::TMPFile* PutFilesToStream(const ListOfFiles& theFiles, + const ListOfFiles& theFileNames); // Converts a byte sequence to files and places them in - static std::list PutStreamToFiles(const SALOMEDS::TMPFile& theStream, + static ListOfFiles PutStreamToFiles(const SALOMEDS::TMPFile& theStream, const std::string& theToDirectory, const int theNamesOnly = 0);