From 705780b6240c8ada097b7046989ce208c7a30f25 Mon Sep 17 00:00:00 2001 From: srn Date: Thu, 7 Apr 2005 04:55:32 +0000 Subject: [PATCH] Cnaged WNT on WIN32, modified methods for Copy/Paste in StudManager --- src/SALOMEDS/SALOMEDS_GenericAttribute.cxx | 4 +- src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx | 4 +- src/SALOMEDS/SALOMEDS_SObject.cxx | 10 ++- src/SALOMEDS/SALOMEDS_SObject_i.cxx | 4 +- src/SALOMEDS/SALOMEDS_Study.cxx | 4 +- src/SALOMEDS/SALOMEDS_StudyManager.cxx | 93 +++++++++++++++++--- src/SALOMEDS/SALOMEDS_StudyManager.hxx | 5 ++ src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 4 +- src/SALOMEDS/SALOMEDS_Study_i.cxx | 4 +- 9 files changed, 103 insertions(+), 29 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx index f9365c23a..440893473 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx @@ -11,7 +11,7 @@ using namespace std; #include "SALOMEDS_SObject.hxx" #include "SALOMEDS_ClientAttributes.hxx" -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -29,7 +29,7 @@ SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(const Handle(SALOMEDSImpl_G SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ptr theGA) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index 899f81cea..5e968a40f 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -13,7 +13,7 @@ using namespace std; #include #include -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -103,7 +103,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(cons //=========================================================================== long SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index a2c9392d9..81109cbe5 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -15,7 +15,7 @@ using namespace std; #include "SALOMEDS_Study.hxx" #include "SALOMEDSImpl_Study.hxx" -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -26,7 +26,7 @@ using namespace std; SALOMEDS_SObject::SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); @@ -57,8 +57,10 @@ SALOMEDS_SObject::~SALOMEDS_SObject() char* SALOMEDS_SObject::GetID() { - if(_isLocal) return _local_impl->GetID().ToCString(); - return _corba_impl->GetID(); + TCollection_AsciiString aValue; + if(_isLocal) aValue = _local_impl->GetID(); + else aValue = _corba_impl->GetID(); + return aValue.ToCString(); } SALOMEDSClient_SComponent* SALOMEDS_SObject::GetFatherComponent() diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index e70da136b..6954cd437 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -20,7 +20,7 @@ using namespace std; #include #include -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -308,7 +308,7 @@ char* SALOMEDS_SObject_i::GetIOR() //=========================================================================== long SALOMEDS_SObject_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 76cfc6306..1dd63654b 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -30,7 +30,7 @@ using namespace std; #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -49,7 +49,7 @@ SALOMEDS_Study::SALOMEDS_Study(const Handle(SALOMEDSImpl_Study)& theStudy) SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 9c6368fcd..559af5d82 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -8,8 +8,12 @@ using namespace std; #include "SALOMEDSImpl_Study.hxx" #include "SALOMEDS_Study.hxx" #include "SALOMEDS_SObject.hxx" +#include "SALOMEDS_Driver_i.hxx" -#ifdef WNT +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +#ifdef WIN32 #include #else #include @@ -21,10 +25,12 @@ using namespace std; #include "OpUtil.hxx" +SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb); + SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManager) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); @@ -39,6 +45,8 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManag _local_impl = NULL; _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager); } + + init_orb(); } SALOMEDS_StudyManager::~SALOMEDS_StudyManager() @@ -177,31 +185,90 @@ SALOMEDSClient_Study* SALOMEDS_StudyManager::GetStudyByID(int theStudyID) bool SALOMEDS_StudyManager::CanCopy(SALOMEDSClient_SObject* theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO); - //SRN: Pure CORBA call as SALOMEDS::Driver required for this method - return _corba_impl->CanCopy(aSO->GetCORBAImpl()); + bool ret; + + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); + ret = _local_impl->CanCopy(aSO_impl, GetDriver(aSO_impl, _orb)); + } + else { + ret = _corba_impl->CanCopy(aSO->GetCORBAImpl()); + } + + return ret; } bool SALOMEDS_StudyManager::Copy(SALOMEDSClient_SObject* theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO); - //SRN: Pure CORBA call as SALOMEDS::Driver required for this method - return _corba_impl->Copy(aSO->GetCORBAImpl()); + bool ret; + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); + ret = _local_impl->Copy(aSO_impl, GetDriver(aSO_impl, _orb)); + } + else { + ret = _corba_impl->Copy(aSO->GetCORBAImpl()); + } + return ret; } bool SALOMEDS_StudyManager::CanPaste(SALOMEDSClient_SObject* theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO); - //SRN: Pure CORBA call as SALOMEDS::Driver required for this method - return _corba_impl->CanPaste(aSO->GetCORBAImpl()); + bool ret; + + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); + ret = _local_impl->CanPaste(aSO_impl, GetDriver(aSO_impl, _orb)); + } + else { + ret = _corba_impl->CanPaste(aSO->GetCORBAImpl()); + } + + return ret; } SALOMEDSClient_SObject* SALOMEDS_StudyManager::Paste(SALOMEDSClient_SObject* theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO); - //SRN: Pure CORBA call as SALOMEDS::Driver required for this method - SALOMEDS::SObject_var aSO_impl = _corba_impl->Paste(aSO->GetCORBAImpl()); - if(CORBA::is_nil(aSO_impl)) return NULL; - SALOMEDS_SObject* aResultSO = new SALOMEDS_SObject(aSO_impl); - return aResultSO; + SALOMEDSClient_SObject* aResult = NULL; + + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); + Handle(SALOMEDSImpl_SObject) aNewSO = _local_impl->Paste(aSO_impl, GetDriver(aSO_impl, _orb)); + if(aNewSO.IsNull()) return NULL; + aResult = new SALOMEDS_SObject(aNewSO); + } + else { + SALOMEDS::SObject_ptr aNewSO = _corba_impl->Paste(aSO->GetCORBAImpl()); + if(CORBA::is_nil(aNewSO)) return NULL; + aResult = new SALOMEDS_SObject(aNewSO); + } + + return aResult; +} + + +void SALOMEDS_StudyManager::init_orb() +{ + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _orb = init(0 , 0 ) ; } +SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb) +{ + SALOMEDS_Driver_i* driver = NULL; + + Handle(SALOMEDSImpl_SComponent) aSCO = theObject->GetFatherComponent(); + if(!aSCO.IsNull()) { + TCollection_AsciiString IOREngine = aSCO->GetIOR(); + if(!IOREngine.IsEmpty()) { + CORBA::Object_var obj = orb->string_to_object(IOREngine.ToCString()); + SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; + driver = new SALOMEDS_Driver_i(Engine, orb); + } + } + + return driver; +} diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.hxx b/src/SALOMEDS/SALOMEDS_StudyManager.hxx index 6d8680227..908aa2b2c 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.hxx @@ -23,6 +23,8 @@ private: bool _isLocal; Handle(SALOMEDSImpl_StudyManager) _local_impl; SALOMEDS::StudyManager_var _corba_impl; + CORBA::ORB_var _orb; + public: SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManager); @@ -42,6 +44,9 @@ public: virtual bool Copy(SALOMEDSClient_SObject* theSO); virtual bool CanPaste(SALOMEDSClient_SObject* theSO); virtual SALOMEDSClient_SObject* Paste(SALOMEDSClient_SObject* theSO); + +private: + void init_orb(); }; #endif diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 1b3965924..960e10ac4 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -24,7 +24,7 @@ #include using namespace std; -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -416,7 +416,7 @@ SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORB //=========================================================================== long SALOMEDS_StudyManager_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 3298a7466..faed4024b 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -27,7 +27,7 @@ using namespace std; #include #include -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -714,7 +714,7 @@ CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath, const char* theB //=========================================================================== long SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal) { -#ifdef WNT +#ifdef WIN32 long pid = (long)_getpid(); #else long pid = (long)getpid(); -- 2.39.2