//
#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;
+ _mapOfStudies.erase(_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
SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(anItr, _orb);
- SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this());
- return it;
+ return it_servant->_this();
}
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;
SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
for (; itcomponent->More(); itcomponent->Next()) {
SALOMEDS::SComponent_var sco = itcomponent->Value();
- MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType());
+ CORBA::String_var compodatatype=sco->ComponentDataType();
+ MESSAGE ( "Look for an engine for data type :"<< compodatatype);
// if there is an associated Engine call its method for closing
CORBA::String_var IOREngine;
if (sco->ComponentIOR(IOREngine)) {
// we have found the associated engine to write the data
- MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType());
- CORBA::Object_var obj = _orb->string_to_object(IOREngine);
- if (!CORBA::is_nil(obj)) {
- SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
-
- if (!anEngine->_is_nil()) {
- SALOMEDS::unlock();
- anEngine->Close(sco);
- SALOMEDS::lock();
- }
- }
+ MESSAGE ( "We have found an engine for data type :"<< compodatatype);
+ //_narrow can throw a corba exception
+ try
+ {
+ CORBA::Object_var obj = _orb->string_to_object(IOREngine);
+ if (!CORBA::is_nil(obj))
+ {
+ SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
+ if (!anEngine->_is_nil())
+ {
+ SALOMEDS::unlock();
+ anEngine->Close(sco);
+ SALOMEDS::lock();
+ }
+ }
+ }
+ catch (CORBA::Exception&)
+ {/*pass*/ }
}
+ sco->Destroy();
}
+ //Does not need any more this iterator
+ itcomponent->Destroy();
+
+
_impl->Close();
}
SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
}
+//============================================================================
+/*! Function : SetString
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue)
+{
+ _impl->SetStringVariable(string(theVarName),
+ theValue,
+ SALOMEDSImpl_GenericVariable::STRING_VAR);
+}
+
+//============================================================================
+/*! Function : SetStringAsDouble
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue)
+{
+ _impl->SetStringVariableAsDouble(string(theVarName),
+ theValue,
+ SALOMEDSImpl_GenericVariable::STRING_VAR);
+}
+
//============================================================================
/*! Function : GetReal
* Purpose :
return (bool)_impl->GetVariableValue(string(theVarName));
}
+//============================================================================
+/*! Function : GetString
+ * Purpose :
+ */
+//============================================================================
+char* SALOMEDS_Study_i::GetString(const char* theVarName)
+{
+ return CORBA::string_dup(_impl->GetStringVariableValue(string(theVarName)).c_str());
+}
+
//============================================================================
/*! Function : IsReal
* Purpose :
SALOMEDSImpl_GenericVariable::BOOLEAN_VAR);
}
+//============================================================================
+/*! Function : IsString
+ * Purpose :
+ */
+//============================================================================
+CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName)
+{
+ return _impl->IsTypeOf(string(theVarName),
+ SALOMEDSImpl_GenericVariable::STRING_VAR);
+}
+
//============================================================================
/*! Function : IsVariable
* Purpose :