# -----------------------------------------------------------------------------
- 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."
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 ):
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
##############################
#include "SALOMEDS_Defines.hxx"
++#include <utilities.h>
++
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
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();
+ }
}
// 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"
*/
//============================================================================
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);
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
*
//
#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"
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;
{
}
- 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;
#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
//============================================================================
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();
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
*
//
#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"
* 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()) {
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
_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)
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)
#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
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)
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);
};
#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"
*/
//============================================================================
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;
{
}
- 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
//
#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"
*/
//============================================================================
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();
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
*
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;