Salome HOME
ccad82686ac98079983e13a4781ef9f3b4e01ed6
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study_i.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOMEDS_Study_i.cxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #include "utilities.h"
28 #include "SALOMEDS_Study_i.hxx"
29 #include "SALOMEDS_StudyManager_i.hxx"
30 #include "SALOMEDS_UseCaseIterator_i.hxx"
31 #include "SALOMEDS_GenericAttribute_i.hxx"
32 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
33 #include "SALOMEDS_AttributeParameter_i.hxx"
34 #include "SALOMEDS_ChildIterator_i.hxx"
35 #include "SALOMEDS_Driver_i.hxx"
36 #include "SALOMEDS.hxx"
37
38 #include "SALOMEDSImpl_SObject.hxx"
39 #include "SALOMEDSImpl_SComponent.hxx"
40 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
41 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
42 #include "SALOMEDSImpl_AttributeParameter.hxx"
43 #include "SALOMEDSImpl_ChildIterator.hxx"
44 #include "SALOMEDSImpl_IParameters.hxx"
45 #include "SALOMEDSImpl_Callback.hxx"
46
47 #include "DF_Label.hxx"
48 #include "DF_Attribute.hxx"
49
50 #include "Basics_Utils.hxx"
51
52 #ifdef WIN32
53 #include <process.h>
54 #else
55 #include <sys/types.h>
56 #include <unistd.h>
57 #endif
58
59 namespace SALOMEDS
60 {
61   class Notifier: public SALOMEDSImpl_AbstractCallback
62   {
63   public:
64     Notifier(CORBA::ORB_ptr orb)
65     {
66       _orb = CORBA::ORB::_duplicate(orb);
67     }
68
69     //============================================================================
70     /*! Function : addSO_Notification
71      *  Purpose  : This function tells all the observers that a SO has been added
72      */
73     //============================================================================
74
75     virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject)
76     {
77       std::string anID=theSObject.GetID();
78       const char* cID=anID.c_str();
79       for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
80       {
81         it->first->notifyObserverID(cID,1);
82       }
83       return true; // NGE return always true but can be modified if needed
84     }
85
86     //============================================================================
87     /*! Function : removeSO_Notification
88      *  Purpose  : This function tells all the observers that a SO has been removed
89      */
90     //============================================================================
91
92     virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject)
93     {
94       std::string anID=theSObject.GetID();
95       const char* cID=anID.c_str();
96       for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
97       {
98         it->first->notifyObserverID(cID,2);
99       }
100       return true; // NGE return always true but can be modified if needed
101     }
102
103     //============================================================================
104     /*! Function : modifySO_Notification
105      *  Purpose  : This function tells all the observers that a SO has been modified
106      */
107     //============================================================================
108
109     virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason)
110     {
111       for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
112       {
113         if(it->second)
114         {
115           std::string anID=theSObject.GetID();
116           const char* cID=anID.c_str();
117           it->first->notifyObserverID(cID,reason);
118         }
119       }
120       return true; // NGE return always true but can be modified if needed
121     }
122
123     //============================================================================
124     /*! Function : modifyNB_Notification
125      *  Purpose  : This function tells all the observers that 
126      *             a NoteBook variable has been added/modified/removed.
127      */
128     //============================================================================
129     
130     virtual bool modifyNB_Notification(const char* theVarName)
131     {
132       for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
133         {
134           it->first->notifyObserverID(theVarName,6);
135         }
136       return true; // NGE return always true but can be modified if needed
137     }
138
139     //============================================================================
140     /*! Function : attach
141      *  Purpose  : register an Observer
142      */
143     //============================================================================
144
145     virtual void attach(SALOMEDS::Observer_ptr theObs, bool modify)
146     {
147       myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
148     }
149
150   private:
151     typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
152     typedef ObsList::iterator ObsListIter;
153     ObsList myObservers;
154     CORBA::ORB_var                    _orb;
155   };
156
157   class GenObjRegister: public SALOMEDSImpl_AbstractCallback
158   {
159   public:
160     GenObjRegister(CORBA::ORB_ptr orb)
161     {
162       _orb = CORBA::ORB::_duplicate(orb);
163     }
164     virtual void RegisterGenObj  (const std::string& theIOR)
165     {
166       try
167       {
168         CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
169         if ( obj->_non_existent() ) return;
170         SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
171         if(! CORBA::is_nil(gobj) )
172         {
173           gobj->Register();
174         }
175       }
176       catch(const CORBA::Exception& e)
177       {
178       }
179     }
180     virtual void UnRegisterGenObj(const std::string& theIOR)
181     {
182       try
183       {
184         CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
185         if ( obj->_non_existent() ) return;
186         SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj);
187         if(! CORBA::is_nil(gobj) )
188         {
189           gobj->UnRegister();
190         }
191       }
192       catch(const CORBA::Exception& e)
193       {
194       }
195     }
196
197   private:
198     CORBA::ORB_var _orb;
199   };
200
201 } // namespace SALOMEDS
202
203 std::map<SALOMEDSImpl_Study* , SALOMEDS_Study_i*> SALOMEDS_Study_i::_mapOfStudies;
204
205 //============================================================================
206 /*! Function : SALOMEDS_Study_i
207  *  Purpose  : SALOMEDS_Study_i constructor
208  */
209 //============================================================================
210 SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDSImpl_Study* theImpl,
211                                    CORBA::ORB_ptr      orb)
212 {
213   _orb            = CORBA::ORB::_duplicate(orb);
214   _impl           = theImpl;
215   _builder        = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);  
216   _notifier       = new SALOMEDS::Notifier(_orb);
217   _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
218
219   theImpl->setNotifier(_notifier);
220   theImpl->setGenObjRegister( _genObjRegister );
221 }
222   
223 //============================================================================
224 /*! Function : ~SALOMEDS_Study_i
225  *  Purpose  : SALOMEDS_Study_i destructor
226  */
227 //============================================================================
228 SALOMEDS_Study_i::~SALOMEDS_Study_i()
229 {
230   //delete the builder servant
231   PortableServer::POA_var poa=_builder->_default_POA();
232   PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
233   poa->deactivate_object(anObjectId.in());
234   _builder->_remove_ref();
235   
236   _impl->setNotifier(0);
237   delete _notifier;
238   delete _genObjRegister;
239   //delete implementation
240   delete _impl;
241   _mapOfStudies.erase(_impl);
242 }  
243
244 //============================================================================
245 /*! Function : GetPersistentReference
246  *  Purpose  : Get persistent reference of study (idem URL())
247  */
248 //============================================================================
249 char* SALOMEDS_Study_i::GetPersistentReference()
250 {
251   SALOMEDS::Locker lock; 
252   return CORBA::string_dup(_impl->GetPersistentReference().c_str());
253 }
254 //============================================================================
255 /*! Function : GetTransientReference
256  *  Purpose  : Get IOR of the Study (registred in OCAF document in doc->Root)
257  */
258 //============================================================================
259 char* SALOMEDS_Study_i::GetTransientReference()
260 {
261   SALOMEDS::Locker lock; 
262   return CORBA::string_dup(_impl->GetTransientReference().c_str()); 
263 }
264
265 //============================================================================
266 /*! Function : IsEmpty
267  *  Purpose  : Detect if study is empty
268  */
269 //============================================================================
270 CORBA::Boolean SALOMEDS_Study_i::IsEmpty()
271 {
272   SALOMEDS::Locker lock; 
273   return _impl->IsEmpty();
274 }
275
276 //============================================================================
277 /*! Function : FindComponent
278  *  Purpose  : Find a Component with ComponentDataType = aComponentName
279  */
280 //============================================================================
281 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName)
282 {
283   SALOMEDS::Locker lock; 
284   
285   SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponent(std::string(aComponentName));
286   if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
287
288   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
289   return sco._retn();
290 }
291
292 //============================================================================
293 /*! Function : FindComponentID
294  *  Purpose  : Find a Component from it's ID
295  */
296 //============================================================================
297 SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID)
298 {
299   SALOMEDS::Locker lock; 
300   
301   SALOMEDSImpl_SComponent aCompImpl = _impl->FindComponentID(std::string((char*)aComponentID));
302   if(aCompImpl.IsNull()) return SALOMEDS::SComponent::_nil();
303
304   SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aCompImpl, _orb);
305   return sco._retn();
306 }
307
308 //============================================================================
309 /*! Function : FindObject
310  *  Purpose  : Find an Object with SALOMEDS::Name = anObjectName
311  */
312 //============================================================================
313 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName)
314 {
315   SALOMEDS::Locker lock; 
316
317   SALOMEDSImpl_SObject aSO = _impl->FindObject(std::string((char*)anObjectName));
318   if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
319
320   if(aSO.IsComponent()) {
321     SALOMEDSImpl_SComponent aSCO = aSO;
322     SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (aSCO, _orb);
323     return sco._retn();
324   }
325    
326   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
327  
328  return so._retn();
329 }
330
331 //============================================================================
332 /*! Function : FindObjectID
333  *  Purpose  : Find an Object with ID = anObjectID
334  */
335 //============================================================================
336 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
337 {
338   SALOMEDS::Locker lock; 
339
340   SALOMEDSImpl_SObject aSO = _impl->FindObjectID(std::string((char*)anObjectID));
341   if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
342   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
343   return so._retn();
344 }
345
346 //============================================================================
347 /*! Function : CreateObjectID
348  *  Purpose  : Creates an Object with ID = anObjectID
349  */
350 //============================================================================
351 SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
352 {
353   SALOMEDS::Locker lock; 
354
355   if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
356
357   SALOMEDSImpl_SObject aSO = _impl->CreateObjectID((char*)anObjectID);
358   if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
359
360   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
361   return so._retn();
362 }
363
364 //============================================================================
365 /*! Function : FindObjectByName
366  *  Purpose  : Find Objects with SALOMEDS::Name = anObjectName in a Component
367  *           : with ComponentDataType = aComponentName
368  */
369 //============================================================================
370 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName,
371                                                                     const char* aComponentName )
372 {
373   SALOMEDS::Locker lock; 
374
375   std::vector<SALOMEDSImpl_SObject> aSeq = _impl->FindObjectByName(std::string((char*)anObjectName),
376                                                                std::string((char*)aComponentName));
377   int aLength = aSeq.size();
378   SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
379   listSO->length(aLength);
380   for(int i = 0; i<aLength; i++) {
381     SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSeq[i], _orb);
382     listSO[i] = so ;
383   }
384   return listSO._retn() ;
385 }
386
387 //============================================================================
388 /*! Function : FindObjectIOR
389  *  Purpose  : Find an Object with IOR = anObjectIOR
390  */
391 //============================================================================
392 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
393 {
394   SALOMEDS::Locker lock; 
395
396   SALOMEDSImpl_SObject aSO = _impl->FindObjectIOR(std::string((char*)anObjectIOR));
397   if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
398
399   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
400   return so._retn();
401 }
402
403 //============================================================================
404 /*! Function : FindObjectByPath
405  *  Purpose  : Find an Object by its path = thePath
406  */
407 //============================================================================
408 SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
409 {
410   SALOMEDS::Locker lock; 
411
412   SALOMEDSImpl_SObject aSO = _impl->FindObjectByPath(std::string((char*)thePath));
413   if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
414
415   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);
416   return so._retn();
417 }
418
419 //============================================================================
420 /*! Function : GetObjectPath
421  *  Purpose  : 
422  */
423 //============================================================================
424 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
425 {
426   SALOMEDS::Locker lock; 
427
428   std::string aPath("");
429   if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.c_str());
430   SALOMEDSImpl_SObject aSO;
431   SALOMEDS::SObject_var aSObj = SALOMEDS::SObject::_narrow(theObject);
432
433   if(!CORBA::is_nil(aSObj)) {
434     aSO = _impl->FindObjectID(aSObj->GetID());
435   }
436   else {
437     aSO  = _impl->FindObjectIOR(_orb->object_to_string(theObject));
438   }
439    
440   if(aSO.IsNull()) return CORBA::string_dup(aPath.c_str());
441   
442   aPath = _impl->GetObjectPath(aSO);
443   return  CORBA::string_dup(aPath.c_str());
444 }
445
446
447 //============================================================================
448 /*! Function : SetContext
449  *  Purpose  : Sets the current context
450  */
451 //============================================================================
452 void SALOMEDS_Study_i::SetContext(const char* thePath) 
453 {
454   SALOMEDS::Locker lock; 
455
456   _impl->SetContext(std::string((char*)thePath));
457   if(_impl->IsError() && _impl->GetErrorCode() == "InvalidContext") 
458     throw SALOMEDS::Study::StudyInvalidContext();  
459 }
460
461 //============================================================================
462 /*! Function : GetContext
463  *  Purpose  : Gets the current context
464  */
465 //============================================================================
466 char* SALOMEDS_Study_i::GetContext() 
467 {
468   SALOMEDS::Locker lock; 
469   
470   if(!_impl->HasCurrentContext()) throw SALOMEDS::Study::StudyInvalidContext();   
471   return CORBA::string_dup(_impl->GetContext().c_str());
472 }
473
474 //============================================================================
475 /*! Function : GetObjectNames
476  *  Purpose  : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
477  */
478 //============================================================================
479 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext) 
480 {
481   SALOMEDS::Locker lock; 
482
483   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
484
485   if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
486     throw SALOMEDS::Study::StudyInvalidContext();
487
488   std::vector<std::string> aSeq = _impl->GetObjectNames(std::string((char*)theContext));
489   if (_impl->GetErrorCode() == "InvalidContext")
490     throw SALOMEDS::Study::StudyInvalidContext();
491
492   int aLength = aSeq.size();
493   aResult->length(aLength);
494   for (int anIndex = 0; anIndex < aLength; anIndex++) {
495     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
496   }
497
498   return aResult._retn();
499 }
500
501 //============================================================================
502 /*! Function : GetDirectoryNames
503  *  Purpose  : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
504  */
505 //============================================================================
506 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext) 
507 {
508   SALOMEDS::Locker lock; 
509
510   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
511
512   if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
513     throw SALOMEDS::Study::StudyInvalidContext();
514
515   std::vector<std::string> aSeq = _impl->GetDirectoryNames(std::string((char*)theContext));
516   if (_impl->GetErrorCode() == "InvalidContext")
517     throw SALOMEDS::Study::StudyInvalidContext();
518
519   int aLength = aSeq.size();
520   aResult->length(aLength);
521   for (int anIndex = 0; anIndex < aLength; anIndex++) {
522     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
523   }
524
525   return aResult._retn();
526 }
527
528 //============================================================================
529 /*! Function : GetFileNames
530  *  Purpose  : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
531  */
532 //============================================================================
533 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext) 
534 {
535   SALOMEDS::Locker lock; 
536
537   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
538
539   if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
540     throw SALOMEDS::Study::StudyInvalidContext();
541
542   std::vector<std::string> aSeq = _impl->GetFileNames(std::string((char*)theContext));
543   if (_impl->GetErrorCode() == "InvalidContext")
544     throw SALOMEDS::Study::StudyInvalidContext();
545
546   int aLength = aSeq.size();
547   aResult->length(aLength);
548   for (int anIndex = 0; anIndex < aLength; anIndex++) {
549     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
550   }
551
552   return aResult._retn();
553 }
554
555 //============================================================================
556 /*! Function : GetComponentNames
557  *  Purpose  : method to get all components names
558  *  SRN:       Note, theContext can be any, it doesn't matter
559  */
560 //============================================================================
561 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext) 
562 {
563   SALOMEDS::Locker lock; 
564
565   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
566
567   std::vector<std::string> aSeq = _impl->GetComponentNames(std::string((char*)theContext));
568
569   int aLength = aSeq.size();
570   aResult->length(aLength);
571   for(int anIndex = 0; anIndex < aLength; anIndex++) {
572     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
573   }
574
575   return aResult._retn();
576 }
577
578 //============================================================================
579 /*! Function : NewChildIterator
580  *  Purpose  : Create a ChildIterator from an SObject
581  */
582 //============================================================================
583 SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSO)
584 {
585   SALOMEDS::Locker lock; 
586
587   CORBA::String_var anID=theSO->GetID();
588   SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
589   SALOMEDSImpl_ChildIterator anItr(aSO);
590
591   //Create iterator
592   SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
593
594   return it_servant->_this();
595 }
596
597
598 //============================================================================
599 /*! Function : NewComponentIterator
600  *  Purpose  : Create a SComponentIterator
601  */
602 //============================================================================
603 SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
604 {
605   SALOMEDS::Locker lock; 
606   SALOMEDS_SComponentIterator_i* _it = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb);
607   _it->Init();
608   return _it->_this();
609 }
610
611
612 //============================================================================
613 /*! Function : NewBuilder
614  *  Purpose  : Create a StudyBuilder
615  */
616 //============================================================================
617 SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
618 {
619   SALOMEDS::Locker lock; 
620   return _builder->_this();
621 }
622  
623 //============================================================================
624 /*! Function : Name
625  *  Purpose  : get study name
626  */
627 //============================================================================
628 char* SALOMEDS_Study_i::Name()
629 {
630   SALOMEDS::Locker lock; 
631   return CORBA::string_dup(_impl->Name().c_str());
632 }
633
634 //============================================================================
635 /*! Function : Name
636  *  Purpose  : set study name
637  */
638 //============================================================================
639 void SALOMEDS_Study_i::Name(const char* name)
640 {
641   SALOMEDS::Locker lock;  
642   _impl->Name(std::string(name));
643 }
644
645 //============================================================================
646 /*! Function : IsSaved
647  *  Purpose  : get if study has been saved
648  */
649 //============================================================================
650 CORBA::Boolean  SALOMEDS_Study_i::IsSaved()
651 {
652   SALOMEDS::Locker lock; 
653   return _impl->IsSaved();
654 }
655
656 //============================================================================
657 /*! Function : IsSaved
658  *  Purpose  : set if study has been saved
659  */
660 //============================================================================
661 void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save)
662 {
663   SALOMEDS::Locker lock; 
664   _impl->IsSaved(save);
665 }
666
667 //============================================================================
668 /*! Function : IsModified
669  *  Purpose  : Detect if a Study has been modified since it has been saved
670  */
671 //============================================================================
672 CORBA::Boolean  SALOMEDS_Study_i::IsModified()
673 {
674   SALOMEDS::Locker lock; 
675   return _impl->IsModified();
676 }
677
678 //============================================================================
679 /*! Function : Modified
680  *  Purpose  : Sets a Modified flag of a Study to True
681  */
682 //============================================================================
683 void  SALOMEDS_Study_i::Modified()
684 {
685   SALOMEDS::Locker lock; 
686   return _impl->Modify();
687 }
688
689
690 //============================================================================
691 /*! Function : URL
692  *  Purpose  : get URL of the study (persistent reference of the study)
693  */
694 //============================================================================
695 char* SALOMEDS_Study_i::URL()
696 {
697   SALOMEDS::Locker lock; 
698   return CORBA::string_dup(_impl->URL().c_str());
699 }
700
701 //============================================================================
702 /*! Function : URL
703  *  Purpose  : set URL of the study (persistent reference of the study)
704  */
705 //============================================================================
706 void SALOMEDS_Study_i::URL(const char* url)
707 {
708   SALOMEDS::Locker lock; 
709   _impl->URL(std::string((char*)url));
710 }
711
712
713 CORBA::Short SALOMEDS_Study_i::StudyId()
714 {
715   SALOMEDS::Locker lock; 
716   return _impl->StudyId();
717 }
718
719 void SALOMEDS_Study_i::StudyId(CORBA::Short id)
720
721   SALOMEDS::Locker lock; 
722   _impl->StudyId(id);
723 }
724
725 void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) 
726 {
727   SALOMEDS::Locker lock; 
728   _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry));
729 }
730
731 SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb) 
732 {
733   SALOMEDS::Locker lock; 
734
735   SALOMEDSImpl_AttributeIOR* Att = NULL;
736   if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){
737     char* IOR = CORBA::string_dup(Att->Value().c_str());
738     CORBA::Object_var obj = orb->string_to_object(IOR);
739     SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
740     ASSERT(!CORBA::is_nil(aStudy));
741     return SALOMEDS::Study::_duplicate(aStudy);
742   } else {
743     MESSAGE("GetStudy: Problem to get study");
744   }
745   return SALOMEDS::Study::_nil();
746 }
747
748 SALOMEDS_Study_i* SALOMEDS_Study_i::GetStudyServant(SALOMEDSImpl_Study* aStudyImpl, CORBA::ORB_ptr orb)
749 {
750   if (_mapOfStudies.find(aStudyImpl) != _mapOfStudies.end()) 
751     return _mapOfStudies[aStudyImpl];
752   else
753     {
754       SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, orb);
755       _mapOfStudies[aStudyImpl]=Study_servant;
756       return Study_servant;
757     }
758 }
759
760 void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute) 
761 {
762   SALOMEDS::Locker lock; 
763   SALOMEDSImpl_Study::IORUpdated(theAttribute);
764 }
765
766 SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) 
767 {
768   SALOMEDS::Locker lock; 
769
770   SALOMEDS::GenericAttribute_ptr aTarget;
771   if (anObject->FindAttribute(aTarget,"AttributeTarget")) {
772     return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get();
773   }
774   SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject;
775   aList->length(0);
776   return aList;
777 }
778
779
780 SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties() 
781 {
782   SALOMEDS::Locker lock; 
783   
784   SALOMEDSImpl_AttributeStudyProperties* anAttr = _impl->GetProperties();
785   SALOMEDS_AttributeStudyProperties_i* SP = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
786   return SP->AttributeStudyProperties::_this();
787 }
788
789 char* SALOMEDS_Study_i::GetLastModificationDate() 
790 {
791   SALOMEDS::Locker lock; 
792   return CORBA::string_dup(_impl->GetLastModificationDate().c_str());
793 }
794
795 SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() 
796 {
797   SALOMEDS::Locker lock; 
798   
799   std::vector<std::string> aSeq = _impl->GetModificationsDate();
800   int aLength = aSeq.size();
801   SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates;
802   aDates->length(aLength);
803
804   for(int anIndex = 0; anIndex < aLength; anIndex++) {
805     aDates[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
806   }
807   return aDates._retn();
808 }
809
810
811
812 //============================================================================
813 /*! Function : GetUseCaseBuilder
814  *  Purpose  : Returns a UseCase builder
815  */
816 //============================================================================
817 SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() 
818 {
819   SALOMEDS::Locker lock; 
820   SALOMEDS_UseCaseBuilder_i* UCBuilder = new SALOMEDS_UseCaseBuilder_i(_impl->GetUseCaseBuilder(), _orb);
821   return UCBuilder->_this();
822 }
823
824
825 //============================================================================
826 /*! Function : Close
827  *  Purpose  : 
828  */
829 //============================================================================
830 void SALOMEDS_Study_i::Close()
831 {
832   SALOMEDS::Locker lock; 
833
834   RemovePostponed(-1);
835
836   SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
837   for (; itcomponent->More(); itcomponent->Next()) {
838     SALOMEDS::SComponent_var sco = itcomponent->Value();
839     CORBA::String_var compodatatype=sco->ComponentDataType();
840     MESSAGE ( "Look for an engine for data type :"<< compodatatype);
841     // if there is an associated Engine call its method for closing
842     CORBA::String_var IOREngine;
843     if (sco->ComponentIOR(IOREngine)) {
844       // we have found the associated engine to write the data 
845       MESSAGE ( "We have found an engine for data type :"<< compodatatype);
846       //_narrow can throw a corba exception
847       try
848         {
849           CORBA::Object_var obj = _orb->string_to_object(IOREngine);
850           if (!CORBA::is_nil(obj)) 
851             {
852               SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
853               if (!anEngine->_is_nil()) 
854                 { 
855                   SALOMEDS::unlock();
856                   anEngine->Close(sco);
857                   SALOMEDS::lock();
858                 }
859             }
860         } 
861       catch (CORBA::Exception&) 
862         {/*pass*/ }
863     }
864     sco->UnRegister();
865   }
866
867   //Does not need any more this iterator
868   itcomponent->UnRegister();
869
870
871   _impl->Close();
872 }
873
874 //============================================================================
875 /*! Function : AddPostponed
876  *  Purpose  : 
877  */
878  //============================================================================
879 void SALOMEDS_Study_i::AddPostponed(const char* theIOR) 
880 {
881   SALOMEDS::Locker lock; 
882   //Not implemented
883 }
884
885 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) 
886 {
887   SALOMEDS::Locker lock; 
888   //Not implemented
889 }
890
891 //============================================================================
892 /*! Function : RemovePostponed
893  *  Purpose  : 
894  */
895 //============================================================================
896 #ifndef WIN32
897 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/) 
898 #else
899 void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/) 
900 #endif
901 {  
902   SALOMEDS::Locker lock; 
903
904   std::vector<std::string> anIORs = _impl->GetIORs();
905   int i, aSize = (int)anIORs.size();
906
907   for(i = 0; i < aSize; i++) {
908     try {
909       CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str());
910       SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
911           //rnv: To avoid double deletion of the Salome Generic Objects:
912           //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR();
913           //rnv: 2. Second decrement of the reference count in the next string : aGeneric->UnRegister();
914       //if (!CORBA::is_nil(aGeneric)) aGeneric->UnRegister();
915     } catch (...) {}
916   }
917
918   //Not implemented
919 }
920
921 //============================================================================
922 /*! Function : UndoPostponed
923  *  Purpose  : 
924  */
925 //============================================================================
926 #ifndef WIN32
927 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay) 
928 #else
929 void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay) 
930 #endif
931 {
932   SALOMEDS::Locker lock; 
933   //Not implemented
934 }
935
936
937 //============================================================================
938 /*! Function : DumpStudy
939  *  Purpose  : 
940  */
941 //============================================================================
942 CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath, 
943                                            const char* theBaseName, 
944                                            CORBA::Boolean isPublished,
945                                            CORBA::Boolean isMultiFile)
946 {
947   SALOMEDS::Locker lock; 
948
949   std::string aPath((char*)thePath), aBaseName((char*)theBaseName);
950   SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb);
951   CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, isMultiFile, factory);
952   delete factory;
953   return ret;
954 }
955
956 //============================================================================
957 /*! Function : GetCommonParameters
958  *  Purpose  : 
959  */
960 //============================================================================
961 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
962 {
963   SALOMEDS::Locker lock; 
964   
965   SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetCommonParameters(theID, theSavePoint);
966   SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
967   return SP->AttributeParameter::_this();
968 }
969  
970 //============================================================================
971 /*! Function : GetCommonModuleParameters
972  *  Purpose  : 
973  */
974 //============================================================================
975 SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID, 
976                                                                        const char* theModuleName, 
977                                                                        CORBA::Long theSavePoint)
978 {
979   SALOMEDS::Locker lock; 
980   
981   SALOMEDSImpl_AttributeParameter* anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
982   SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
983   return SP->AttributeParameter::_this();
984 }
985
986 //============================================================================
987 /*! Function : SetStudyLock
988  *  Purpose  : 
989  */
990 //============================================================================
991 void SALOMEDS_Study_i::SetStudyLock(const char* theLockerID)
992 {
993   SALOMEDS::Locker lock; 
994   _impl->SetStudyLock(theLockerID);
995 }
996
997 //============================================================================
998 /*! Function : IsStudyLocked
999  *  Purpose  : 
1000  */
1001 //============================================================================
1002 bool SALOMEDS_Study_i::IsStudyLocked()
1003 {
1004   SALOMEDS::Locker lock; 
1005   return _impl->IsStudyLocked();
1006 }
1007
1008 //============================================================================
1009 /*! Function : UnLockStudy
1010  *  Purpose  : 
1011  */
1012 //============================================================================
1013 void SALOMEDS_Study_i::UnLockStudy(const char* theLockerID)
1014 {
1015   SALOMEDS::Locker lock; 
1016   _impl->UnLockStudy(theLockerID);
1017 }
1018
1019 //============================================================================
1020 /*! Function : GetLockerID
1021  *  Purpose  : 
1022  */
1023 //============================================================================
1024 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID()
1025 {
1026   SALOMEDS::Locker lock; 
1027
1028   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1029
1030   std::vector<std::string> aSeq = _impl->GetLockerID();
1031
1032   int aLength = aSeq.size();
1033   aResult->length(aLength);
1034   for(int anIndex = 0; anIndex < aLength; anIndex++) {
1035     aResult[anIndex] = CORBA::string_dup(aSeq[anIndex].c_str());
1036   }
1037   return aResult._retn();
1038 }
1039 //============================================================================
1040 /*! Function : SetReal
1041  *  Purpose  : 
1042  */
1043 //============================================================================
1044 void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue)
1045 {
1046   _impl->SetVariable(std::string(theVarName), 
1047                      theValue,
1048                      SALOMEDSImpl_GenericVariable::REAL_VAR);
1049   if(_notifier)
1050     _notifier->modifyNB_Notification(theVarName);
1051 }
1052
1053 //============================================================================
1054 /*! Function : SetInteger
1055  *  Purpose  : 
1056  */
1057 //============================================================================
1058 void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue)
1059 {
1060   _impl->SetVariable(std::string(theVarName), 
1061                      theValue,
1062                      SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1063   if(_notifier)
1064     _notifier->modifyNB_Notification(theVarName);
1065 }
1066
1067 //============================================================================
1068 /*! Function : SetBoolean
1069  *  Purpose  : 
1070  */
1071 //============================================================================
1072 void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue)
1073 {
1074   _impl->SetVariable(std::string(theVarName), 
1075                      theValue,
1076                      SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1077   if(_notifier)
1078     _notifier->modifyNB_Notification(theVarName);
1079 }
1080
1081 //============================================================================
1082 /*! Function : SetString
1083  *  Purpose  : 
1084  */
1085 //============================================================================
1086 void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
1087 {
1088   _impl->SetStringVariable(std::string(theVarName), 
1089                            theValue,
1090                            SALOMEDSImpl_GenericVariable::STRING_VAR);
1091   if(_notifier)
1092     _notifier->modifyNB_Notification(theVarName);
1093 }
1094
1095 //============================================================================
1096 /*! Function : SetStringAsDouble
1097  *  Purpose  : 
1098  */
1099 //============================================================================
1100 void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
1101 {
1102   _impl->SetStringVariableAsDouble(std::string(theVarName), 
1103                                    theValue,
1104                                    SALOMEDSImpl_GenericVariable::STRING_VAR);
1105 }
1106
1107 //============================================================================
1108 /*! Function : GetReal
1109  *  Purpose  : 
1110  */
1111 //============================================================================
1112 CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName)
1113 {
1114   return _impl->GetVariableValue(std::string(theVarName));
1115 }
1116
1117 //============================================================================
1118 /*! Function : GetInteger
1119  *  Purpose  : 
1120  */
1121 //============================================================================
1122 CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName)
1123 {
1124   return (int)_impl->GetVariableValue(std::string(theVarName));
1125 }
1126
1127 //============================================================================
1128 /*! Function : GetBoolean
1129  *  Purpose  : 
1130  */
1131 //============================================================================
1132 CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName)
1133 {
1134   return (bool)_impl->GetVariableValue(std::string(theVarName));
1135 }
1136
1137 //============================================================================
1138 /*! Function : GetString
1139  *  Purpose  : 
1140  */
1141 //============================================================================
1142 char* SALOMEDS_Study_i::GetString(const char* theVarName)
1143 {
1144   return CORBA::string_dup(_impl->GetStringVariableValue(std::string(theVarName)).c_str());
1145 }
1146
1147 //============================================================================
1148 /*! Function : IsReal
1149  *  Purpose  : 
1150  */
1151 //============================================================================
1152 CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName)
1153 {
1154   return _impl->IsTypeOf(std::string(theVarName),
1155                          SALOMEDSImpl_GenericVariable::REAL_VAR);
1156 }
1157
1158 //============================================================================
1159 /*! Function : IsInteger
1160  *  Purpose  : 
1161  */
1162 //============================================================================
1163 CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName)
1164 {
1165   return _impl->IsTypeOf(std::string(theVarName),
1166                          SALOMEDSImpl_GenericVariable::INTEGER_VAR);
1167 }
1168
1169 //============================================================================
1170 /*! Function : IsBoolean
1171  *  Purpose  : 
1172  */
1173 //============================================================================
1174 CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName)
1175 {
1176   return _impl->IsTypeOf(std::string(theVarName),
1177                          SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
1178 }
1179
1180 //============================================================================
1181 /*! Function : IsString
1182  *  Purpose  : 
1183  */
1184 //============================================================================
1185 CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
1186 {
1187   return _impl->IsTypeOf(std::string(theVarName),
1188                          SALOMEDSImpl_GenericVariable::STRING_VAR);
1189 }
1190
1191 //============================================================================
1192 /*! Function : IsVariable
1193  *  Purpose  : 
1194  */
1195 //============================================================================
1196 CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName)
1197 {
1198   return _impl->IsVariable(std::string(theVarName));
1199 }
1200
1201 //============================================================================
1202 /*! Function : GetVariableNames
1203  *  Purpose  : 
1204  */
1205 //============================================================================
1206 SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames()
1207 {
1208   std::vector<std::string> aVarNames = _impl->GetVariableNames();
1209   SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
1210   
1211   int aLen = aVarNames.size();
1212   aResult->length(aLen);
1213   
1214   for (int anInd = 0; anInd < aLen; anInd++)
1215     aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1216   
1217   return aResult._retn();
1218 }
1219
1220 //============================================================================
1221 /*! Function : RemoveVariable
1222  *  Purpose  : 
1223  */
1224 //============================================================================
1225 CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName)
1226 {
1227   CORBA::Boolean res = _impl->RemoveVariable(std::string(theVarName));
1228   if(res && _notifier)
1229     _notifier->modifyNB_Notification(theVarName);
1230   return res;
1231 }
1232
1233 //============================================================================
1234 /*! Function : RenameVariable
1235  *  Purpose  : 
1236  */
1237 //============================================================================
1238 CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName)
1239 {
1240   CORBA::Boolean res = _impl->RenameVariable(std::string(theVarName), std::string(theNewVarName));
1241   if(res && _notifier)
1242     _notifier->modifyNB_Notification(theVarName);
1243   return res;
1244 }
1245
1246 //============================================================================
1247 /*! Function : IsVariableUsed
1248  *  Purpose  : 
1249  */
1250 //============================================================================
1251 CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
1252 {
1253   return _impl->IsVariableUsed(std::string(theVarName));
1254 }
1255
1256
1257 //============================================================================
1258 /*! Function : ParseVariables
1259  *  Purpose  : 
1260  */
1261 //============================================================================
1262 SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
1263 {
1264   std::vector< std::vector<std::string> > aSections = _impl->ParseVariables(std::string(theVarName));
1265
1266   SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
1267
1268   int aSectionsLen = aSections.size();
1269   aResult->length(aSectionsLen);
1270
1271   for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
1272     std::vector<std::string> aVarNames = aSections[aSectionInd];
1273
1274     SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
1275
1276     int aLen = aVarNames.size();
1277     aList->length(aLen);
1278
1279     for (int anInd = 0; anInd < aLen; anInd++)
1280       aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
1281
1282     aResult[aSectionInd] = aList;
1283   }
1284
1285   return aResult._retn();
1286 }
1287
1288 //============================================================================
1289 /*! Function : GetDefaultScript
1290  *  Purpose  : 
1291  */
1292 //============================================================================
1293 char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
1294 {
1295   SALOMEDS::Locker lock; 
1296
1297   std::string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
1298   return CORBA::string_dup(script.c_str());
1299 }
1300
1301 //============================================================================
1302 /*! Function : EnableUseCaseAutoFilling
1303  *  Purpose  : 
1304  */
1305 //============================================================================
1306 void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) 
1307
1308   _impl->EnableUseCaseAutoFilling(isEnabled); 
1309   SALOMEDSImpl_StudyBuilder* builder = _builder->GetImpl();
1310   if(builder) {
1311     if(isEnabled) {
1312       builder->SetOnAddSObject(_impl->GetCallback());
1313       builder->SetOnRemoveSObject(_impl->GetCallback());
1314     }
1315     else {
1316       builder->SetOnAddSObject(NULL);
1317       builder->SetOnRemoveSObject(NULL);
1318     }
1319   }
1320 }
1321
1322 //============================================================================
1323 /*! Function : attach
1324  *  Purpose  : This function attach an observer to the study
1325  */
1326 //============================================================================
1327 void SALOMEDS_Study_i::attach(SALOMEDS::Observer_ptr theObs,CORBA::Boolean modify)
1328 {
1329   if(_notifier)
1330     static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs,modify);
1331 }
1332
1333 //===========================================================================
1334 //   PRIVATE FUNCTIONS
1335 //===========================================================================
1336 CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
1337 {
1338 #ifdef WIN32
1339   long pid = (long)_getpid();
1340 #else
1341   long pid = (long)getpid();
1342 #endif  
1343   isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
1344   return reinterpret_cast<CORBA::LongLong>(_impl);
1345 }