1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 // File : SALOMEDS_Study_i.cxx
21 // Author : Sergey RUIN
25 #include "utilities.h"
26 #include "SALOMEDS_Study_i.hxx"
27 #include "SALOMEDS_UseCaseIterator_i.hxx"
28 #include "SALOMEDS_GenericAttribute_i.hxx"
29 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
30 #include "SALOMEDS_ChildIterator_i.hxx"
31 #include "SALOMEDS_Driver_i.hxx"
32 #include "SALOMEDS.hxx"
34 #include "SALOMEDSImpl_SObject.hxx"
35 #include "SALOMEDSImpl_SComponent.hxx"
36 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
37 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
38 #include "SALOMEDSImpl_ChildIterator.hxx"
40 #include <TColStd_SequenceOfExtendedString.hxx>
41 #include <TColStd_HSequenceOfAsciiString.hxx>
42 #include <TColStd_HSequenceOfTransient.hxx>
43 #include <TCollection_AsciiString.hxx>
44 #include <TCollection_ExtendedString.hxx>
46 #include <TDF_Label.hxx>
47 #include <TDF_Attribute.hxx>
52 #include <sys/types.h>
60 //============================================================================
61 /*! Function : SALOMEDS_Study_i
62 * Purpose : SALOMEDS_Study_i constructor
64 //============================================================================
65 SALOMEDS_Study_i::SALOMEDS_Study_i(const Handle(SALOMEDSImpl_Study) theImpl,
68 _orb = CORBA::ORB::_duplicate(orb);
71 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
74 //============================================================================
75 /*! Function : ~SALOMEDS_Study_i
76 * Purpose : SALOMEDS_Study_i destructor
78 //============================================================================
79 SALOMEDS_Study_i::~SALOMEDS_Study_i()
83 //============================================================================
84 /*! Function : GetPersistentReference
85 * Purpose : Get persistent reference of study (idem URL())
87 //============================================================================
88 char* SALOMEDS_Study_i::GetPersistentReference()
90 SALOMEDS::Locker lock;
91 return CORBA::string_dup(_impl->GetPersistentReference().ToCString());
93 //============================================================================
94 /*! Function : GetTransientReference
95 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
97 //============================================================================
98 char* SALOMEDS_Study_i::GetTransientReference()
100 SALOMEDS::Locker lock;
101 return CORBA::string_dup(_impl->GetTransientReference().ToCString());
104 //============================================================================
105 /*! Function : IsEmpty
106 * Purpose : Detect if study is empty
108 //============================================================================
109 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
111 SALOMEDS::Locker lock;
112 return _impl->IsEmpty();
115 //============================================================================
116 /*! Function : FindComponent
117 * Purpose : Find a Component with ComponentDataType = aComponentName
119 //============================================================================
120 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
122 SALOMEDS::Locker lock;
124 Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponent(TCollection_AsciiString((char*)aComponentName));
125 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
127 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
131 //============================================================================
132 /*! Function : FindComponentID
133 * Purpose : Find a Component from it's ID
135 //============================================================================
136 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
138 SALOMEDS::Locker lock;
140 Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponentID(TCollection_AsciiString((char*)aComponentID));
141 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
143 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
147 //============================================================================
148 /*! Function : FindObject
149 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
151 //============================================================================
152 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
154 SALOMEDS::Locker lock;
156 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObject(TCollection_AsciiString((char*)anObjectName));
157 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
159 if(aSO->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_SComponent)) {
160 Handle(SALOMEDSImpl_SComponent) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO);
161 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
165 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
170 //============================================================================
171 /*! Function : FindObjectID
172 * Purpose : Find an Object with ID = anObjectID
174 //============================================================================
175 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
177 SALOMEDS::Locker lock;
179 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectID(TCollection_AsciiString((char*)anObjectID));
180 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
181 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
185 //============================================================================
186 /*! Function : CreateObjectID
187 * Purpose : Creates an Object with ID = anObjectID
189 //============================================================================
190 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
192 SALOMEDS::Locker lock;
194 Handle(SALOMEDSImpl_SObject) aSO = _impl->CreateObjectID((char*)anObjectID);
195 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
197 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
201 //============================================================================
202 /*! Function : FindObjectByName
203 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
204 * : with ComponentDataType = aComponentName
206 //============================================================================
207 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
208 const char* aComponentName )
210 SALOMEDS::Locker lock;
212 Handle(TColStd_HSequenceOfTransient) aSeq = _impl->FindObjectByName(TCollection_AsciiString((char*)anObjectName),
213 TCollection_AsciiString((char*)aComponentName));
214 int aLength = aSeq->Length();
215 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
216 listSO->length(aLength);
217 for(int i = 1; i<=aLength; i++) {
218 Handle(SALOMEDSImpl_SObject) aSO = Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i));
219 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
222 return listSO._retn() ;
225 //============================================================================
226 /*! Function : FindObjectIOR
227 * Purpose : Find an Object with IOR = anObjectIOR
229 //============================================================================
230 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
232 SALOMEDS::Locker lock;
234 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectIOR(TCollection_AsciiString((char*)anObjectIOR));
235 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
237 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
241 //============================================================================
242 /*! Function : FindObjectByPath
243 * Purpose : Find an Object by its path = thePath
245 //============================================================================
246 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
248 SALOMEDS::Locker lock;
250 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectByPath(TCollection_AsciiString((char*)thePath));
251 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
253 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
257 //============================================================================
258 /*! Function : GetObjectPath
261 //============================================================================
262 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
264 SALOMEDS::Locker lock;
266 TCollection_AsciiString aPath("");
267 if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.ToCString());
268 Handle(SALOMEDSImpl_SObject) aSO;
269 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
271 if(!CORBA::is_nil(aSObj)) {
272 aSO = _impl->FindObjectID(aSObj->GetID());
275 aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
278 if(aSO.IsNull()) return CORBA::string_dup(aPath.ToCString());
280 aPath = _impl->GetObjectPath(aSO);
281 return CORBA::string_dup(aPath.ToCString());
285 //============================================================================
286 /*! Function : SetContext
287 * Purpose : Sets the current context
289 //============================================================================
290 void SALOMEDS_Study_i::SetContext(const char* thePath)
292 SALOMEDS::Locker lock;
294 _impl->SetContext(TCollection_AsciiString((char*)thePath));
295 if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
296 throw SALOMEDS::Study::StudyInvalidContext();
299 //============================================================================
300 /*! Function : GetContext
301 * Purpose : Gets the current context
303 //============================================================================
304 char* SALOMEDS_Study_i::GetContext()
306 SALOMEDS::Locker lock;
308 if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
309 return CORBA::string_dup(_impl->GetContext().ToCString());
312 //============================================================================
313 /*! Function : GetObjectNames
314 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
316 //============================================================================
317 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
319 SALOMEDS::Locker lock;
321 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
322 if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
323 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetObjectNames(TCollection_AsciiString((char*)theContext));
324 int aLength = aSeq->Length();
325 aResult->length(aLength);
326 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
327 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
329 return aResult._retn();
332 //============================================================================
333 /*! Function : GetDirectoryNames
334 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
336 //============================================================================
337 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
339 SALOMEDS::Locker lock;
341 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
342 if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
343 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetDirectoryNames(TCollection_AsciiString((char*)theContext));
344 int aLength = aSeq->Length();
345 aResult->length(aLength);
346 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
347 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
349 return aResult._retn();
352 //============================================================================
353 /*! Function : GetFileNames
354 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
356 //============================================================================
357 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
359 SALOMEDS::Locker lock;
361 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
362 if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
363 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetFileNames(TCollection_AsciiString((char*)theContext));
364 int aLength = aSeq->Length();
365 aResult->length(aLength);
366 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
367 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
369 return aResult._retn();
372 //============================================================================
373 /*! Function : GetComponentNames
374 * Purpose : method to get all components names
376 //============================================================================
377 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
379 SALOMEDS::Locker lock;
381 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
382 if (strlen(theContext) == 0 && !_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
383 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetComponentNames(TCollection_AsciiString((char*)theContext));
384 int aLength = aSeq->Length();
385 aResult->length(aLength);
386 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
387 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
389 return aResult._retn();
392 //============================================================================
393 /*! Function : NewChildIterator
394 * Purpose : Create a ChildIterator from an SObject
396 //============================================================================
397 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
399 SALOMEDS::Locker lock;
401 Handle(SALOMEDSImpl_SObject) aSO = _impl->GetSObject(theSO->GetID());
402 Handle(SALOMEDSImpl_ChildIterator) anItr = new SALOMEDSImpl_ChildIterator(aSO);
405 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
406 SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this());
412 //============================================================================
413 /*! Function : NewComponentIterator
414 * Purpose : Create a SComponentIterator
416 //============================================================================
417 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
419 SALOMEDS::Locker lock;
420 SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
426 //============================================================================
427 /*! Function : NewBuilder
428 * Purpose : Create a StudyBuilder
430 //============================================================================
431 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
433 SALOMEDS::Locker lock;
434 return _builder->_this();
437 //============================================================================
439 * Purpose : get study name
441 //============================================================================
442 char* SALOMEDS_Study_i::Name()
444 SALOMEDS::Locker lock;
445 return CORBA::string_dup(_impl->Name().ToCString());
448 //============================================================================
450 * Purpose : set study name
452 //============================================================================
453 void SALOMEDS_Study_i::Name(const char* name)
455 SALOMEDS::Locker lock;
456 _impl->Name(TCollection_AsciiString((char*)name));
459 //============================================================================
460 /*! Function : IsSaved
461 * Purpose : get if study has been saved
463 //============================================================================
464 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
466 SALOMEDS::Locker lock;
467 return _impl->IsSaved();
470 //============================================================================
471 /*! Function : IsSaved
472 * Purpose : set if study has been saved
474 //============================================================================
475 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
477 SALOMEDS::Locker lock;
478 _impl->IsSaved(save);
481 //============================================================================
482 /*! Function : IsModified
483 * Purpose : Detect if a Study has been modified since it has been saved
485 //============================================================================
486 CORBA::Boolean SALOMEDS_Study_i::IsModified()
488 SALOMEDS::Locker lock;
489 return _impl->IsModified();
492 //============================================================================
494 * Purpose : get URL of the study (persistent reference of the study)
496 //============================================================================
497 char* SALOMEDS_Study_i::URL()
499 SALOMEDS::Locker lock;
500 return CORBA::string_dup(_impl->URL().ToCString());
503 //============================================================================
505 * Purpose : set URL of the study (persistent reference of the study)
507 //============================================================================
508 void SALOMEDS_Study_i::URL(const char* url)
510 SALOMEDS::Locker lock;
511 _impl->URL(TCollection_AsciiString((char*)url));
515 CORBA::Short SALOMEDS_Study_i::StudyId()
517 SALOMEDS::Locker lock;
518 return _impl->StudyId();
521 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
523 SALOMEDS::Locker lock;
527 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
529 SALOMEDS::Locker lock;
530 _impl->UpdateIORLabelMap(TCollection_AsciiString((char*)anIOR), TCollection_AsciiString((char*)anEntry));
533 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb)
535 SALOMEDS::Locker lock;
537 Handle(SALOMEDSImpl_AttributeIOR) Att;
538 if (theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),Att)){
539 char* IOR = CORBA::string_dup(TCollection_AsciiString(Att->Value()).ToCString());
540 CORBA::Object_var obj = orb->string_to_object(IOR);
541 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
542 ASSERT(!CORBA::is_nil(aStudy));
543 return SALOMEDS::Study::_duplicate(aStudy);
545 MESSAGE("GetStudy: Problem to get study");
547 return SALOMEDS::Study::_nil();
550 void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR) theAttribute)
552 SALOMEDS::Locker lock;
553 SALOMEDSImpl_Study::IORUpdated(theAttribute);
556 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
558 SALOMEDS::Locker lock;
560 SALOMEDS::GenericAttribute_ptr aTarget;
561 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
562 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
564 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
570 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
572 SALOMEDS::Locker lock;
574 Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr = _impl->GetProperties();
575 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
576 return SP->AttributeStudyProperties::_this();
579 char* SALOMEDS_Study_i::GetLastModificationDate()
581 SALOMEDS::Locker lock;
582 return CORBA::string_dup(_impl->GetLastModificationDate().ToCString());
585 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
587 SALOMEDS::Locker lock;
589 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetModificationsDate();
590 int aLength = aSeq->Length();
591 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
592 aDates->length(aLength);
594 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
595 aDates[anIndex-1] = CORBA::string_dup(aSeq->Value(anIndex).ToCString());
597 return aDates._retn();
602 //============================================================================
603 /*! Function : GetUseCaseBuilder
604 * Purpose : Returns a UseCase builder
606 //============================================================================
607 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
609 SALOMEDS::Locker lock;
610 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
611 return UCBuilder->_this();
615 //============================================================================
619 //============================================================================
620 void SALOMEDS_Study_i::Close()
622 SALOMEDS::Locker lock;
626 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
628 for (; itcomponent->More(); itcomponent->Next()) {
629 SALOMEDS::SComponent_var sco = itcomponent->Value();
631 MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType());
632 // if there is an associated Engine call its method for closing
633 CORBA::String_var IOREngine;
634 if (sco->ComponentIOR(IOREngine)) {
635 // we have found the associated engine to write the data
636 MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType());
637 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
638 if (!CORBA::is_nil(obj)) {
639 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
641 if (!anEngine->_is_nil()) {
643 anEngine->Close(sco);
652 //============================================================================
653 /*! Function : AddPostponed
656 //============================================================================
657 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
659 SALOMEDS::Locker lock;
661 CORBA::Object_var obj = _orb->string_to_object(theIOR);
662 if (!CORBA::is_nil(obj)) {
663 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
664 if (!CORBA::is_nil(aGeneric)) _impl->AddPostponed((char*)theIOR);
668 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
670 SALOMEDS::Locker lock;
672 CORBA::Object_var obj = _orb->string_to_object(theIOR);
673 if (!CORBA::is_nil(obj)) {
674 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
675 if (!CORBA::is_nil(aGeneric)) _impl->AddCreatedPostponed((char*)theIOR);
679 //============================================================================
680 /*! Function : RemovePostponed
683 //============================================================================
685 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit)
687 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long theUndoLimit)
690 SALOMEDS::Locker lock;
692 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->RemovePostponed(theUndoLimit);
693 int aLegth = aSeq->Length();
694 for(int i = 1; i <= aLegth; i++) {
695 TCollection_AsciiString anIOR = aSeq->Value(i);
696 //mkr : fix for bug IPAL9408 : check the length of anIOR
697 // before take value from it
698 if ( !anIOR.IsEmpty() && anIOR.Value(1) == 'c') {
699 CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
700 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
701 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
703 else if ( !anIOR.IsEmpty() && anIOR.Value(1) == 'd') {
704 CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
705 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
706 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
710 CORBA::Object_var obj = _orb->string_to_object(anIOR.ToCString());
711 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
712 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
718 //============================================================================
719 /*! Function : UndoPostponed
722 //============================================================================
724 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
726 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
729 SALOMEDS::Locker lock;
731 _impl->UndoPostponed(theWay);
735 //============================================================================
736 /*! Function : DumpStudy
739 //============================================================================
740 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished)
742 SALOMEDS::Locker lock;
744 TCollection_AsciiString aPath((char*)thePath), aBaseName((char*)theBaseName);
745 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
746 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
751 //===========================================================================
753 //===========================================================================
754 long SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
757 long pid = (long)_getpid();
759 long pid = (long)getpid();
761 isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
762 SALOMEDSImpl_Study* local_impl = _impl.operator->();
763 return ((long)local_impl);