Salome HOME
Merge V9_dev branch into master
authorrnv <rnv@opencascade.com>
Thu, 14 Jun 2018 08:33:23 +0000 (11:33 +0300)
committerrnv <rnv@opencascade.com>
Thu, 14 Jun 2018 08:33:23 +0000 (11:33 +0300)
22 files changed:
1  2 
bin/launchConfigureParser.py
src/KERNEL_PY/salome_iapp.py
src/Launcher/Test/test_launcher.py
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx
src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx
src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx
src/SALOMEDS/SALOMEDS_SObject.cxx
src/SALOMEDS/SALOMEDS_SObject.hxx
src/SALOMEDS/SALOMEDS_SObject_i.cxx
src/SALOMEDS/SALOMEDS_SObject_i.hxx
src/SALOMEDS/SALOMEDS_Server.cxx
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.hxx
src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx
src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx
src/SALOMEDSClient/SALOMEDSClient_SObject.hxx

index bde0a996e935916307bd31aaf3dd69e944b0df1e,e32982a549365536fb2735b183a5c5ddd6ebf012..e52313342f939dcace0bed5fd27d97a3e7cef2c1
@@@ -430,99 -437,116 +437,116 @@@ class xml_parser
  
  # -----------------------------------------------------------------------------
  
- booleans = { '1': True , 'yes': True , 'y': True , 'on' : True , 'true' : True , 'ok'     : True,
-              '0': False, 'no' : False, 'n': False, 'off': False, 'false': False, 'cancel' : False }
+ booleans = {'1': True , 'yes': True , 'y': True , 'on' : True , 'true' : True , 'ok'     : True,
+             '0': False, 'no' : False, 'n': False, 'off': False, 'false': False, 'cancel' : False}
  
- boolean_choices = booleans.keys()
+ boolean_choices = list(booleans.keys())
  
- def check_embedded(option, opt, value, parser):
-     from optparse import OptionValueError
-     assert value is not None
-     if parser.values.embedded:
-         embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
-     else:
-         embedded = []
-     if parser.values.standalone:
-         standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
-     else:
-         standalone = []
-     vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
-     for v in vals:
-         if v not in embedded_choices:
-             raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, embedded_choices ) ) ) )
-         if v not in embedded:
-             embedded.append( v )
-             if v in standalone:
-                 del standalone[ standalone.index( v ) ]
-                 pass
-     parser.values.embedded = ",".join( embedded )
-     parser.values.standalone = ",".join( standalone )
-     pass
  
- def check_standalone(option, opt, value, parser):
-     from optparse import OptionValueError
-     assert value is not None
-     if parser.values.embedded:
-         embedded = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.embedded ) )
-     else:
-         embedded = []
-     if parser.values.standalone:
-         standalone = filter( lambda a: a.strip(), re.split( "[:;,]", parser.values.standalone ) )
-     else:
-         standalone = []
-     vals = filter( lambda a: a.strip(), re.split( "[:;,]", value ) )
-     for v in vals:
-         if v not in standalone_choices:
-             raise OptionValueError( "option %s: invalid choice: %r (choose from %s)" % ( opt, v, ", ".join( map( repr, standalone_choices ) ) ) )
-         if v not in standalone:
-             standalone.append( v )
-             if v in embedded:
-                 del embedded[ embedded.index( v ) ]
-                 pass
-     parser.values.embedded = ",".join( embedded )
-     parser.values.standalone = ",".join( standalone )
-     pass
+ class CheckEmbeddedAction(argparse.Action):
+     def __call__(self, parser, namespace, value, option_string=None):
+         assert value is not None
+         if namespace.embedded:
+             embedded = [a for a in re.split("[:;,]", namespace.embedded) if a.strip()]
+         else:
+             embedded = []
+         if namespace.standalone:
+             standalone = [a for a in re.split("[:;,]", namespace.standalone) if a.strip()]
+         else:
+             standalone = []
+         vals = [a for a in re.split("[:;,]", value) if a.strip()]
+         for v in vals:
+             if v not in embedded_choices:
+                 raise argparse.ArgumentError("option %s: invalid choice: %r (choose from %s)"
+                                              % (self.dest, v, ", ".join(map(repr, embedded_choices))))
+             if v not in embedded:
+                 embedded.append(v)
+                 if v in standalone:
+                     del standalone[standalone.index(v)]
+                     pass
+         namespace.embedded = ",".join(embedded)
+         namespace.standalone = ",".join(standalone)
+         pass
+ class CheckStandaloneAction(argparse.Action):
+     def __call__(self, parser, namespace, value, option_string=None):
+         assert value is not None
+         if namespace.embedded:
+             embedded = [a for a in re.split("[:;,]", namespace.embedded) if a.strip()]
+         else:
+             embedded = []
+         if namespace.standalone:
+             standalone = [a for a in re.split("[:;,]", namespace.standalone) if a.strip()]
+         else:
+             standalone = []
+         vals = [a for a in re.split("[:;,]", value) if a.strip()]
+         for v in vals:
+             if v not in standalone_choices:
+                 raise argparse.ArgumentError("option %s: invalid choice: %r (choose from %s)"
+                                              % (self.dest, v, ", ".join(map(repr, standalone_choices))))
+             if v not in standalone:
+                 standalone.append(v)
+                 if v in embedded:
+                     del embedded[embedded.index(v)]
+                     pass
+         namespace.embedded = ",".join(embedded)
+         namespace.standalone = ",".join(standalone)
  
- def store_boolean (option, opt, value, parser, *args):
-     if isinstance(value, types.StringType):
-         try:
-             value_conv = booleans[value.strip().lower()]
-             for attribute in args:
-                 setattr(parser.values, attribute, value_conv)
-         except KeyError:
-             raise optparse.OptionValueError(
-                 "option %s: invalid boolean value: %s (choose from %s)"
-                 % (opt, value, boolean_choices))
-     else:
-         for attribute in args:
-             setattr(parser.values, attribute, value)
  
- def CreateOptionParser (theAdditionalOptions=None, exeName=None):
-     if theAdditionalOptions is None:
-         theAdditionalOptions = []
+ class StoreBooleanAction(argparse.Action):
+     def __call__(self, parser, namespace, value, option_string=None):
+         if isinstance(value, bytes):
+             value = value.decode()
+         if isinstance(value, str):
+             try:
+                 value_conv = booleans[value.strip().lower()]
+                 setattr(namespace, self.dest, value_conv)
+             except KeyError:
+                 raise argparse.ArgumentError(
+                     "option %s: invalid boolean value: %s (choose from %s)"
+                     % (self.dest, value, boolean_choices))
+         else:
+             setattr(namespace, self.dest, value)
+ def CreateOptionParser(exeName=None):
+     if not exeName:
+         exeName = "%(prog)s"
+     a_usage = """%s [options] [STUDY_FILE] [PYTHON_FILE [args] [PYTHON_FILE [args]...]]
+ Python file arguments, if any, must be comma-separated (without blank characters) and prefixed by "args:" (without quotes), e.g. myscript.py args:arg1,arg2=val,...
+ """ % exeName
+     version_str = "Salome %s" % version()
+     pars = argparse.ArgumentParser(usage=a_usage)
+     # Version
+     pars.add_argument('-v', '--version', action='version', version=version_str)
      # GUI/Terminal. Default: GUI
      help_str = "Launch without GUI (in the terminal mode)."
-     o_t = optparse.Option("-t",
-                           "--terminal",
-                           action="store_false",
-                           dest="gui",
-                           help=help_str)
+     pars.add_argument("-t",
+                       "--terminal",
+                       action="store_false",
+                       dest="gui",
+                       help=help_str)
  
      help_str = "Launch in Batch Mode. (Without GUI on batch machine)"
-     o_b = optparse.Option("-b",
-                           "--batch",
-                           action="store_true",
-                           dest="batch",
-                           help=help_str)
+     pars.add_argument("-b",
+                       "--batch",
+                       action="store_true",
+                       dest="batch",
+                       help=help_str)
  
      help_str = "Launch in GUI mode [default]."
-     o_g = optparse.Option("-g",
-                           "--gui",
-                           action="store_true",
-                           dest="gui",
-                           help=help_str)
+     pars.add_argument("-g",
+                       "--gui",
+                       action="store_true",
+                       dest="gui",
+                       help=help_str)
  
 -    # Show Desktop (inly in GUI mode). Default: True
 +    # Show Desktop (only in GUI mode). Default: True
      help_str  = "1 to activate GUI desktop [default], "
      help_str += "0 to not activate GUI desktop (Session_Server starts, but GUI is not shown). "
      help_str += "Ignored in the terminal mode."
index 0946fe371740172c82294740ce4284677b91aa22,24deed4111d47b32031ea73a31bde64692d08dda..30ec345667ed950c89c7137b417f6b084c32d6de
@@@ -144,7 -139,7 +139,7 @@@ class SalomeOutsideGUI(object)
  
      def IsInCurrentView(self, Entry):
          """Indicate if an entry is in current view"""
-         print "SalomeOutsideGUI.IsIncurrentView: not available outside GUI"
 -        print("SalomeOutsideGUI.IsIncurentView: not available outside GUI")
++        print("SalomeOutsideGUI.IsIncurrentView: not available outside GUI")
          return False
          
      def getComponentName(self, ComponentUserName ):
index 5087d66998bfffe149172b6e6522321616554604,41c2d079a41bb99831b336e928cdb2bfe9f0a5fc..339e4c8751b67e843c8e78a79a4528f7775544b5
@@@ -58,16 -58,9 +58,16 @@@ class TestCompo(unittest.TestCase)
        text = f.read()
        f.close()
        self.assertEqual(text, content)
-     except IOError,ex:
+     except IOError as ex:
        self.fail("IO exception:" + str(ex));
  
 +  def create_JobParameters(self):
 +    job_params = salome.JobParameters()
 +    job_params.wckey="P11U5:CARBONES" #needed by edf clusters
 +    job_params.resource_required = salome.ResourceParameters()
 +    job_params.resource_required.nb_proc = 1
 +    return job_params
 +
    ##############################
    # test of python_salome job
    ##############################
index e6313314bd9e929a7f93bddd525fa207f244d6a4,2d86b26de6f34157141879e41fcbb2e5891d8db9..b6fdf918b64c9ace47c92c61d044749ab10a8fd9
@@@ -38,8 -38,6 +38,8 @@@
  
  #include "SALOMEDS_Defines.hxx"
  
++#include <utilities.h>
++
  // IDL headers
  #include <SALOMEconfig.h>
  #include CORBA_SERVER_HEADER(SALOMEDS)
@@@ -79,99 -75,73 +77,86 @@@ void SALOMEDS::unlock(
  
  extern "C"
  {
- SALOMEDS_EXPORT
-   SALOMEDSClient_StudyManager* StudyManagerFactory()
- {
-   return new SALOMEDS_StudyManager();
- }
- SALOMEDS_EXPORT
+   SALOMEDS_EXPORT
    SALOMEDSClient_Study* StudyFactory(SALOMEDS::Study_ptr theStudy)
- {
-   if(CORBA::is_nil(theStudy)) return NULL;
-   return new SALOMEDS_Study(theStudy);
- }
  {
+     if(CORBA::is_nil(theStudy)) return NULL;
+     return new SALOMEDS_Study(theStudy);
  }
  
- SALOMEDS_EXPORT
  SALOMEDS_EXPORT
    SALOMEDSClient_SObject* SObjectFactory(SALOMEDS::SObject_ptr theSObject)
- {
-   if(CORBA::is_nil(theSObject)) return NULL;
-   return new SALOMEDS_SObject(theSObject);
- }
  {
+     if(CORBA::is_nil(theSObject)) return NULL;
+     return new SALOMEDS_SObject(theSObject);
  }
  
- SALOMEDS_EXPORT
  SALOMEDS_EXPORT
    SALOMEDSClient_SComponent* SComponentFactory(SALOMEDS::SComponent_ptr theSComponent)
- {
-   if(CORBA::is_nil(theSComponent)) return NULL;
-   return new SALOMEDS_SComponent(theSComponent);
- }
  {
+     if(CORBA::is_nil(theSComponent)) return NULL;
+     return new SALOMEDS_SComponent(theSComponent);
  }
  
- SALOMEDS_EXPORT
  SALOMEDS_EXPORT
    SALOMEDSClient_StudyBuilder* BuilderFactory(SALOMEDS::StudyBuilder_ptr theBuilder)
- {
-   if(CORBA::is_nil(theBuilder)) return NULL;
-   return new SALOMEDS_StudyBuilder(theBuilder);
- }
  {
+     if(CORBA::is_nil(theBuilder)) return NULL;
+     return new SALOMEDS_StudyBuilder(theBuilder);
  }
  
- SALOMEDS_EXPORT
-   SALOMEDSClient_StudyManager* CreateStudyManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
- {
-   SALOME_NamingService namingService(orb);
-   CORBA::Object_var obj = namingService.Resolve( "/myStudyManager" );
-   SALOMEDS::StudyManager_var theManager = SALOMEDS::StudyManager::_narrow( obj );
-   if( CORBA::is_nil(theManager) )
+   SALOMEDS_EXPORT
+   void CreateStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
    {
-     PortableServer::POAManager_var pman = root_poa->the_POAManager();
-     CORBA::PolicyList policies;
-     policies.length(2);
-     //PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
-     PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL));
-     PortableServer::ImplicitActivationPolicy_var implicitPol(root_poa->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION));
-     policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
-     policies[1] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitPol);
-     PortableServer::POA_var poa = root_poa->create_POA("KERNELStudySingleThreadPOA",pman,policies);
-     MESSAGE("CreateStudyManager: KERNELStudySingleThreadPOA: "<< poa);
-     threadPol->destroy();
-     SALOMEDS_StudyManager_i * aStudyManager_i = new  SALOMEDS_StudyManager_i(orb, poa);
-     // Activate the objects.  This tells the POA that the objects are ready to accept requests.
-     PortableServer::ObjectId_var aStudyManager_iid =  poa->activate_object(aStudyManager_i);
-     //give ownership to the poa : the object will be deleted by the poa
-     aStudyManager_i->_remove_ref();
-     aStudyManager_i->register_name((char*)"/myStudyManager");
+     SALOME_NamingService namingService(orb);
+     CORBA::Object_var obj = namingService.Resolve( "/Study" );
+     SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( obj );
+     if( CORBA::is_nil(aStudy) ) {
++      PortableServer::POAManager_var pman = root_poa->the_POAManager();
++      CORBA::PolicyList policies;
++      policies.length(2);
++      //PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
++      PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL));
++      PortableServer::ImplicitActivationPolicy_var implicitPol(root_poa->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION));
++      policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
++      policies[1] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitPol);
++      PortableServer::POA_var poa = root_poa->create_POA("KERNELStudySingleThreadPOA",pman,policies);
++      MESSAGE("CreateStudy: KERNELStudySingleThreadPOA: "<< poa);
++      threadPol->destroy();
++
++      SALOMEDS_Study_i::SetThePOA(poa);  
+       SALOMEDS_Study_i* aStudy_i = new SALOMEDS_Study_i(orb);
+       // Activate the objects.  This tells the POA that the objects are ready to accept requests.
+       PortableServer::ObjectId_var aStudy_iid =  root_poa->activate_object(aStudy_i);
+       aStudy = aStudy_i->_this();
+       namingService.Register(aStudy, "/Study");
+       aStudy_i->GetImpl()->GetDocument()->SetModified(false);
+       aStudy_i->_remove_ref();
+     }
    }
-   return new SALOMEDS_StudyManager();
- }
  
- SALOMEDS_EXPORT
  SALOMEDS_EXPORT
    SALOMEDSClient_IParameters* GetIParameters(const _PTR(AttributeParameter)& ap)
- {
-   return new SALOMEDS_IParameters(ap);
- }
  {
+     return new SALOMEDS_IParameters(ap);
  }
  
- SALOMEDS_EXPORT
  SALOMEDS_EXPORT
    SALOMEDS::SObject_ptr ConvertSObject(const _PTR(SObject)& theSObject)
- {
-   
-   SALOMEDS_SObject* so = _CAST(SObject, theSObject);
-   if(!theSObject || !so) return SALOMEDS::SObject::_nil();
-   return so->GetSObject();
- }
- SALOMEDS_EXPORT
-   SALOMEDS::Study_ptr ConvertStudy(const _PTR(Study)& theStudy)
- {
-   SALOMEDS_Study* study = _CAST(Study, theStudy);
-   if(!theStudy || !study) return SALOMEDS::Study::_nil();
-   return study->GetStudy();
- }
+   {
+     SALOMEDS_SObject* so = _CAST(SObject, theSObject);
+     if ( !theSObject || !so )
+       return SALOMEDS::SObject::_nil();
+     return so->GetSObject();
+   }
  
- SALOMEDS_EXPORT
  SALOMEDS_EXPORT
    SALOMEDS::StudyBuilder_ptr ConvertBuilder(const _PTR(StudyBuilder)& theBuilder)
- {
-   SALOMEDS_StudyBuilder* builder = _CAST(StudyBuilder, theBuilder);
-   if(!theBuilder || !builder) return SALOMEDS::StudyBuilder::_nil(); 
-   return builder->GetBuilder();
- }
+   {
+     SALOMEDS_StudyBuilder* builder = _CAST(StudyBuilder, theBuilder);
+     if ( !theBuilder || !builder )
+       return SALOMEDS::StudyBuilder::_nil();
+     return builder->GetBuilder();
+   }
  }
index 3a17656b00adfa1ffbe79ec56220d744c9b7d83b,e5c3ad9e1cfd6a876d7e323d9ae777ee50eb3d78..574cf45b04ee7caef4bec4116c0786d43517cbb3
@@@ -25,7 -25,6 +25,7 @@@
  //  Module : SALOME
  //
  #include "SALOMEDS_ChildIterator_i.hxx"
- #include "SALOMEDS_StudyManager_i.hxx"
++#include "SALOMEDS_Study_i.hxx"
  #include "SALOMEDS_SObject_i.hxx"
  #include "SALOMEDS.hxx"
  #include "SALOMEDSImpl_SObject.hxx"
@@@ -38,9 -37,8 +38,9 @@@
   */
  //============================================================================
  SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(const SALOMEDSImpl_ChildIterator& theImpl,
 -                                                   CORBA::ORB_ptr orb) 
 -  : _it(theImpl.GetPersistentCopy())
 +                                                   CORBA::ORB_ptr orb)  :
-   GenericObj_i(SALOMEDS_StudyManager_i::GetThePOA()),
++  GenericObj_i(SALOMEDS_Study_i::GetThePOA()),
 +  _it(theImpl.GetPersistentCopy())
  {
    SALOMEDS::Locker lock;
    _orb = CORBA::ORB::_duplicate(orb);
@@@ -56,23 -54,6 +56,23 @@@ SALOMEDS_ChildIterator_i::~SALOMEDS_Chi
      if(_it) delete _it;
  }
  
-   myPOA = PortableServer::POA::_duplicate(SALOMEDS_StudyManager_i::GetThePOA());
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_ChildIterator_i::_default_POA()
 +{
++  myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
 +  //MESSAGE("SALOMEDS_ChildIterator_i::_default_POA: " << myPOA);
 +  return PortableServer::POA::_duplicate(myPOA);
 +}
 +
  //============================================================================
  /*! Function :Init
   * 
index 114c0a228986085e1c2988a4492d3f969219acfb,5b98df2db2e2ccf0f12c8a3a95db8ca5577eb3c6..7014f54c8c3f8f27d9f867eee6bdfc6095959be8
@@@ -26,7 -26,6 +26,7 @@@
  //
  #include "utilities.h"
  #include "SALOMEDS_GenericAttribute_i.hxx"
- #include "SALOMEDS_StudyManager_i.hxx"
++#include "SALOMEDS_Study_i.hxx"
  #include "SALOMEDS_Attributes.hxx"
  #include "SALOMEDS.hxx"
  #include "SALOMEDSImpl_SObject.hxx"
@@@ -44,8 -43,7 +44,8 @@@
  
  UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
  
 -SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(DF_Attribute* theImpl, CORBA::ORB_ptr theOrb)
 +SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(DF_Attribute* theImpl, CORBA::ORB_ptr theOrb) :
-   GenericObj_i(SALOMEDS_StudyManager_i::GetThePOA())
++  GenericObj_i(SALOMEDS_Study_i::GetThePOA())
  {
    _orb = CORBA::ORB::_duplicate(theOrb);
    _impl = theImpl;
@@@ -55,23 -53,6 +55,23 @@@ SALOMEDS_GenericAttribute_i::~SALOMEDS_
  {
  }
  
-   myPOA = PortableServer::POA::_duplicate(SALOMEDS_StudyManager_i::GetThePOA());
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_GenericAttribute_i::_default_POA()
 +{
++  myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
 +  //MESSAGE("SALOMEDS_GenericAttribute_i::_default_POA: " << myPOA);
 +  return PortableServer::POA::_duplicate(myPOA);
 +}
 +
  void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) 
  {
    SALOMEDS::Locker lock;
index 07b24a93cd3d2970de5914d5391e05a113ec445e,cc7d6700fda508498f90395d78f7f59796d68637..35b3b34fb62b664cd264b9417976ef49eb397d94
@@@ -27,8 -27,6 +27,8 @@@
  #include "SALOMEDS_SComponentIterator_i.hxx"
  #include "SALOMEDS.hxx"
  #include "SALOMEDSImpl_SComponent.hxx"
- #include "SALOMEDS_StudyManager_i.hxx"
++#include "SALOMEDS_Study_i.hxx"
 +#include "utilities.h"
  
  //============================================================================
  /*! Function : constructor
@@@ -37,8 -35,7 +37,8 @@@
  //============================================================================
  
  SALOMEDS_SComponentIterator_i::SALOMEDS_SComponentIterator_i(const SALOMEDSImpl_SComponentIterator& theImpl, 
 -                                                             CORBA::ORB_ptr orb) 
 +                                                             CORBA::ORB_ptr orb)  :
-   GenericObj_i(SALOMEDS_StudyManager_i::GetThePOA())
++  GenericObj_i(SALOMEDS_Study_i::GetThePOA())
  {
    _orb = CORBA::ORB::_duplicate(orb);
    _impl = theImpl.GetPersistentCopy();
@@@ -54,23 -51,6 +54,23 @@@ SALOMEDS_SComponentIterator_i::~SALOMED
     if(_impl) delete _impl;
  }
  
-   myPOA = PortableServer::POA::_duplicate(SALOMEDS_StudyManager_i::GetThePOA());
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_SComponentIterator_i::_default_POA()
 +{
++  myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
 +  MESSAGE("SALOMEDS_SComponentIterator_i::_default_POA: " << myPOA);
 +  return PortableServer::POA::_duplicate(myPOA);
 +}
 +
  //============================================================================
  /*! Function : Init
   * 
Simple merge
Simple merge
index bfff08d5ed4907cf8ada7e6bc1109ba553e62031,2cf28a4cc388ef647e5fb7b153f065dd9d8fcaf6..36e8cbb4c71a8d232a1344436c6b1f52131d20a4
@@@ -26,9 -26,8 +26,9 @@@
  //
  #include "utilities.h"
  #include "SALOMEDS_SObject_i.hxx"
++#include "SALOMEDS_Study_i.hxx"
  #include "SALOMEDS_SComponent_i.hxx"
  #include "SALOMEDS_GenericAttribute_i.hxx"
- #include "SALOMEDS_StudyManager_i.hxx"
  #include "SALOMEDS.hxx"
  #include "SALOMEDSImpl_GenericAttribute.hxx"
  #include "SALOMEDSImpl_SComponent.hxx"
@@@ -58,8 -57,7 +58,8 @@@ SALOMEDS::SObject_ptr SALOMEDS_SObject_
   *  Purpose  :
   */
  //============================================================================
 -SALOMEDS_SObject_i::SALOMEDS_SObject_i(const SALOMEDSImpl_SObject& impl, CORBA::ORB_ptr orb)
 +SALOMEDS_SObject_i::SALOMEDS_SObject_i(const SALOMEDSImpl_SObject& impl, CORBA::ORB_ptr orb) :
-   GenericObj_i(SALOMEDS_StudyManager_i::GetThePOA())
++  GenericObj_i(SALOMEDS_Study_i::GetThePOA())
  {
    _impl = 0;
    if(!impl.IsNull()) {
@@@ -86,23 -83,6 +85,23 @@@ SALOMEDS_SObject_i::~SALOMEDS_SObject_i
     if(_impl) delete _impl;    
  }
  
-   myPOA = PortableServer::POA::_duplicate(SALOMEDS_StudyManager_i::GetThePOA());
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_SObject_i::_default_POA()
 +{
++  myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
 +  //MESSAGE("SALOMEDS_SObject_i::_default_POA: " << myPOA);
 +  return PortableServer::POA::_duplicate(myPOA);
 +}
 +
  //================================================================================
  /*!
   * \brief Returns true if the %SObject does not belong to any %Study
Simple merge
Simple merge
index 50d658b7d969fc876e8513f8d1832d2acfff069b,86629e27142cfb4d9cb0a410b318bbf2327ff5ff..f7ea3dc15b94d6e510a04c9e7d423f2b2125fd63
@@@ -68,10 -70,7 +70,10 @@@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS
    _isLocal = true;
    _local_impl = theStudy;
    _corba_impl = SALOMEDS::Study::_nil();
-   init_orb();
 +
 +  pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
 +
+   InitORB();
  }
  
  SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
index e3013e714232005a8ed7d0a64bb483476e53ad74,9ba49a3264f4d9b015a836287f7dbbc6e50758ac..f9ecf67a23bc930bd33f4db95f94f2d6c3d8da27
@@@ -68,23 -67,6 +67,23 @@@ SALOMEDS_StudyBuilder_i::SALOMEDS_Study
  SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i()
  {}
  
-   PortableServer::POA_ptr poa = SALOMEDS_StudyManager_i::GetThePOA();
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_StudyBuilder_i::_default_POA()
 +{
++  PortableServer::POA_ptr poa = SALOMEDS_Study_i::GetThePOA();
 +  MESSAGE("SALOMEDS_StudyBuilder_i::_default_POA: " << poa);
 +  return PortableServer::POA::_duplicate(poa);
 +}
 +
  //============================================================================
  /*! Function : NewComponent
   *  Purpose  : Create a new component (Scomponent)
index 3d99e2b73925b3f4a428dc077152c8f4745c1d49,19abf1b64cd4e0a6278636dc4c9590f72c802073..050f925004414b04fecd526c907ebc85915ad283
  #include <unistd.h>
  #endif
  
+ UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
+ UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
+ static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
++static  PortableServer::POA_ptr _poa;
++
  namespace SALOMEDS
  {
    class Notifier: public SALOMEDSImpl_AbstractCallback
@@@ -252,16 -291,21 +293,21 @@@ void SALOMEDS_Study_i::Init(
      SALOMEDS::lock();
    }
  }
-   
  //============================================================================
- /*! Function : ~SALOMEDS_Study_i
-  *  Purpose  : SALOMEDS_Study_i destructor
+ /*! Function : Clear
+  *  Purpose  : Clear study components
   */
  //============================================================================
SALOMEDS_Study_i::~SALOMEDS_Study_i()
void SALOMEDS_Study_i::Clear()
  {
+   if (_closed)
+     return;
+   SALOMEDS::Locker lock;
    //delete the builder servant
--  PortableServer::POA_var poa=_builder->_default_POA();
++  PortableServer::POA_var poa=_default_POA();
    PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
    poa->deactivate_object(anObjectId.in());
    _builder->_remove_ref();
    _impl->setNotifier(0);
    delete _notifier;
    delete _genObjRegister;
-   //delete implementation
-   delete _impl;
-   _mapOfStudies.erase(_impl);
- }  
+   _notifier = NULL;
+   _closed = true;
+ }
  
-   PortableServer::POA_ptr poa = SALOMEDS_StudyManager_i::GetThePOA();
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_Study_i::_default_POA()
 +{
++  PortableServer::POA_ptr poa = GetThePOA();
 +  MESSAGE("SALOMEDS_Study_i::_default_POA: " << poa);
 +  return PortableServer::POA::_duplicate(poa);
 +}
 +
  //============================================================================
- /*! Function : GetPersistentReference
-  *  Purpose  : Get persistent reference of study (idem URL())
+ /*! Function : Open
+  *  Purpose  : Open a Study from it's persistent reference
   */
  //============================================================================
- char* SALOMEDS_Study_i::GetPersistentReference()
+ bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
+   throw(SALOME::SALOME_Exception)
  {
-   SALOMEDS::Locker lock; 
+   if (!_closed)
+     Clear();
+   Init();
+   SALOMEDS::Locker lock;
+   Unexpect aCatch(SalomeException);
+   MESSAGE("Begin of SALOMEDS_Study_i::Open");
+   
+   std::string aUrl = Kernel_Utils::encode_s(aWUrl);
+   bool res = _impl->Open(std::string(aUrl));
+   // update desktop title with new study name
+   NameChanged();
+   if ( !res )
+     THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM)
+   return res;
+ }
++PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA()
++{
++  return _poa;
++}
++
++void SALOMEDS_Study_i::SetThePOA(PortableServer::POA_ptr thePOA)
++{
++  _poa = PortableServer::POA::_duplicate(thePOA);
++}
++
+ //============================================================================
+ /*! Function : Save
+  *  Purpose  : Save a Study to it's persistent reference
+  */
+ //============================================================================
+ CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
+ {
+   SALOMEDS::Locker lock;
    if (_closed)
-     throw SALOMEDS::Study::StudyInvalidReference();  
-   return CORBA::string_dup(_impl->GetPersistentReference().c_str());
+     throw SALOMEDS::Study::StudyInvalidReference();
+   return _impl->Save(_factory, theMultiFile, theASCII);
+ }
+ //=============================================================================
+ /*! Function : SaveAs
+  *  Purpose  : Save a study to the persistent reference aUrl
+  */
+ //============================================================================
+ CORBA::Boolean SALOMEDS_Study_i::SaveAs(const wchar_t* aWUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII)
+ {
+   SALOMEDS::Locker lock;
+   if (_closed)
+     throw SALOMEDS::Study::StudyInvalidReference();
+   
+   std::string aUrl = Kernel_Utils::encode_s(aWUrl);
+   return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile, theASCII);
+ }
+ //============================================================================
+ /*! Function : CanCopy
+  *  Purpose  :
+  */
+ //============================================================================
+ CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
+ {
+   SALOMEDS::Locker lock;
+   if (_closed)
+     throw SALOMEDS::Study::StudyInvalidReference();
+   CORBA::String_var anID = theObject->GetID();
+   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
+   SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+   bool ret = _impl->CanCopy(anObject, aDriver);
+   delete aDriver;
+   return ret;
+ }
+ //============================================================================
+ /*! Function : Copy
+  *  Purpose  :
+  */
+ //============================================================================
+ CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
+ {
+   SALOMEDS::Locker lock;
+   if (_closed)
+     throw SALOMEDS::Study::StudyInvalidReference();
+   CORBA::String_var anID = theObject->GetID();
+   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
+   SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+   bool ret = _impl->Copy(anObject, aDriver);
+   delete aDriver;
+   return ret;
+ }
+ //============================================================================
+ /*! Function : CanPaste
+  *  Purpose  :
+  */
+ //============================================================================
+ CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
+ {
+   SALOMEDS::Locker lock;
+   if (_closed)
+     throw SALOMEDS::Study::StudyInvalidReference();
+   CORBA::String_var anID = theObject->GetID();
+   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
+   SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+   bool ret = _impl->CanPaste(anObject, aDriver);
+   delete aDriver;
+   return ret;
+ }
+ //============================================================================
+ /*! Function : Paste
+  *  Purpose  :
+  */
+ //============================================================================
+ SALOMEDS::SObject_ptr SALOMEDS_Study_i::Paste(SALOMEDS::SObject_ptr theObject)
+      throw(SALOMEDS::StudyBuilder::LockProtection)
+ {
+   SALOMEDS::Locker lock;
+   Unexpect aCatch(LockProtection);
+   CORBA::String_var anID = theObject->GetID();
+   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
+   SALOMEDSImpl_SObject aNewSO;
+   try {
+     SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
+     aNewSO =  _impl->Paste(anObject, aDriver);
+     delete aDriver;
+   }
+   catch (...) {
+     throw SALOMEDS::StudyBuilder::LockProtection();
+   }
+   SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aNewSO, _orb);
+   return so._retn();
  }
+ SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb)
+ {
+   SALOMEDS_Driver_i* driver = NULL;
+   SALOMEDSImpl_SComponent aSCO = theObject.GetFatherComponent();
+   if(!aSCO.IsNull()) {
+     std::string IOREngine = aSCO.GetIOR();
+     if(!IOREngine.empty()) {
+       CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str());
+       Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ;
+       driver = new SALOMEDS_Driver_i(Engine, orb);
+     }
+   }
+   return driver;
+ }
  //============================================================================
- /*! Function : GetTransientReference
-  *  Purpose  : Get IOR of the Study (registered in OCAF document in doc->Root)
+ /*! Function : GetPersistentReference
+  *  Purpose  : Get persistent reference of study (idem URL())
   */
  //============================================================================
- char* SALOMEDS_Study_i::GetTransientReference()
+ char* SALOMEDS_Study_i::GetPersistentReference()
  {
    SALOMEDS::Locker lock; 
    if (_closed)
index 59fed56643c5fbd007b6f4515525ae3b4dff9e1f,d1c3d7f22eb546f915d980acaa785fa7aba609cb..f77d1e2c594ed81f4dc7f08ff5dde5b913d8dca7
@@@ -61,13 -63,43 +63,46 @@@ private
  public:
  
    //! standard constructor
-   SALOMEDS_Study_i(SALOMEDSImpl_Study*, CORBA::ORB_ptr);
+   SALOMEDS_Study_i(CORBA::ORB_ptr);
    
    //! standard destructor
-   virtual ~SALOMEDS_Study_i(); 
++
+   virtual ~SALOMEDS_Study_i();
 -  
 +
 +  virtual PortableServer::POA_ptr _default_POA();
-   
++
+   virtual void Init();
+   virtual void Clear();
+   //! method to Open a Study
+   /*!
+     \param char* arguments, the study URL
+     \return Study_ptr arguments
+   */
+   virtual bool Open(const wchar_t* aStudyUrl) throw (SALOME::SALOME_Exception);
+   //! method to save a Study
+   virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
+   //! method to save a Study to the persistent reference aUrl
+   /*!
+     \param char* arguments, the new URL of the study
+   */
+   virtual CORBA::Boolean SaveAs(const wchar_t* aUrl, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
+   //! method to copy the object
+   /*!
+     \param theObject object to copy
+   */
+   virtual CORBA::Boolean Copy(SALOMEDS::SObject_ptr theObject);
+   virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
+   //! method to paste the object in study
+   /*!
+     \param theObject object to paste
+   */
+   virtual SALOMEDS::SObject_ptr Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection);
+   virtual CORBA::Boolean CanPaste(SALOMEDS::SObject_ptr theObject);
    //! method to Get persistent reference of study (idem URL())
    /*!
      \sa URL()
  
    virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
  
++  static void SetThePOA(PortableServer::POA_ptr);
++  static PortableServer::POA_ptr GetThePOA();
++
+   void ping(){};
+   CORBA::Long getPID();
+   void ShutdownWithExit();
+   void Shutdown();
    virtual void attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify);
    virtual void detach(SALOMEDS::Observer_ptr theObs);
  };
index 4c4d3fdd4fb8138b9abc1e0e46800259cecc7ac6,118ab2d8120f3b5123ea895c448899ad04c7187b..5726f6b607d13dd155d55fab793aed4ba59ca31b
@@@ -27,8 -27,7 +27,8 @@@
  #include "SALOMEDS_UseCaseBuilder_i.hxx"
  #include "SALOMEDS_UseCaseIterator_i.hxx"
  #include "SALOMEDS_SObject_i.hxx"  
++#include "SALOMEDS_Study_i.hxx"
  #include "SALOMEDS.hxx"
- #include "SALOMEDS_StudyManager_i.hxx"
  
  #include "utilities.h"
  
@@@ -38,8 -37,7 +38,8 @@@
   */
  //============================================================================
  SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(SALOMEDSImpl_UseCaseBuilder* theImpl,
 -                                                     CORBA::ORB_ptr orb)
 +                                                     CORBA::ORB_ptr orb) :
-   GenericObj_i(SALOMEDS_StudyManager_i::GetThePOA())
++  GenericObj_i(SALOMEDS_Study_i::GetThePOA())
  {
    _orb = CORBA::ORB::_duplicate(orb);
    _impl = theImpl;
@@@ -54,23 -52,6 +54,23 @@@ SALOMEDS_UseCaseBuilder_i::~SALOMEDS_Us
  {
  }
  
-   myPOA = PortableServer::POA::_duplicate(SALOMEDS_StudyManager_i::GetThePOA());
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_UseCaseBuilder_i::_default_POA()
 +{
++  myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
 +  //MESSAGE("SALOMEDS_UseCaseBuilder_i::_default_POA: " << myPOA);
 +  return PortableServer::POA::_duplicate(myPOA);
 +}
 +
  
  //============================================================================
  /*! Function : Append
index dd34e11b7ed7cb7c2d14bcd1e4246debb45b98dd,cb3babe7672d7a2567f8d13d58f880bdc6b8d180..eb6a1ab8919408ccde333b5f9669b487299c043f
@@@ -26,8 -26,7 +26,8 @@@
  //
  #include "SALOMEDS_UseCaseIterator_i.hxx"
  #include "SALOMEDS_SObject_i.hxx"
++#include "SALOMEDS_Study_i.hxx"
  #include "SALOMEDS.hxx"
- #include "SALOMEDS_StudyManager_i.hxx"
  
  #include "SALOMEDSImpl_SObject.hxx"
  #include "utilities.h"
@@@ -38,8 -37,7 +38,8 @@@
   */
  //============================================================================
  SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(const SALOMEDSImpl_UseCaseIterator& theImpl, 
 -                                                       CORBA::ORB_ptr orb)
 +                                                       CORBA::ORB_ptr orb) :
-   GenericObj_i(SALOMEDS_StudyManager_i::GetThePOA())
++  GenericObj_i(SALOMEDS_Study_i::GetThePOA())
  {
    _orb = CORBA::ORB::_duplicate(orb);
    _impl = theImpl.GetPersistentCopy();
@@@ -55,23 -53,6 +55,23 @@@ SALOMEDS_UseCaseIterator_i::~SALOMEDS_U
      if(_impl) delete _impl;
  }
  
-   myPOA = PortableServer::POA::_duplicate(SALOMEDS_StudyManager_i::GetThePOA());
 +//============================================================================
 +/*!
 +  \brief Get default POA for the servant object.
 +
 +  This function is implicitly called from "_this()" function.
 +  Default POA can be set via the constructor.
 +
 +  \return reference to the default POA for the servant
 +*/
 +//============================================================================
 +PortableServer::POA_ptr SALOMEDS_UseCaseIterator_i::_default_POA()
 +{
++  myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
 +  //MESSAGE("SALOMEDS_UseCaseIterator_i::_default_POA: " << myPOA);
 +  return PortableServer::POA::_duplicate(myPOA);
 +}
 +
  //============================================================================
  /*! Function :Init
   * 
index 686f3ea5bfca36ae5b7d97c7fa29267d6910962d,29840b7f39252b99b81270218b49c40f15cd13e2..abb180c201425c3329301c285a873c377854890d
@@@ -43,15 -43,14 +43,14 @@@ public
    virtual ~SALOMEDSClient_SObject() {}
  
    virtual bool IsNull() const = 0;
 -  virtual std::string GetID()  = 0;
 +  virtual std::string GetID() = 0;
    virtual _PTR(SComponent) GetFatherComponent() = 0;
 -  virtual _PTR(SObject)    GetFather() = 0;
 -  virtual bool FindAttribute(_PTR(GenericAttribute)& anAttribute, const std::string& aTypeOfAttribute) = 0;
 -  virtual bool ReferencedObject(_PTR(SObject)& theObject) = 0;
 -  virtual bool FindSubObject(int theTag, _PTR(SObject)& theObject) = 0;
 +  virtual _PTR(SObject) GetFather() = 0;
 +  virtual bool FindAttribute(_PTR(GenericAttribute)& attribute, const std::string& type) = 0;
 +  virtual bool ReferencedObject(_PTR(SObject)& object) = 0;
 +  virtual bool FindSubObject(int tag, _PTR(SObject)& object) = 0;
-   virtual _PTR(Study) GetStudy() = 0;
    virtual std::string Name() = 0;
 -  virtual void  Name(const std::string& theName)  = 0;
 +  virtual void Name(const std::string& name) = 0;
    virtual std::vector<_PTR(GenericAttribute)> GetAllAttributes() = 0;
    virtual std::string GetName() = 0;
    virtual std::string GetComment() = 0;