using namespace std;
#include "SALOMEDS_SComponent.hxx"
+#include "SALOMEDS_SComponent_i.hxx"
#include <string>
#include <TCollection_AsciiString.hxx>
return ret;
}
+
+SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent()
+{
+ if(_isLocal) {
+ if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
+ return SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()), _orb);
+ }
+ else {
+ return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
+ }
+
+ return SALOMEDS::SComponent::_nil();
+}
+
virtual std::string ComponentDataType();
virtual bool ComponentIOR(std::string& theID);
+
+ SALOMEDS::SComponent_ptr GetSComponent();
};
#endif
#include "SALOMEDS_Study.hxx"
#include "SALOMEDSImpl_Study.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
#ifdef WIN32
#include <process.h>
#else
long addr = theSObject->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
if(_isLocal) {
_local_impl = ((SALOMEDSImpl_SObject*)(addr));
- _corba_impl = SALOMEDS::SObject::_nil();
+ _corba_impl = SALOMEDS::SObject::_duplicate(theSObject);
}
else {
_local_impl = NULL;
_corba_impl = SALOMEDS::SObject::_duplicate(theSObject);
}
+
+ init_orb();
}
SALOMEDS_SObject::SALOMEDS_SObject(const Handle(SALOMEDSImpl_SObject)& theSObject)
{
_corba_impl = SALOMEDS::SObject::_nil();
_local_impl = theSObject;
+
+ init_orb();
}
SALOMEDS_SObject::~SALOMEDS_SObject()
CORBA::Object_ptr SALOMEDS_SObject::GetObject()
{
- CORBA::Object_var obj;
if(_isLocal) {
std::string anIOR = GetIOR();
- SALOMEDS_Study* aStudy = dynamic_cast<SALOMEDS_Study*>(GetStudy());
- obj = CORBA::Object::_duplicate(aStudy->ConvertIORToObject(anIOR));
- delete aStudy;
+ return _orb->string_to_object(anIOR.c_str());
+ }
+ else return _corba_impl->GetObject();
+
+ return CORBA::Object::_nil();
+}
+
+SALOMEDS::SObject_ptr SALOMEDS_SObject::GetSObject()
+{
+ if(_isLocal) {
+ if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
+ return SALOMEDS_SObject_i::New(_local_impl, _orb);
+ }
+ else {
+ return _corba_impl;
}
- else obj = CORBA::Object::_duplicate(_corba_impl->GetObject());
- return obj._retn();
+ return SALOMEDS::SObject::_nil();
+}
+
+
+void SALOMEDS_SObject::init_orb()
+{
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(0 , 0 ) ;
}
{
protected:
-bool _isLocal;
-Handle(SALOMEDSImpl_SObject) _local_impl;
-SALOMEDS::SObject_var _corba_impl;
+ bool _isLocal;
+ Handle(SALOMEDSImpl_SObject) _local_impl;
+ SALOMEDS::SObject_var _corba_impl;
+ CORBA::ORB_var _orb;
public:
virtual int Depth();
CORBA::Object_ptr GetObject();
+ SALOMEDS::SObject_ptr GetSObject();
+
SALOMEDS::SObject_ptr GetCORBAImpl() { return SALOMEDS::SObject::_duplicate(_corba_impl); }
- Handle(SALOMEDSImpl_SObject) GetLocalImpl() { return _local_impl; }
+ Handle(SALOMEDSImpl_SObject) GetLocalImpl() { return _local_impl; }
+
+private:
+ void init_orb();
};
#endif
long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
if(_isLocal) {
_local_impl = ((SALOMEDSImpl_Study*)(addr));
- _corba_impl = SALOMEDS::Study::_nil();
+ _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
}
else {
_local_impl = NULL;
SALOMEDSClient_SObject* SALOMEDS_Study::FindObject(const std::string& anObjectName)
{
- SALOMEDS_SObject* aSO = NULL;
if(_isLocal) {
Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject((char*)anObjectName.c_str());
if(aSO_impl.IsNull()) return NULL;
- aSO = new SALOMEDS_SObject(aSO_impl);
+ Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO_impl);
+ if(!aSCO_impl.IsNull()) return new SALOMEDS_SComponent(aSCO_impl);
+ return new SALOMEDS_SObject(aSO_impl);
}
else {
SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str());
if(CORBA::is_nil(aSO_impl)) return NULL;
- aSO = new SALOMEDS_SObject(aSO_impl);
+ SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl);
+ if(!CORBA::is_nil(aSCO_impl)) return new SALOMEDS_SComponent(aSCO_impl);
+ return new SALOMEDS_SObject(aSO_impl);
}
- return aSO;
+ return NULL;
}
std::vector<SALOMEDSClient_SObject*> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName,
SALOMEDSClient_SObject* SALOMEDS_Study::FindObjectID(const std::string& anObjectID)
{
- SALOMEDS_SObject* aSO = NULL;
if(_isLocal) {
Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID((char*)anObjectID.c_str());
if(aSO_impl.IsNull()) return NULL;
- aSO = new SALOMEDS_SObject(aSO_impl);
+ return new SALOMEDS_SObject(aSO_impl);
}
else {
SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID((char*)anObjectID.c_str());
if(CORBA::is_nil(aSO_impl)) return NULL;
- aSO = new SALOMEDS_SObject(aSO_impl);
+ return new SALOMEDS_SObject(aSO_impl);
}
- return aSO;
+ return NULL;
}
SALOMEDSClient_SObject* SALOMEDS_Study::CreateObjectID(const std::string& anObjectID)
void SALOMEDS_Study::init_orb()
{
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
_orb = init(0 , 0 ) ;
}
SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy()
{
if(_isLocal) {
+ if(!CORBA::is_nil(_corba_impl)) return _corba_impl;
SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(_local_impl, _orb);
SALOMEDS::Study_var Study = Study_servant->_this();
return Study;
void SALOMEDS_StudyBuilder::init_orb()
{
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
_orb = init(0 , 0 ) ;
}
void SALOMEDS_StudyManager::init_orb()
{
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
_orb = init(0 , 0 ) ;
}