]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Implemented a possibility to dlopen SalomeDS libarary and create SObject, Study,...
authorsrn <srn@opencascade.com>
Mon, 20 Mar 2006 12:29:52 +0000 (12:29 +0000)
committersrn <srn@opencascade.com>
Mon, 20 Mar 2006 12:29:52 +0000 (12:29 +0000)
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDS/SALOMEDS_IParameters.hxx
src/SALOMEDS/SALOMEDS_SComponent.cxx
src/SALOMEDS/SALOMEDS_SObject.cxx
src/SALOMEDS/SALOMEDS_SObject.hxx
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.hxx

index 4a35577e12f33e2a9988df814177a7faed6b20ac..6ea7ac4728d4d18482ab2653a106827e3f4ffb73 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#ifndef WNT
+#ifdef WNT
 #include <SALOMEDS.hxx>
 #include <SALOMEDS_StudyManager.hxx>
 #include <SALOMEDS_Study.hxx>
 #include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_StudyBuilder.hxx>
 #include <SALOMEDS_SComponent.hxx>
 #include <SALOMEDSClient.hxx>
+#include <SALOMEDSClient_IParameters.hxx>
+#include <SALOMEDS_IParameters.hxx>
 #include <SALOMEDS_StudyManager_i.hxx>
 #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();
+}
+
+
 }
index 4111e83f978901b02068e57959c3cfa83d5a09a3..9c0e957607ff5ae11ce65aea6f00fb3254fbfdc2 100644 (file)
 #include <map>
 
 #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;
index f061fcc5f9d08d7e26b9251a846541a8d15cac4a..3f104bcfedac0c09701b904828fd543991b6a7bf 100644 (file)
@@ -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();
 }
index 233c5fca805dfd5d790d5418ff401ff459a4dec8..d11a3cb1ce7f54aa6f5ad0fa7cc53bc2697f8d30 100644 (file)
@@ -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();
 }
index f947d1ad089ee5b354691acec547c55be09ec259..6ac8f1d26015bb3720cc596006290d62d223915b 100644 (file)
@@ -33,7 +33,6 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
-#include "SALOMEDS_SObject_i.hxx"
 #include "SALOMEDSImpl_SObject.hxx"
 
 class Standard_EXPORT SALOMEDS_SObject: public virtual SALOMEDSClient_SObject
index 67220592ea50bd39eb33faacca6a697daf9deeca..c3e572f217042bea3be8dd65d1159c313745f511 100644 (file)
@@ -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;
index e11a77eb498a0d41f83270d5780b8aa81766eacd..d7c12eb6d73f62d16e40e2c512c6e974cd430d1e 100644 (file)
@@ -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_<ORB_INIT>::Instance();
index a40e19e4ce0fc7217dddf8c237b91ce51c0515bd..0db1647abed5fa78ccb7fb3ad3fb00e1028b5500 100644 (file)
@@ -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();