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/ or email : webmaster.salome@opencascade.com
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_AttributeParameter_i.hxx"
31 #include "SALOMEDS_ChildIterator_i.hxx"
32 #include "SALOMEDS_Driver_i.hxx"
33 #include "SALOMEDS.hxx"
35 #include "SALOMEDSImpl_SObject.hxx"
36 #include "SALOMEDSImpl_SComponent.hxx"
37 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
38 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
39 #include "SALOMEDSImpl_AttributeParameter.hxx"
40 #include "SALOMEDSImpl_ChildIterator.hxx"
41 #include "SALOMEDSImpl_IParameters.hxx"
43 #include <TColStd_SequenceOfExtendedString.hxx>
44 #include <TColStd_HSequenceOfAsciiString.hxx>
45 #include <TColStd_HSequenceOfTransient.hxx>
46 #include <TCollection_AsciiString.hxx>
47 #include <TCollection_ExtendedString.hxx>
49 #include <TDF_Label.hxx>
50 #include <TDF_Attribute.hxx>
55 #include <sys/types.h>
63 //============================================================================
64 /*! Function : SALOMEDS_Study_i
65 * Purpose : SALOMEDS_Study_i constructor
67 //============================================================================
68 SALOMEDS_Study_i::SALOMEDS_Study_i(const Handle(SALOMEDSImpl_Study) theImpl,
71 _orb = CORBA::ORB::_duplicate(orb);
74 _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);
77 //============================================================================
78 /*! Function : ~SALOMEDS_Study_i
79 * Purpose : SALOMEDS_Study_i destructor
81 //============================================================================
82 SALOMEDS_Study_i::~SALOMEDS_Study_i()
86 //============================================================================
87 /*! Function : GetPersistentReference
88 * Purpose : Get persistent reference of study (idem URL())
90 //============================================================================
91 char* SALOMEDS_Study_i::GetPersistentReference()
93 SALOMEDS::Locker lock;
94 return CORBA::string_dup(_impl->GetPersistentReference().ToCString());
96 //============================================================================
97 /*! Function : GetTransientReference
98 * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root)
100 //============================================================================
101 char* SALOMEDS_Study_i::GetTransientReference()
103 SALOMEDS::Locker lock;
104 return CORBA::string_dup(_impl->GetTransientReference().ToCString());
107 //============================================================================
108 /*! Function : IsEmpty
109 * Purpose : Detect if study is empty
111 //============================================================================
112 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
114 SALOMEDS::Locker lock;
115 return _impl->IsEmpty();
118 //============================================================================
119 /*! Function : FindComponent
120 * Purpose : Find a Component with ComponentDataType = aComponentName
122 //============================================================================
123 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
125 SALOMEDS::Locker lock;
127 Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponent(TCollection_AsciiString((char*)aComponentName));
128 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
130 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
134 //============================================================================
135 /*! Function : FindComponentID
136 * Purpose : Find a Component from it's ID
138 //============================================================================
139 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
141 SALOMEDS::Locker lock;
143 Handle(SALOMEDSImpl_SComponent) aCompImpl = _impl->FindComponentID(TCollection_AsciiString((char*)aComponentID));
144 if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
146 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
150 //============================================================================
151 /*! Function : FindObject
152 * Purpose : Find an Object with SALOMEDS::Name = anObjectName
154 //============================================================================
155 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
157 SALOMEDS::Locker lock;
159 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObject(TCollection_AsciiString((char*)anObjectName));
160 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
162 if(aSO->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_SComponent)) {
163 Handle(SALOMEDSImpl_SComponent) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO);
164 SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
168 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
173 //============================================================================
174 /*! Function : FindObjectID
175 * Purpose : Find an Object with ID = anObjectID
177 //============================================================================
178 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
180 SALOMEDS::Locker lock;
182 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectID(TCollection_AsciiString((char*)anObjectID));
183 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
184 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
188 //============================================================================
189 /*! Function : CreateObjectID
190 * Purpose : Creates an Object with ID = anObjectID
192 //============================================================================
193 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
195 SALOMEDS::Locker lock;
197 Handle(SALOMEDSImpl_SObject) aSO = _impl->CreateObjectID((char*)anObjectID);
198 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
200 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
204 //============================================================================
205 /*! Function : FindObjectByName
206 * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component
207 * : with ComponentDataType = aComponentName
209 //============================================================================
210 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
211 const char* aComponentName )
213 SALOMEDS::Locker lock;
215 Handle(TColStd_HSequenceOfTransient) aSeq = _impl->FindObjectByName(TCollection_AsciiString((char*)anObjectName),
216 TCollection_AsciiString((char*)aComponentName));
217 int aLength = aSeq->Length();
218 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
219 listSO->length(aLength);
220 for(int i = 1; i<=aLength; i++) {
221 Handle(SALOMEDSImpl_SObject) aSO = Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i));
222 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
225 return listSO._retn() ;
228 //============================================================================
229 /*! Function : FindObjectIOR
230 * Purpose : Find an Object with IOR = anObjectIOR
232 //============================================================================
233 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
235 SALOMEDS::Locker lock;
237 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectIOR(TCollection_AsciiString((char*)anObjectIOR));
238 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
240 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
244 //============================================================================
245 /*! Function : FindObjectByPath
246 * Purpose : Find an Object by its path = thePath
248 //============================================================================
249 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
251 SALOMEDS::Locker lock;
253 Handle(SALOMEDSImpl_SObject) aSO = _impl->FindObjectByPath(TCollection_AsciiString((char*)thePath));
254 if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
256 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
260 //============================================================================
261 /*! Function : GetObjectPath
264 //============================================================================
265 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
267 SALOMEDS::Locker lock;
269 TCollection_AsciiString aPath("");
270 if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.ToCString());
271 Handle(SALOMEDSImpl_SObject) aSO;
272 SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
274 if(!CORBA::is_nil(aSObj)) {
275 aSO = _impl->FindObjectID(aSObj->GetID());
278 CORBA::String_var objStr = _orb->object_to_string(theObject);
279 TCollection_AsciiString anAscii((char *)objStr.in());
280 aSO = _impl->FindObjectIOR(anAscii);
283 if(aSO.IsNull()) return CORBA::string_dup(aPath.ToCString());
285 aPath = _impl->GetObjectPath(aSO);
286 return CORBA::string_dup(aPath.ToCString());
290 //============================================================================
291 /*! Function : SetContext
292 * Purpose : Sets the current context
294 //============================================================================
295 void SALOMEDS_Study_i::SetContext(const char* thePath)
297 SALOMEDS::Locker lock;
299 _impl->SetContext(TCollection_AsciiString((char*)thePath));
300 if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext")
301 throw SALOMEDS::Study::StudyInvalidContext();
304 //============================================================================
305 /*! Function : GetContext
306 * Purpose : Gets the current context
308 //============================================================================
309 char* SALOMEDS_Study_i::GetContext()
311 SALOMEDS::Locker lock;
313 if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();
314 return CORBA::string_dup(_impl->GetContext().ToCString());
317 //============================================================================
318 /*! Function : GetObjectNames
319 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
321 //============================================================================
322 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext)
324 SALOMEDS::Locker lock;
326 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
328 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
329 throw SALOMEDS::Study::StudyInvalidContext();
331 Handle(TColStd_HSequenceOfAsciiString) aSeq =
332 _impl->GetObjectNames(TCollection_AsciiString((char*)theContext));
333 if (_impl->GetErrorCode() == "InvalidContext")
334 throw SALOMEDS::Study::StudyInvalidContext();
336 int aLength = aSeq->Length();
337 aResult->length(aLength);
338 for (int anIndex = 1; anIndex <= aLength; anIndex++) {
339 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
342 return aResult._retn();
345 //============================================================================
346 /*! Function : GetDirectoryNames
347 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
349 //============================================================================
350 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext)
352 SALOMEDS::Locker lock;
354 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
356 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
357 throw SALOMEDS::Study::StudyInvalidContext();
359 Handle(TColStd_HSequenceOfAsciiString) aSeq =
360 _impl->GetDirectoryNames(TCollection_AsciiString((char*)theContext));
361 if (_impl->GetErrorCode() == "InvalidContext")
362 throw SALOMEDS::Study::StudyInvalidContext();
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());
370 return aResult._retn();
373 //============================================================================
374 /*! Function : GetFileNames
375 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
377 //============================================================================
378 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext)
380 SALOMEDS::Locker lock;
382 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
384 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
385 throw SALOMEDS::Study::StudyInvalidContext();
387 Handle(TColStd_HSequenceOfAsciiString) aSeq =
388 _impl->GetFileNames(TCollection_AsciiString((char*)theContext));
389 if (_impl->GetErrorCode() == "InvalidContext")
390 throw SALOMEDS::Study::StudyInvalidContext();
392 int aLength = aSeq->Length();
393 aResult->length(aLength);
394 for (int anIndex = 1; anIndex <= aLength; anIndex++) {
395 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
398 return aResult._retn();
401 //============================================================================
402 /*! Function : GetComponentNames
403 * Purpose : method to get all components names
405 //============================================================================
406 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
408 SALOMEDS::Locker lock;
410 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
412 if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
413 throw SALOMEDS::Study::StudyInvalidContext();
415 Handle(TColStd_HSequenceOfAsciiString) aSeq =
416 _impl->GetComponentNames(TCollection_AsciiString((char*)theContext));
418 int aLength = aSeq->Length();
419 aResult->length(aLength);
420 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
421 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
424 return aResult._retn();
427 //============================================================================
428 /*! Function : NewChildIterator
429 * Purpose : Create a ChildIterator from an SObject
431 //============================================================================
432 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
434 SALOMEDS::Locker lock;
436 Handle(SALOMEDSImpl_SObject) aSO = _impl->GetSObject(theSO->GetID());
437 Handle(SALOMEDSImpl_ChildIterator) anItr = new SALOMEDSImpl_ChildIterator(aSO);
440 SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
441 SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this());
447 //============================================================================
448 /*! Function : NewComponentIterator
449 * Purpose : Create a SComponentIterator
451 //============================================================================
452 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
454 SALOMEDS::Locker lock;
455 SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
461 //============================================================================
462 /*! Function : NewBuilder
463 * Purpose : Create a StudyBuilder
465 //============================================================================
466 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
468 SALOMEDS::Locker lock;
469 return _builder->_this();
472 //============================================================================
474 * Purpose : get study name
476 //============================================================================
477 char* SALOMEDS_Study_i::Name()
479 SALOMEDS::Locker lock;
480 return CORBA::string_dup(_impl->Name().ToCString());
483 //============================================================================
485 * Purpose : set study name
487 //============================================================================
488 void SALOMEDS_Study_i::Name(const char* name)
490 SALOMEDS::Locker lock;
491 _impl->Name(TCollection_AsciiString((char*)name));
494 //============================================================================
495 /*! Function : IsSaved
496 * Purpose : get if study has been saved
498 //============================================================================
499 CORBA::Boolean SALOMEDS_Study_i::IsSaved()
501 SALOMEDS::Locker lock;
502 return _impl->IsSaved();
505 //============================================================================
506 /*! Function : IsSaved
507 * Purpose : set if study has been saved
509 //============================================================================
510 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
512 SALOMEDS::Locker lock;
513 _impl->IsSaved(save);
516 //============================================================================
517 /*! Function : IsModified
518 * Purpose : Detect if a Study has been modified since it has been saved
520 //============================================================================
521 CORBA::Boolean SALOMEDS_Study_i::IsModified()
523 SALOMEDS::Locker lock;
524 return _impl->IsModified();
527 //============================================================================
529 * Purpose : get URL of the study (persistent reference of the study)
531 //============================================================================
532 char* SALOMEDS_Study_i::URL()
534 SALOMEDS::Locker lock;
535 return CORBA::string_dup(_impl->URL().ToCString());
538 //============================================================================
540 * Purpose : set URL of the study (persistent reference of the study)
542 //============================================================================
543 void SALOMEDS_Study_i::URL(const char* url)
545 SALOMEDS::Locker lock;
546 _impl->URL(TCollection_AsciiString((char*)url));
550 CORBA::Short SALOMEDS_Study_i::StudyId()
552 SALOMEDS::Locker lock;
553 return _impl->StudyId();
556 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
558 SALOMEDS::Locker lock;
562 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry)
564 SALOMEDS::Locker lock;
565 _impl->UpdateIORLabelMap(TCollection_AsciiString((char*)anIOR), TCollection_AsciiString((char*)anEntry));
568 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb)
570 SALOMEDS::Locker lock;
572 Handle(SALOMEDSImpl_AttributeIOR) Att;
573 if (theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),Att)){
574 char* IOR = CORBA::string_dup(TCollection_AsciiString(Att->Value()).ToCString());
575 CORBA::Object_var obj = orb->string_to_object(IOR);
576 SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
577 ASSERT(!CORBA::is_nil(aStudy));
578 return SALOMEDS::Study::_duplicate(aStudy);
580 MESSAGE("GetStudy: Problem to get study");
582 return SALOMEDS::Study::_nil();
585 void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR) theAttribute)
587 SALOMEDS::Locker lock;
588 SALOMEDSImpl_Study::IORUpdated(theAttribute);
591 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject)
593 SALOMEDS::Locker lock;
595 SALOMEDS::GenericAttribute_ptr aTarget;
596 if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
597 return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
599 SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
605 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties()
607 SALOMEDS::Locker lock;
609 Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr = _impl->GetProperties();
610 SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
611 return SP->AttributeStudyProperties::_this();
614 char* SALOMEDS_Study_i::GetLastModificationDate()
616 SALOMEDS::Locker lock;
617 return CORBA::string_dup(_impl->GetLastModificationDate().ToCString());
620 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate()
622 SALOMEDS::Locker lock;
624 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetModificationsDate();
625 int aLength = aSeq->Length();
626 SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
627 aDates->length(aLength);
629 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
630 aDates[anIndex-1] = CORBA::string_dup(aSeq->Value(anIndex).ToCString());
632 return aDates._retn();
637 //============================================================================
638 /*! Function : GetUseCaseBuilder
639 * Purpose : Returns a UseCase builder
641 //============================================================================
642 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder()
644 SALOMEDS::Locker lock;
645 SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
646 return UCBuilder->_this();
650 //============================================================================
654 //============================================================================
655 void SALOMEDS_Study_i::Close()
657 SALOMEDS::Locker lock;
661 SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
663 for (; itcomponent->More(); itcomponent->Next()) {
664 SALOMEDS::SComponent_var sco = itcomponent->Value();
666 MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType());
667 // if there is an associated Engine call its method for closing
668 CORBA::String_var IOREngine;
669 if (sco->ComponentIOR(IOREngine)) {
670 // we have found the associated engine to write the data
671 MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType());
672 CORBA::Object_var obj = _orb->string_to_object(IOREngine);
673 if (!CORBA::is_nil(obj)) {
674 SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
676 if (!anEngine->_is_nil()) {
678 anEngine->Close(sco);
687 //============================================================================
688 /*! Function : AddPostponed
691 //============================================================================
692 void SALOMEDS_Study_i::AddPostponed(const char* theIOR)
694 SALOMEDS::Locker lock;
696 CORBA::Object_var obj = _orb->string_to_object(theIOR);
697 if (!CORBA::is_nil(obj)) {
698 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
699 if (!CORBA::is_nil(aGeneric)) _impl->AddPostponed((char*)theIOR);
703 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR)
705 SALOMEDS::Locker lock;
707 CORBA::Object_var obj = _orb->string_to_object(theIOR);
708 if (!CORBA::is_nil(obj)) {
709 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
710 if (!CORBA::is_nil(aGeneric)) _impl->AddCreatedPostponed((char*)theIOR);
714 //============================================================================
715 /*! Function : RemovePostponed
718 //============================================================================
720 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit)
722 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long theUndoLimit)
725 SALOMEDS::Locker lock;
727 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->RemovePostponed(theUndoLimit);
728 int aLegth = aSeq->Length();
729 for(int i = 1; i <= aLegth; i++) {
730 TCollection_AsciiString anIOR = aSeq->Value(i);
731 //mkr : fix for bug IPAL9408 : check the length of anIOR
732 // before take value from it
733 if ( !anIOR.IsEmpty() && anIOR.Value(1) == 'c') {
734 CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
735 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
736 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
738 else if ( !anIOR.IsEmpty() && anIOR.Value(1) == 'd') {
739 CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
740 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
741 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
745 CORBA::Object_var obj = _orb->string_to_object(anIOR.ToCString());
746 SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
747 if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
753 //============================================================================
754 /*! Function : UndoPostponed
757 //============================================================================
759 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay)
761 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay)
764 SALOMEDS::Locker lock;
766 _impl->UndoPostponed(theWay);
770 //============================================================================
771 /*! Function : DumpStudy
774 //============================================================================
775 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
776 const char* theBaseName,
777 CORBA::Boolean isPublished)
779 SALOMEDS::Locker lock;
781 TCollection_AsciiString aPath((char*)thePath), aBaseName((char*)theBaseName);
782 SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
783 CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory);
788 //============================================================================
789 /*! Function : GetCommonParameters
792 //============================================================================
793 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
795 SALOMEDS::Locker lock;
797 Handle(SALOMEDSImpl_AttributeParameter) anAttr = _impl->GetCommonParameters(theID, theSavePoint);
798 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
799 return SP->AttributeParameter::_this();
802 //============================================================================
803 /*! Function : GetCommonModuleParameters
806 //============================================================================
807 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
808 const char* theModuleName,
809 CORBA::Long theSavePoint)
811 SALOMEDS::Locker lock;
813 Handle(SALOMEDSImpl_AttributeParameter) anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
814 SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
815 return SP->AttributeParameter::_this();
818 //============================================================================
819 /*! Function : SetStudyLock
822 //============================================================================
823 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
825 SALOMEDS::Locker lock;
826 _impl->SetStudyLock(theLockerID);
829 //============================================================================
830 /*! Function : IsStudyLocked
833 //============================================================================
834 bool SALOMEDS_Study_i::IsStudyLocked()
836 SALOMEDS::Locker lock;
837 return _impl->IsStudyLocked();
840 //============================================================================
841 /*! Function : UnLockStudy
844 //============================================================================
845 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
847 SALOMEDS::Locker lock;
848 _impl->UnLockStudy(theLockerID);
851 //============================================================================
852 /*! Function : GetLockerID
855 //============================================================================
856 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
858 SALOMEDS::Locker lock;
860 SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
862 Handle(TColStd_HSequenceOfAsciiString) aSeq = _impl->GetLockerID();
864 int aLength = aSeq->Length();
865 aResult->length(aLength);
866 for(int anIndex = 1; anIndex <= aLength; anIndex++) {
867 aResult[anIndex-1] = CORBA::string_dup(TCollection_AsciiString(aSeq->Value(anIndex)).ToCString());
869 return aResult._retn();
872 //============================================================================
873 /*! Function : GetDefaultScript
876 //============================================================================
877 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
879 SALOMEDS::Locker lock;
881 string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
882 return CORBA::string_dup(script.c_str());
885 //===========================================================================
887 //===========================================================================
888 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
891 long pid = (long)_getpid();
893 long pid = (long)getpid();
895 isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
896 SALOMEDSImpl_Study* local_impl = _impl.operator->();
897 return ((CORBA::LongLong)local_impl);