Salome HOME
Implemented method Modified() for SALOMEDS_Study that marks the Study as being modified.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDS_Study.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25
26 #include "utilities.h" 
27
28 #include "SALOMEDS_Study.hxx"
29
30 #include "SALOMEDS.hxx"
31 #include "SALOMEDS_SComponent.hxx"
32 #include "SALOMEDS_SObject.hxx"
33 #include "SALOMEDS_StudyBuilder.hxx"
34 #include "SALOMEDS_ChildIterator.hxx"
35 #include "SALOMEDS_SComponentIterator.hxx"
36 #include "SALOMEDS_AttributeStudyProperties.hxx"
37 #include "SALOMEDS_AttributeParameter.hxx"
38 #include "SALOMEDS_UseCaseBuilder.hxx"
39
40 #include "SALOMEDSImpl_SComponent.hxx"
41 #include "SALOMEDSImpl_SObject.hxx"
42 #include "SALOMEDSImpl_StudyBuilder.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_SComponentIterator.hxx"
45 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
46 #include "SALOMEDSImpl_AttributeParameter.hxx"
47 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
48
49 #include "SALOMEDS_Driver_i.hxx"
50 #include "SALOMEDS_Study_i.hxx"
51
52 #include <TCollection_AsciiString.hxx> 
53 #include <TColStd_HSequenceOfAsciiString.hxx>
54 #include <TColStd_HSequenceOfTransient.hxx>
55
56 #include "Utils_ORB_INIT.hxx" 
57 #include "Utils_SINGLETON.hxx" 
58
59 #ifdef WIN32
60 #include <process.h>
61 #else
62 #include <sys/types.h>
63 #include <unistd.h>
64 #endif
65
66 #include "OpUtil.hxx"
67
68 using namespace std; 
69
70 SALOMEDS_Study::SALOMEDS_Study(const Handle(SALOMEDSImpl_Study)& theStudy)
71 {
72   _isLocal = true;
73   _local_impl = theStudy;
74   _corba_impl = SALOMEDS::Study::_nil();
75   init_orb();
76 }
77
78 SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
79 {
80 #ifdef WIN32
81   long pid =  (long)_getpid();
82 #else
83   long pid =  (long)getpid();
84 #endif  
85
86   long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
87   if(_isLocal) {
88     _local_impl = ((SALOMEDSImpl_Study*)(addr));
89     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
90   }
91   else {
92     _local_impl = NULL;
93     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
94   }
95
96   init_orb();
97 }
98
99 SALOMEDS_Study::~SALOMEDS_Study()
100 {
101 }
102
103 std::string SALOMEDS_Study::GetPersistentReference()
104 {
105   std::string aRef;
106   if (_isLocal) {
107     SALOMEDS::Locker lock;
108     aRef = _local_impl->GetPersistentReference().ToCString();
109   }
110   else aRef = _corba_impl->GetPersistentReference();
111   return aRef;
112 }
113
114 std::string SALOMEDS_Study::GetTransientReference()
115 {
116   std::string aRef;
117   if (_isLocal) {
118     SALOMEDS::Locker lock;
119     aRef = _local_impl->GetTransientReference().ToCString();
120   }
121   else aRef = _corba_impl->GetTransientReference();
122   return aRef;
123 }
124  
125 bool SALOMEDS_Study::IsEmpty()
126 {
127   bool ret;
128   if (_isLocal) {
129     SALOMEDS::Locker lock;
130     ret = _local_impl->IsEmpty();
131   }
132   else ret = _corba_impl->IsEmpty();
133   return ret;
134 }
135
136 _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName)
137 {
138   SALOMEDSClient_SComponent* aSCO = NULL;
139   if (_isLocal) {
140     SALOMEDS::Locker lock;
141
142     Handle(SALOMEDSImpl_SComponent) aSCO_impl =
143       _local_impl->FindComponent((char*)aComponentName.c_str());
144     if (aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
145     aSCO = new SALOMEDS_SComponent(aSCO_impl);
146   }
147   else {
148     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str());
149     if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
150     aSCO = new SALOMEDS_SComponent(aSCO_impl);
151   }
152   return _PTR(SComponent)(aSCO);
153 }
154  
155 _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID)
156 {  
157   SALOMEDSClient_SComponent* aSCO = NULL;
158   if (_isLocal) {
159     SALOMEDS::Locker lock;
160
161     Handle(SALOMEDSImpl_SComponent) aSCO_impl =
162       _local_impl->FindComponentID((char*)aComponentID.c_str());
163     if (aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO);
164     aSCO = new SALOMEDS_SComponent(aSCO_impl);
165   }
166   else {
167     SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID((char*)aComponentID.c_str());
168     if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO);
169     aSCO = new SALOMEDS_SComponent(aSCO_impl);
170   }
171   return _PTR(SComponent)(aSCO);
172 }
173  
174 _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName)
175 {
176   SALOMEDSClient_SObject* aSO = NULL;
177
178   if (_isLocal) {
179     SALOMEDS::Locker lock;
180
181     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject((char*)anObjectName.c_str());
182     if (aSO_impl.IsNull()) return _PTR(SObject)(aSO);
183     Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO_impl);
184     if (!aSCO_impl.IsNull()) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
185     aSO = new SALOMEDS_SObject(aSO_impl);
186   }
187   else { 
188     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
189     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
190     SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
191     if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl));
192     aSO = new SALOMEDS_SObject(aSO_impl);
193   }
194
195   return _PTR(SObject)(aSO);
196 }
197
198 std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName, 
199                                                             const std::string& aComponentName)   
200 {
201   std::vector<_PTR(SObject)> aVector;
202   int i, aLength = 0;
203
204   if (_isLocal) {
205     SALOMEDS::Locker lock;
206
207     Handle(TColStd_HSequenceOfTransient) aSeq =
208       _local_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str());
209     aLength = aSeq->Length();
210     for (i = 1; i<= aLength; i++) 
211       aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject
212                                       (Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
213   }
214   else {
215     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(), 
216                                                                             (char*)aComponentName.c_str());
217     aLength = aSeq->length();
218     for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
219   }
220
221   return aVector;
222 }
223
224 _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
225 {
226   SALOMEDSClient_SObject* aSO = NULL;
227   if (_isLocal) {
228     SALOMEDS::Locker lock;
229
230     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID((char*)anObjectID.c_str());
231     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
232     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
233   }
234   else { 
235     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
236     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
237     return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl));
238   }
239   return _PTR(SObject)(aSO);
240 }
241  
242 _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
243 {
244   SALOMEDSClient_SObject* aSO = NULL;
245   if (_isLocal) {
246     SALOMEDS::Locker lock;
247     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->CreateObjectID((char*)anObjectID.c_str());
248     if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
249     aSO = new SALOMEDS_SObject(aSO_impl);
250   }
251   else { 
252     SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
253     if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
254     aSO = new SALOMEDS_SObject(aSO_impl);
255   }
256   return _PTR(SObject)(aSO);
257 }
258
259 _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR)
260 {
261   SALOMEDSClient_SObject* aSO = NULL;
262   if (_isLocal) {
263     SALOMEDS::Locker lock;
264
265     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectIOR((char*)anObjectIOR.c_str());
266     if (aSO_impl.IsNull()) return _PTR(SObject)(aSO);
267     aSO = new SALOMEDS_SObject(aSO_impl);
268   }
269   else { 
270     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str());
271     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
272     aSO = new SALOMEDS_SObject(aSO_impl);
273   }
274   return _PTR(SObject)(aSO);
275 }
276
277 _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath)
278 {
279   SALOMEDSClient_SObject* aSO = NULL;
280   if (_isLocal) {
281     SALOMEDS::Locker lock;
282
283     Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectByPath((char*)thePath.c_str());
284     if (aSO_impl.IsNull()) return _PTR(SObject)(aSO);
285     aSO = new SALOMEDS_SObject(aSO_impl);
286   }
287   else {
288     SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str());
289     if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
290     aSO = new SALOMEDS_SObject(aSO_impl);
291   }
292   return _PTR(SObject)(aSO);
293 }
294
295 std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
296 {
297   if(!theSO) return "";
298   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
299   std::string aPath;
300   if (_isLocal) {
301     SALOMEDS::Locker lock;
302     aPath = _local_impl->GetObjectPath(aSO->GetLocalImpl()).ToCString();
303   }
304   else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl());
305   return aPath;
306 }
307
308 void SALOMEDS_Study::SetContext(const std::string& thePath)
309 {
310   if (_isLocal) {
311     SALOMEDS::Locker lock;
312     _local_impl->SetContext((char*)thePath.c_str());
313   }
314   else _corba_impl->SetContext((char*)thePath.c_str());
315 }
316
317 std::string SALOMEDS_Study::GetContext()  
318 {
319   std::string aPath;
320   if (_isLocal) {
321     SALOMEDS::Locker lock;
322     aPath = _local_impl->GetContext().ToCString();
323   }
324   else aPath = _corba_impl->GetContext();
325   return aPath;
326 }
327
328 std::vector<std::string> SALOMEDS_Study::GetObjectNames(const std::string& theContext)
329 {
330   std::vector<std::string> aVector;
331   int aLength, i;
332   if (_isLocal) {
333     SALOMEDS::Locker lock;
334
335     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetObjectNames((char*)theContext.c_str());
336     aLength = aSeq->Length();
337     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
338   }
339   else {
340     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str());
341     aLength = aSeq->length();
342     for (i = 0; i < aLength; i++) aVector.push_back(std::string((std::string)aSeq[i].in()));
343   }
344   return aVector;
345 }
346  
347 std::vector<std::string> SALOMEDS_Study::GetDirectoryNames(const std::string& theContext)
348 {
349   std::vector<std::string> aVector;
350   int aLength, i;
351   if (_isLocal) {
352     SALOMEDS::Locker lock;
353
354     Handle(TColStd_HSequenceOfAsciiString) aSeq =
355       _local_impl->GetDirectoryNames((char*)theContext.c_str());
356     aLength = aSeq->Length();
357     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
358   }
359   else {
360     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str());
361     aLength = aSeq->length();
362     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
363   }
364   return aVector;
365 }
366  
367 std::vector<std::string> SALOMEDS_Study::GetFileNames(const std::string& theContext)
368 {
369   std::vector<std::string> aVector;
370   int aLength, i;
371   if (_isLocal) {
372     SALOMEDS::Locker lock;
373
374     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetFileNames((char*)theContext.c_str());
375     aLength = aSeq->Length();
376     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
377   }
378   else {
379     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str());
380     aLength = aSeq->length();
381
382     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
383   }
384   return aVector;
385 }
386  
387 std::vector<std::string> SALOMEDS_Study::GetComponentNames(const std::string& theContext)
388 {
389   std::vector<std::string> aVector;
390   int aLength, i;
391   if (_isLocal) {
392     SALOMEDS::Locker lock;
393
394     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetComponentNames((char*)theContext.c_str());
395     aLength = aSeq->Length();
396     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
397   }
398   else {
399     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str());
400     aLength = aSeq->length();
401     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
402   }
403   return aVector;
404 }
405
406 _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO)
407 {
408   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
409   SALOMEDSClient_ChildIterator* aCI = NULL; 
410   if (_isLocal) {
411     SALOMEDS::Locker lock;
412
413     Handle(SALOMEDSImpl_ChildIterator) aCIimpl = _local_impl->NewChildIterator(aSO->GetLocalImpl());
414     aCI = new SALOMEDS_ChildIterator(aCIimpl);
415   }
416   else {
417     SALOMEDS::ChildIterator_var aCIimpl = _corba_impl->NewChildIterator(aSO->GetCORBAImpl());
418     aCI = new SALOMEDS_ChildIterator(aCIimpl);
419   }
420
421   return _PTR(ChildIterator)(aCI);
422 }
423
424 _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator()
425 {
426   SALOMEDSClient_SComponentIterator* aCI = NULL; 
427   if (_isLocal) {
428     SALOMEDS::Locker lock;
429
430     SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator();
431     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
432   }
433   else {
434     SALOMEDS::SComponentIterator_var aCIimpl = _corba_impl->NewComponentIterator();
435     aCI = new SALOMEDS_SComponentIterator(aCIimpl);
436   }
437
438   return _PTR(SComponentIterator)(aCI);
439 }
440
441 _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder()
442 {
443   SALOMEDSClient_StudyBuilder* aSB = NULL; 
444   if (_isLocal) {
445     SALOMEDS::Locker lock;
446
447     Handle(SALOMEDSImpl_StudyBuilder) aSBimpl = _local_impl->NewBuilder();
448     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
449   }
450   else {
451     SALOMEDS::StudyBuilder_var aSBimpl = _corba_impl->NewBuilder();
452     aSB = new SALOMEDS_StudyBuilder(aSBimpl);
453   }
454
455   return _PTR(StudyBuilder)(aSB);
456 }
457
458 std::string SALOMEDS_Study::Name()
459 {
460   std::string aName;
461   if (_isLocal) {
462     SALOMEDS::Locker lock;
463     aName = _local_impl->Name().ToCString();
464   }
465   else aName = _corba_impl->Name();
466   return aName;
467 }
468
469 void SALOMEDS_Study::Name(const std::string& theName)
470 {
471   if (_isLocal) {
472     SALOMEDS::Locker lock;
473     _local_impl->Name((char*)theName.c_str());
474   }
475   else _corba_impl->Name((char*)theName.c_str());
476 }
477
478 bool SALOMEDS_Study::IsSaved()
479 {
480   bool isSaved;
481   if (_isLocal) {
482     SALOMEDS::Locker lock;
483     isSaved = _local_impl->IsSaved();
484   }
485   else isSaved = _corba_impl->IsSaved();
486   return isSaved;
487 }
488
489 void SALOMEDS_Study::IsSaved(bool save)
490 {
491   if (_isLocal) {
492     SALOMEDS::Locker lock;
493     _local_impl->IsSaved(save);
494   }
495   else _corba_impl->IsSaved(save);
496 }
497
498 bool SALOMEDS_Study::IsModified()
499 {
500   bool isModified;
501   if (_isLocal) {
502     SALOMEDS::Locker lock;
503     isModified = _local_impl->IsModified();
504   }
505   else isModified = _corba_impl->IsModified();
506   return isModified;
507 }
508
509 void SALOMEDS_Study::Modified()
510 {
511   if (_isLocal) {
512     SALOMEDS::Locker lock;
513     _local_impl->Modify();
514   }
515   else _corba_impl->IsModified();
516 }
517
518  
519 std::string SALOMEDS_Study::URL()
520 {
521   std::string aURL;
522   if (_isLocal) {
523     SALOMEDS::Locker lock;
524     aURL = _local_impl->URL().ToCString();
525   }
526   else aURL = _corba_impl->URL();
527   return aURL;
528 }
529
530 void SALOMEDS_Study::URL(const std::string& url)
531 {
532   if (_isLocal) {
533     SALOMEDS::Locker lock;
534     _local_impl->URL((char*)url.c_str());
535   }
536   else _corba_impl->URL((char*)url.c_str());
537 }
538
539 int SALOMEDS_Study::StudyId()
540 {
541   int anID;
542   if (_isLocal) {
543     SALOMEDS::Locker lock;
544     anID = _local_impl->StudyId();
545   }
546   else anID = _corba_impl->StudyId();
547   return anID;
548 }
549  
550 void SALOMEDS_Study::StudyId(int id) 
551 {
552   if (_isLocal) {
553     SALOMEDS::Locker lock;
554     _local_impl->StudyId(id);
555   }
556   else _corba_impl->StudyId(id);  
557 }
558
559 std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& theSO)
560 {
561   std::vector<_PTR(SObject)> aVector;
562   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
563   int aLength, i;
564   if (_isLocal) {
565     SALOMEDS::Locker lock;
566
567     Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindDependances(aSO->GetLocalImpl());
568     if (!aSeq.IsNull()) {
569       aLength = aSeq->Length();
570       for (i = 1; i <= aLength; i++) 
571         aVector.push_back(_PTR(SObject)(
572           new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)))));
573     }
574   }
575   else {
576     SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl());
577     aLength = aSeq->length();
578     for (i = 0; i < aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i])));
579   }
580   return aVector;
581 }
582  
583 _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties()
584 {
585   SALOMEDSClient_AttributeStudyProperties* aProp;
586   if (_isLocal) {
587     SALOMEDS::Locker lock;
588     aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties());
589   }
590   else aProp = new SALOMEDS_AttributeStudyProperties(_corba_impl->GetProperties());
591   return _PTR(AttributeStudyProperties)(aProp);
592 }
593  
594 std::string SALOMEDS_Study::GetLastModificationDate() 
595 {
596   std::string aDate;
597   if (_isLocal) {
598     SALOMEDS::Locker lock;
599     aDate = _local_impl->GetLastModificationDate().ToCString();
600   }
601   else aDate = _corba_impl->GetLastModificationDate();
602   return aDate;
603 }
604
605 std::vector<std::string> SALOMEDS_Study::GetModificationsDate()
606 {
607   std::vector<std::string> aVector;
608   int aLength, i;
609   if (_isLocal) {
610     SALOMEDS::Locker lock;
611
612     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetModificationsDate();
613     aLength = aSeq->Length();
614     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
615   }
616   else {
617     SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate();
618     aLength = aSeq->length();
619     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
620   }
621   return aVector;
622 }
623
624 _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder()
625 {
626   SALOMEDSClient_UseCaseBuilder* aUB = NULL;
627   if (_isLocal) {
628     SALOMEDS::Locker lock;
629
630     Handle(SALOMEDSImpl_UseCaseBuilder) aUBimpl = _local_impl->GetUseCaseBuilder();
631     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
632   }
633   else {
634     SALOMEDS::UseCaseBuilder_var aUBimpl = _corba_impl->GetUseCaseBuilder();
635     aUB = new SALOMEDS_UseCaseBuilder(aUBimpl);
636   }
637
638   return _PTR(UseCaseBuilder)(aUB);
639 }
640
641 void SALOMEDS_Study::Close()
642 {
643   if (_isLocal) {
644     SALOMEDS::Locker lock;
645     _local_impl->Close();
646   }
647   else _corba_impl->Close();
648 }
649
650 void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled)
651 {
652   if(_isLocal) _local_impl->EnableUseCaseAutoFilling(isEnabled);
653   else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
654 }
655
656 bool SALOMEDS_Study::DumpStudy(const string& thePath, const string& theBaseName, bool isPublished)
657 {
658   //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
659   if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
660   bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished);
661   return ret;
662 }     
663
664 void SALOMEDS_Study::SetStudyLock(const string& theLockerID)
665 {
666   if (_isLocal) {
667     SALOMEDS::Locker lock;
668     _local_impl->SetStudyLock((char*)theLockerID.c_str());
669   }
670   else _corba_impl->SetStudyLock((char*)theLockerID.c_str());
671 }
672  
673 bool SALOMEDS_Study::IsStudyLocked()
674 {
675   bool isLocked;
676   if (_isLocal) {
677     SALOMEDS::Locker lock;
678     isLocked = _local_impl->IsStudyLocked();
679   }
680   else isLocked = _corba_impl->IsStudyLocked();
681   return isLocked;
682 }
683  
684 void SALOMEDS_Study::UnLockStudy(const string& theLockerID)
685 {
686   if(_isLocal) _local_impl->UnLockStudy((char*)theLockerID.c_str());
687   else _corba_impl->UnLockStudy((char*)theLockerID.c_str());
688 }
689
690 vector<string> SALOMEDS_Study::GetLockerID()
691 {
692   std::vector<std::string> aVector;
693   int aLength, i;
694   if (_isLocal) {
695     SALOMEDS::Locker lock;
696
697     Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetLockerID();
698     aLength = aSeq->Length();
699     for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString());
700   }
701   else {
702     SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetLockerID();
703     aLength = aSeq->length();
704     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
705   }
706   return aVector;
707 }
708
709 std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) 
710 {
711   return _orb->object_to_string(theObject); 
712 }
713
714 CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR) 
715
716   return _orb->string_to_object(theIOR.c_str()); 
717
718
719 void SALOMEDS_Study::init_orb()
720 {
721   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
722   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()); 
723   _orb = init(0 , 0 ) ;     
724 }
725
726 SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
727 {
728   if (_isLocal) {
729     SALOMEDS::Locker lock;
730
731     if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl);
732     std::string anIOR = _local_impl->GetTransientReference().ToCString();
733     SALOMEDS::Study_var aStudy;
734     if (!_local_impl->IsError() && anIOR != "") {
735       aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str()));
736     }
737     else {
738       SALOMEDS_Study_i *aStudy_servant = new SALOMEDS_Study_i(_local_impl, _orb);
739       aStudy = aStudy_servant->_this();
740       _local_impl->SetTransientReference(_orb->object_to_string(aStudy));
741     }
742     _corba_impl = SALOMEDS::Study::_duplicate(aStudy);
743     return aStudy._retn();
744   }
745   else {
746     return SALOMEDS::Study::_duplicate(_corba_impl);
747   }
748
749   return SALOMEDS::Study::_nil();
750 }
751
752
753 _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint)
754 {
755   SALOMEDSClient_AttributeParameter* AP = NULL;
756   if(theSavePoint >= 0) {
757     if (_isLocal) {
758       SALOMEDS::Locker lock;
759       AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
760     }
761     else {
762       AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
763     }
764   }
765   return _PTR(AttributeParameter)(AP);
766 }
767
768 _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const string& theID, 
769                                                              const string& theModuleName, int theSavePoint)
770 {
771   SALOMEDSClient_AttributeParameter* AP = NULL;
772   if(theSavePoint > 0) {
773     if (_isLocal) {
774       SALOMEDS::Locker lock;
775       AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
776     }
777     else {
778       AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
779     }
780   }
781   return _PTR(AttributeParameter)(AP);
782 }