X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDS%2FSALOMEDS_Study_i.cxx;h=cd586ec2f80023d78afc04392e2afcadf5bd4b98;hb=074699f122e9bfd758dc805ca0023d355ce25ec5;hp=23cc0c031f4388ca461950596152797fd1d327b6;hpb=22fef16356c8eb8e9dd1542ac49669f373786db3;p=modules%2Fkernel.git diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 23cc0c031..cd586ec2f 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -165,10 +165,10 @@ namespace SALOMEDS { for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) { - if ( it->first->_is_equivalent(theObs) ) { - myObservers.erase( it ); - break; - } + if ( it->first->_is_equivalent(theObs) ) { + myObservers.erase( it ); + break; + } } } @@ -288,15 +288,6 @@ void SALOMEDS_Study_i::Init() aSession->emitMessageOneWay(str.c_str()); SALOMEDS::lock(); } - - std::string anIOR = _impl->GetTransientReference(); - if ( anIOR.empty() ) { - CORBA::Object_var obj = aNamingService->Resolve("/Study"); - SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( obj ); - CORBA::String_var IORStudy = _orb->object_to_string(aStudy); - _impl->SetTransientReference((char*)IORStudy.in()); - } - } //============================================================================ @@ -308,7 +299,7 @@ void SALOMEDS_Study_i::Clear() { SALOMEDS::Locker lock; if (_closed) - throw SALOMEDS::Study::StudyInvalidReference(); + return; //delete the builder servant PortableServer::POA_var poa=_builder->_default_POA(); PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder); @@ -367,6 +358,7 @@ void SALOMEDS_Study_i::Clear() _impl->setNotifier(0); delete _notifier; delete _genObjRegister; + _notifier = NULL; _closed = true; } @@ -402,20 +394,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) -{ - SALOMEDS::Locker lock; - if (_closed) - throw SALOMEDS::Study::StudyInvalidReference(); - return _impl->Save(_factory, theMultiFile); -} - -CORBA::Boolean SALOMEDS_Study_i::SaveASCII(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->SaveASCII(_factory, theMultiFile); + return _impl->Save(_factory, theMultiFile, theASCII); } //============================================================================= @@ -423,20 +407,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) +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->SaveAs(std::string(aUrl), _factory, theMultiFile); -} - -CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile) -{ - 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); } //============================================================================ @@ -557,18 +533,6 @@ char* SALOMEDS_Study_i::GetPersistentReference() throw SALOMEDS::Study::StudyInvalidReference(); return CORBA::string_dup(_impl->GetPersistentReference().c_str()); } -//============================================================================ -/*! Function : GetTransientReference - * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root) - */ -//============================================================================ -char* SALOMEDS_Study_i::GetTransientReference() -{ - SALOMEDS::Locker lock; - if (_closed) - throw SALOMEDS::Study::StudyInvalidReference(); - return CORBA::string_dup(_impl->GetTransientReference().c_str()); -} //============================================================================ /*! Function : IsEmpty @@ -800,157 +764,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 @@ -1114,23 +927,6 @@ void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry) _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry)); } -SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb) -{ - SALOMEDS::Locker lock; - - SALOMEDSImpl_AttributeIOR* Att = NULL; - if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){ - char* IOR = CORBA::string_dup(Att->Value().c_str()); - CORBA::Object_var obj = orb->string_to_object(IOR); - SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ; - ASSERT(!CORBA::is_nil(aStudy)); - return SALOMEDS::Study::_duplicate(aStudy); - } else { - MESSAGE("GetStudy: Problem to get study"); - } - return SALOMEDS::Study::_nil(); -} - void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute) { SALOMEDS::Locker lock;