From: rnv Date: Thu, 14 Jun 2018 08:33:23 +0000 (+0300) Subject: Merge V9_dev branch into master X-Git-Tag: SHAPER_V9_1_0RC1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8723fcf67b7efe234c1c63bb7139ee7a247ed421;p=modules%2Fkernel.git Merge V9_dev branch into master --- 8723fcf67b7efe234c1c63bb7139ee7a247ed421 diff --cc bin/launchConfigureParser.py index bde0a996e,e32982a54..e52313342 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@@ -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." diff --cc src/KERNEL_PY/salome_iapp.py index 0946fe371,24deed411..30ec34566 --- a/src/KERNEL_PY/salome_iapp.py +++ b/src/KERNEL_PY/salome_iapp.py @@@ -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 ): diff --cc src/Launcher/Test/test_launcher.py index 5087d6699,41c2d079a..339e4c875 --- a/src/Launcher/Test/test_launcher.py +++ b/src/Launcher/Test/test_launcher.py @@@ -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 ############################## diff --cc src/SALOMEDS/SALOMEDS.cxx index e6313314b,2d86b26de..b6fdf918b --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@@ -38,8 -38,6 +38,8 @@@ #include "SALOMEDS_Defines.hxx" ++#include ++ // IDL headers #include #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(); + } } diff --cc src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx index 3a17656b0,e5c3ad9e1..574cf45b0 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx @@@ -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; } +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA()); ++ myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA()); + //MESSAGE("SALOMEDS_ChildIterator_i::_default_POA: " << myPOA); + return PortableServer::POA::_duplicate(myPOA); +} + //============================================================================ /*! Function :Init * diff --cc src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index 114c0a228,5b98df2db..7014f54c8 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@@ -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_ { } +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA()); ++ 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; diff --cc src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx index 07b24a93c,cc7d6700f..35b3b34fb --- a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx @@@ -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; } +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA()); ++ myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA()); + MESSAGE("SALOMEDS_SComponentIterator_i::_default_POA: " << myPOA); + return PortableServer::POA::_duplicate(myPOA); +} + //============================================================================ /*! Function : Init * diff --cc src/SALOMEDS/SALOMEDS_SObject_i.cxx index bfff08d5e,2cf28a4cc..36e8cbb4c --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@@ -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; } +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA()); ++ 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 diff --cc src/SALOMEDS/SALOMEDS_Study.cxx index 50d658b7d,86629e271..f7ea3dc15 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@@ -68,10 -70,7 +70,10 @@@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS _isLocal = true; _local_impl = theStudy; _corba_impl = SALOMEDS::Study::_nil(); + + pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 ); + - init_orb(); + InitORB(); } SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) diff --cc src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index e3013e714,9ba49a326..f9ecf67a2 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@@ -68,23 -67,6 +67,23 @@@ SALOMEDS_StudyBuilder_i::SALOMEDS_Study SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i() {} +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA(); ++ 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) diff --cc src/SALOMEDS/SALOMEDS_Study_i.cxx index 3d99e2b73,19abf1b64..050f92500 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@@ -58,6 -59,11 +59,13 @@@ #include #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(); @@@ -269,46 -362,178 +364,205 @@@ _impl->setNotifier(0); delete _notifier; delete _genObjRegister; - //delete implementation - delete _impl; - _mapOfStudies.erase(_impl); - } + _notifier = NULL; + + _closed = true; + } +//============================================================================ +/*! + \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 = SALOMEDS_StudyManager_i::GetThePOA(); ++ 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) diff --cc src/SALOMEDS/SALOMEDS_Study_i.hxx index 59fed5664,d1c3d7f22..f77d1e2c5 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@@ -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() @@@ -347,6 -334,12 +337,15 @@@ 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); }; diff --cc src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx index 4c4d3fdd4,118ab2d81..5726f6b60 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@@ -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 { } +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA()); ++ myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA()); + //MESSAGE("SALOMEDS_UseCaseBuilder_i::_default_POA: " << myPOA); + return PortableServer::POA::_duplicate(myPOA); +} + //============================================================================ /*! Function : Append diff --cc src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx index dd34e11b7,cb3babe76..eb6a1ab89 --- a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx @@@ -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; } +//============================================================================ +/*! + \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_StudyManager_i::GetThePOA()); ++ myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA()); + //MESSAGE("SALOMEDS_UseCaseIterator_i::_default_POA: " << myPOA); + return PortableServer::POA::_duplicate(myPOA); +} + //============================================================================ /*! Function :Init * diff --cc src/SALOMEDSClient/SALOMEDSClient_SObject.hxx index 686f3ea5b,29840b7f3..abb180c20 --- a/src/SALOMEDSClient/SALOMEDSClient_SObject.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_SObject.hxx @@@ -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;