MESSAGE("NewStudy : Creating the CORBA servant holding it... ");
- SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
+ SALOMEDS_Study_i *Study_servant = SALOMEDS_Study_i::GetStudyServant(aStudyImpl, _orb);
+ PortableServer::ObjectId_var servantid = _poa->activate_object(Study_servant); // to use poa registered in _mapOfPOA
SALOMEDS::Study_var Study = Study_servant->_this();
// Register study in the naming service
MESSAGE("Open : Creating the CORBA servant holding it... ");
// Temporary aStudyUrl in place of study name
- SALOMEDS_Study_i * Study_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
- SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this());
+ SALOMEDS_Study_i * Study_servant = SALOMEDS_Study_i::GetStudyServant(aStudyImpl, _orb);
+ PortableServer::ObjectId_var servantid = _poa->activate_object(Study_servant); // to use poa register in _mapOfPOA
+ SALOMEDS::Study_var Study = Study_servant->_this();
// Assign the value of the IOR in the study->root
CORBA::String_var IORStudy = _orb->object_to_string(Study);
if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" )
else _name_service->Register(Study, CORBA::string_dup(aStudyImpl->Name().c_str()));
- return Study;
+ return Study._retn();
}
SALOMEDS::unlock();
aStudy->Close();
SALOMEDS::lock();
+
+ //remove study servant
+ PortableServer::POA_ptr poa=GetPOA(aStudy);
+ PortableServer::ServantBase* aservant=poa->reference_to_servant(aStudy);
+ PortableServer::ObjectId_var anObjectId = poa->servant_to_id(aservant);
+ poa->deactivate_object(anObjectId.in());
+ aservant->_remove_ref(); // decrement for the call to reference_to_servant
+ aservant->_remove_ref(); // to delete the object
}
//============================================================================
return SALOMEDS::Study::_nil();
}
- SALOMEDS_Study_i* aStudy_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudy_servant->_this());
-
- return aStudy._retn();
+ SALOMEDS_Study_i* aStudy_servant = SALOMEDS_Study_i::GetStudyServant(aStudyImpl, _orb);
+ return aStudy_servant->_this();
}
//============================================================================
return SALOMEDS::Study::_nil();
}
- SALOMEDS_Study_i* aStudy_servant = new SALOMEDS_Study_i(aStudyImpl, _orb);
- CORBA::Object_var obj = aStudy_servant->_this();
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(obj);
-
- return aStudy._retn();
+ SALOMEDS_Study_i* aStudy_servant = SALOMEDS_Study_i::GetStudyServant(aStudyImpl, _orb);
+ return aStudy_servant->_this();
}
SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
- SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(theObject->GetID());
+ CORBA::String_var anID = theObject->GetID();
+ SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(anID.in());
SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
bool ret = _impl->CanCopy(anObject, aDriver);
SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
- SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(theObject->GetID());
+ CORBA::String_var anID = theObject->GetID();
+ SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(anID.in());
SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
bool ret = _impl->Copy(anObject, aDriver);
SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
- SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(theObject->GetID());
+ CORBA::String_var anID = theObject->GetID();
+ SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(anID.in());
SALOMEDS_Driver_i* aDriver = GetDriver(anObject, _orb);
bool ret = _impl->CanPaste(anObject, aDriver);
SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId());
- SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(theObject->GetID());
+ CORBA::String_var anID = theObject->GetID();
+ SALOMEDSImpl_SObject anObject = aStudyImpl->GetSObject(anID.in());
SALOMEDSImpl_SObject aNewSO;
try {
//
#include "utilities.h"
#include "SALOMEDS_Study_i.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
#include "SALOMEDS_UseCaseIterator_i.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
#include "SALOMEDS_AttributeStudyProperties_i.hxx"
using namespace std;
+std::map<SALOMEDSImpl_Study* , SALOMEDS_Study_i*> SALOMEDS_Study_i::_mapOfStudies;
+
//============================================================================
/*! Function : SALOMEDS_Study_i
* Purpose : SALOMEDS_Study_i constructor
//============================================================================
SALOMEDS_Study_i::~SALOMEDS_Study_i()
{
+ //delete the builder servant
+ PortableServer::POA_var poa=_builder->_default_POA();
+ PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
+ poa->deactivate_object(anObjectId.in());
+ _builder->_remove_ref();
+ //delete implementation
+ delete _impl;
}
//============================================================================
{
SALOMEDS::Locker lock;
- SALOMEDSImpl_SObject aSO = _impl->GetSObject(theSO->GetID());
+ CORBA::String_var anID=theSO->GetID();
+ SALOMEDSImpl_SObject aSO = _impl->GetSObject(anID.in());
SALOMEDSImpl_ChildIterator anItr(aSO);
//Create iterator
return SALOMEDS::Study::_nil();
}
+SALOMEDS_Study_i* SALOMEDS_Study_i::GetStudyServant(SALOMEDSImpl_Study* aStudyImpl, CORBA::ORB_ptr orb)
+{
+ if (_mapOfStudies.find(aStudyImpl) != _mapOfStudies.end())
+ return _mapOfStudies[aStudyImpl];
+ else
+ {
+ SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(aStudyImpl, orb);
+ _mapOfStudies[aStudyImpl]=Study_servant;
+ return Study_servant;
+ }
+}
+
void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute)
{
SALOMEDS::Locker lock;
catch (CORBA::Exception&)
{/*pass*/ }
}
+ sco->Destroy();
}
+ //Does not need any more this iterator
+ itcomponent->Destroy();
+
+
_impl->Close();
}
SALOMEDSImpl_AttributeIOR* anAttr = NULL; //Remove from IORLabel map
if ((anAttr=(SALOMEDSImpl_AttributeIOR*)Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
+ _study->DeleteIORLabelMapItem(anAttr->Value());
}
Lab.ForgetAllAttributes();
}
SALOMEDSImpl_AttributeIOR* anAttr = NULL; //Remove from IORLabel map
if ((anAttr=(SALOMEDSImpl_AttributeIOR*)Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
+ _study->DeleteIORLabelMapItem(anAttr->Value());
}
DF_ChildIterator it(Lab, true);
}
SALOMEDSImpl_AttributeIOR* anAttr = NULL; //Remove from IORLabel map
if ((anAttr=(SALOMEDSImpl_AttributeIOR*)aLabel.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
+ _study->DeleteIORLabelMapItem(anAttr->Value());
}
}
if (aTypeOfAttribute == string("AttributeIOR")) { // Remove from IORLabel map
SALOMEDSImpl_AttributeIOR* anAttr = NULL;
if ((anAttr=(SALOMEDSImpl_AttributeIOR*)Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
+ _study->DeleteIORLabelMapItem(anAttr->Value());
}
}