From: srn Date: Mon, 20 Mar 2006 12:29:52 +0000 (+0000) Subject: Implemented a possibility to dlopen SalomeDS libarary and create SObject, Study,... X-Git-Tag: OCC_3_2_0a2_TC~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f1e37195a44596733da918770a98ce16ab736d71;p=modules%2Fkernel.git Implemented a possibility to dlopen SalomeDS libarary and create SObject, Study, StudyBuilder, StudyManager objects --- diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx index 4a35577e1..6ea7ac472 100644 --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -26,21 +26,27 @@ // Module : SALOME // $Header$ -#ifndef WNT +#ifdef WNT #include #include #include #include +#include #include #include +#include +#include #include #else #include "SALOMEDS.hxx" #include "SALOMEDS_StudyManager.hxx" #include "SALOMEDS_Study.hxx" +#include "SALOMEDS_StudyBuilder.hxx" #include "SALOMEDS_SObject.hxx" #include "SALOMEDS_SComponent.hxx" #include "SALOMEDSClient.hxx" +#include "SALOMEDSClient_IParameters.hxx" +#include "SALOMEDS_IParameters.hxx" #include "SALOMEDS_StudyManager_i.hxx" #endif @@ -92,19 +98,28 @@ SALOMEDSClient_StudyManager* StudyManagerFactory() SALOMEDSClient_Study* StudyFactory(SALOMEDS::Study_ptr theStudy) { + if(CORBA::is_nil(theStudy)) return NULL; return new SALOMEDS_Study(theStudy); } SALOMEDSClient_SObject* SObjectFactory(SALOMEDS::SObject_ptr theSObject) { + if(CORBA::is_nil(theSObject)) return NULL; return new SALOMEDS_SObject(theSObject); } SALOMEDSClient_SComponent* SComponentFactory(SALOMEDS::SComponent_ptr theSComponent) { + if(CORBA::is_nil(theSComponent)) return NULL; return new SALOMEDS_SComponent(theSComponent); } +SALOMEDSClient_StudyBuilder* BuilderFactory(SALOMEDS::StudyBuilder_ptr theBuilder) +{ + if(CORBA::is_nil(theBuilder)) return NULL; + return new SALOMEDS_StudyBuilder(theBuilder); +} + SALOMEDSClient_StudyManager* CreateStudyManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa) { SALOMEDS_StudyManager_i * aStudyManager_i = new SALOMEDS_StudyManager_i(orb, root_poa); @@ -114,4 +129,33 @@ SALOMEDSClient_StudyManager* CreateStudyManager(CORBA::ORB_ptr orb, PortableServ return new SALOMEDS_StudyManager(); } +SALOMEDSClient_IParameters* GetIParameters(const _PTR(AttributeParameter)& ap) +{ + return new SALOMEDS_IParameters(ap); +} + + +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::Study_ptr ConvertStudy(const _PTR(Study)& theStudy) +{ + SALOMEDS_Study* study = _CAST(Study, theStudy); + if(!theStudy || !study) return SALOMEDS::Study::_nil(); + return study->GetStudy(); +} + +SALOMEDS::StudyBuilder_ptr ConvertBuilder(const _PTR(StudyBuilder)& theBuilder) +{ + SALOMEDS_StudyBuilder* builder = _CAST(StudyBuilder, theBuilder); + if(!theBuilder || !builder) return SALOMEDS::StudyBuilder::_nil(); + return builder->GetBuilder(); +} + + } diff --git a/src/SALOMEDS/SALOMEDS_IParameters.hxx b/src/SALOMEDS/SALOMEDS_IParameters.hxx index 4111e83f9..9c0e95760 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.hxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.hxx @@ -24,11 +24,12 @@ #include #include "SALOMEDSClient.hxx" +#include "SALOMEDSClient_IParameters.hxx" /*! Class which an interface to store the parameters of the objects */ -class SALOMEDS_IParameters +class SALOMEDS_IParameters: public SALOMEDSClient_IParameters { public: SALOMEDS_IParameters(const _PTR(AttributeParameter)& ap); @@ -127,17 +128,17 @@ public: /*! Enables/Disables the dumping visual parameters */ - static void setDumpPython(_PTR(Study) study, const std::string& theID = ""); + virtual void setDumpPython(_PTR(Study) study, const std::string& theID = ""); /*! Returns whether there is the dumping visual parameters */ - static bool isDumpPython(_PTR(Study) study, const std::string& theID = ""); + virtual bool isDumpPython(_PTR(Study) study, const std::string& theID = ""); /*! Returns a default name of the component where the visula parameters are stored. */ - static std::string getDefaultVisualComponent(); + virtual std::string getDefaultVisualComponent(); private: _PTR(AttributeParameter) _ap; diff --git a/src/SALOMEDS/SALOMEDS_SComponent.cxx b/src/SALOMEDS/SALOMEDS_SComponent.cxx index f061fcc5f..3f104bcfe 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent.cxx @@ -76,15 +76,14 @@ bool SALOMEDS_SComponent::ComponentIOR(std::string& theID) SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent() { - if (_isLocal) { - if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl()); - SALOMEDS::SComponent_var aSCO = - SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()), _orb); + if(_isLocal) { + if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_duplicate(SALOMEDS::SComponent::_narrow(GetCORBAImpl())); + SALOMEDS::SComponent_var aSCO = SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()), _orb); + _corba_impl = SALOMEDS::SComponent::_duplicate(aSCO); return aSCO._retn(); } else { - return SALOMEDS::SComponent::_narrow(GetCORBAImpl()); + return SALOMEDS::SComponent::_duplicate(SALOMEDS::SComponent::_narrow(GetCORBAImpl())); } - return SALOMEDS::SComponent::_nil(); } diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index 233c5fca8..d11a3cb1c 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -33,6 +33,7 @@ #include "SALOMEDS_SComponent.hxx" #include "SALOMEDS_GenericAttribute.hxx" #include "SALOMEDS_Study.hxx" +#include "SALOMEDS_SObject_i.hxx" #include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" @@ -310,12 +311,13 @@ CORBA::Object_ptr SALOMEDS_SObject::GetObject() SALOMEDS::SObject_ptr SALOMEDS_SObject::GetSObject() { if(_isLocal) { - if(!CORBA::is_nil(_corba_impl)) return _corba_impl; + if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SObject::_duplicate(_corba_impl); SALOMEDS::SObject_var aSO = SALOMEDS_SObject_i::New(_local_impl, _orb); + _corba_impl = SALOMEDS::SObject::_duplicate(aSO); return aSO._retn(); } else { - return _corba_impl; + return SALOMEDS::SObject::_duplicate(_corba_impl); } return SALOMEDS::SObject::_nil(); } diff --git a/src/SALOMEDS/SALOMEDS_SObject.hxx b/src/SALOMEDS/SALOMEDS_SObject.hxx index f947d1ad0..6ac8f1d26 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject.hxx @@ -33,7 +33,6 @@ #include #include CORBA_SERVER_HEADER(SALOMEDS) -#include "SALOMEDS_SObject_i.hxx" #include "SALOMEDSImpl_SObject.hxx" class Standard_EXPORT SALOMEDS_SObject: public virtual SALOMEDSClient_SObject diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 67220592e..c3e572f21 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -665,7 +665,7 @@ SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy() if (_isLocal) { SALOMEDS::Locker lock; - if (!CORBA::is_nil(_corba_impl)) return _corba_impl; + if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::Study::_duplicate(_corba_impl); std::string anIOR = _local_impl->GetTransientReference().ToCString(); SALOMEDS::Study_var aStudy; if (!_local_impl->IsError() && anIOR != "") { @@ -676,15 +676,17 @@ SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy() aStudy = aStudy_servant->_this(); _local_impl->SetTransientReference(_orb->object_to_string(aStudy)); } + _corba_impl = SALOMEDS::Study::_duplicate(aStudy); return aStudy._retn(); } else { - return _corba_impl; + return SALOMEDS::Study::_duplicate(_corba_impl); } return SALOMEDS::Study::_nil(); } + _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint) { SALOMEDSClient_AttributeParameter* AP = NULL; diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index e11a77eb4..d7c12eb6d 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -32,6 +32,7 @@ #include "SALOMEDS_SComponent.hxx" #include "SALOMEDS_GenericAttribute.hxx" #include "SALOMEDS_StudyManager.hxx" +#include "SALOMEDS_StudyBuilder_i.hxx" #include "SALOMEDS_Driver_i.hxx" @@ -515,6 +516,21 @@ void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string else _corba_impl->SetIOR(aSO->GetCORBAImpl(), (char*)theValue.c_str()); } +SALOMEDS::StudyBuilder_ptr SALOMEDS_StudyBuilder::GetBuilder() +{ + if(_isLocal) { + if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::StudyBuilder::_duplicate(_corba_impl); + SALOMEDS_StudyBuilder_i* servant = new SALOMEDS_StudyBuilder_i(_local_impl, _orb); + SALOMEDS::StudyBuilder_var aBuilder = servant->StudyBuilder::_this(); + _corba_impl = SALOMEDS::StudyBuilder::_duplicate(aBuilder); + return aBuilder._retn(); + } + else { + return SALOMEDS::StudyBuilder::_duplicate(_corba_impl); + } + return SALOMEDS::StudyBuilder::_nil(); +} + void SALOMEDS_StudyBuilder::init_orb() { ORB_INIT &init = *SINGLETON_::Instance(); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx index a40e19e4c..0db1647ab 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.hxx @@ -80,6 +80,8 @@ public: virtual void SetComment(const _PTR(SObject)& theSO, const std::string& theValue); virtual void SetIOR(const _PTR(SObject)& theSO, const std::string& theValue); + SALOMEDS::StudyBuilder_ptr GetBuilder(); + private: void CheckLocked(); void init_orb();