X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSupervision%2FSuperV_Impl.cxx;h=6806ada002e139db22e2a2b8399f7391a24b1060;hb=b27a45845d224c2c005c02bcccb780df2cb7ea0f;hp=ad556e9a9658b67c17ab45939d2a1974877a7d3a;hpb=72e4c8f5e1a0e0001cdb9cb1de59e0495966fd0c;p=modules%2Fsuperv.git diff --git a/src/Supervision/SuperV_Impl.cxx b/src/Supervision/SuperV_Impl.cxx index ad556e9..6806ada 100644 --- a/src/Supervision/SuperV_Impl.cxx +++ b/src/Supervision/SuperV_Impl.cxx @@ -82,13 +82,167 @@ SuperV_Impl::~SuperV_Impl() { void SuperV_Impl::Destroy() { beginService( "SuperV_Impl::Destroy" ); _poa->deactivate_object(*_id) ; - CORBA::release(_poa) ; +// CORBA::release(_poa) ; delete(_id) ; - _thisObj->_remove_ref(); +// _thisObj->_remove_ref(); Py_Finalize(); endService( "SuperV_Impl::Destroy" ); } +Engines::TMPFile * SuperV_Impl::DumpPython( CORBA::Object_ptr theStudy , + CORBA::Boolean isPublished , + CORBA::Boolean & isValidScript ) { + beginService( "Super_Impl::DumpPython" ); + bool success = true ; + SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theStudy ) ; +// typedef sequence TMPFile; + Engines::TMPFile_var aStreamPythonvar ; + SALOMEDS::SObject_var aStudyObject ; + SALOMEDS::SObject_var aStudyObjectValue ; + SUPERV::StreamGraph_var aStreamGraph ; + char * aGraph ; + string aStringGraph ; + string aStringRebuildData ; + aStringGraph = + "### This file is generated by SALOME automatically by dump python funcitonality\n" + "### of Supervisor component\n\n"; + aStringRebuildData = "def RebuildData( theStudy ) :\n" ; + if ( CORBA::is_nil( aStudy ) ) { + MESSAGE( "aStudy is_nil" ) ; + success = false ; + } + else { + SALOMEDS::SObject_var aStudyObject = aStudy->FindComponent( ComponentDataType() ) ; + if ( CORBA::is_nil( aStudyObject ) ) { + MESSAGE( "aStudyObject is_nil" ) ; + success = false ; + } + else { + SALOMEDS::ChildIterator_var aStudyChildIterator = aStudy->NewChildIterator( aStudyObject ) ; + bool importSuperV = true ; + for ( aStudyChildIterator->InitEx( true ) ; aStudyChildIterator->More() ; + aStudyChildIterator->Next() ) { + aStudyObjectValue = aStudyChildIterator->Value() ; + int aDepth = aStudyObjectValue->Depth() ; + char * aStudyObjectValueIOR = aStudyObjectValue->GetIOR() ; + MESSAGE( "Super_Impl::DumpPython aStudyObjectValueIOR " << aStudyObjectValueIOR + << " Depth " << aDepth ) ; + if ( strlen( aStudyObjectValueIOR ) ) { + CORBA::Object_var obj = CORBA::Object::_nil() ; + try { + obj = _Orb->string_to_object( aStudyObjectValueIOR ) ; + if ( !CORBA::is_nil( obj ) ) { + aStreamGraph = SUPERV::StreamGraph::_narrow( obj ) ; + if ( !CORBA::is_nil( aStreamGraph ) ) { + MESSAGE( "aStreamGraph " << aStreamGraph->Name() ) ; + aStreamGraph->IsValid() ; + aGraph = aStreamGraph->SavePY( importSuperV ) ; + importSuperV = false ; + aStringGraph += string( aGraph ) ; + aStringRebuildData += " " ; + aStringRebuildData += aStreamGraph->Name() ; + aStringRebuildData += " = Def" ; + aStringRebuildData += aStreamGraph->Name() ; + aStringRebuildData += "()\n" ; + aStringRebuildData += " aBuilder,aStudyObject" ; + ostringstream astr ; + astr << aDepth ; + aStringRebuildData += astr.str() ; + aStringRebuildData += " = addDataflowToStudy( theStudy , " ; + aStringRebuildData += aStreamGraph->Name() ; + aStringRebuildData += " )\n" ; + isValidScript = true ; + } + else { + MESSAGE( "Super_Impl::DumpPython aStreamGraph is_nil ERROR" ) ; + success = false ; + break ; + } + } + } + catch ( ... ) { + char * aStudyObjectName = aStudyObjectValue->GetName() ; + ostringstream newastr ; + ostringstream astr ; + if ( strlen( aStudyObjectName ) ) { + MESSAGE( "Super_Impl::DumpPython aStudyObjectName " << aStudyObjectName ) ; + aStringRebuildData += " aStudyObject" ; + astr << aDepth ; + aStringRebuildData += astr.str() ; + aStringRebuildData += " = aBuilder.NewObject( aStudyObject" ; + newastr << (aDepth - 1 ) ; + aStringRebuildData += newastr.str() ; + aStringRebuildData += " )\n" ; + aStringRebuildData += " anAttr = aBuilder.FindOrCreateAttribute( aStudyObject" ; + aStringRebuildData += astr.str() ; + aStringRebuildData += " , 'AttributeName' )\n" ; + aStringRebuildData += " aName = anAttr._narrow( SALOMEDS.AttributeName )\n" ; + aStringRebuildData += " aName.SetValue( '" ; + aStringRebuildData += aStudyObjectName ; + aStringRebuildData += "' )\n" ; + } + else { + MESSAGE( "Super_Impl::DumpPython strlen( aStudyObjectName ) == 0 ERROR" ) ; + success = false ; + break ; + } + MESSAGE( "Super_Impl::DumpPython aStudyObjectValueIOR " << aStudyObjectValueIOR ) ; +//String in fact + aStringRebuildData += " anAttr = aBuilder.FindOrCreateAttribute( aStudyObject" ; + aStringRebuildData += astr.str() ; + aStringRebuildData += " , 'AttributeIOR')\n"; + aStringRebuildData += " anIORAttr = anAttr._narrow( SALOMEDS.AttributeIOR )\n"; + aStringRebuildData += " anIORAttr.SetValue( '" ; + aStringRebuildData += aStudyObjectValueIOR ; + aStringRebuildData += "' )\n" ; + } + } + else { + char * aStudyObjectName = aStudyObjectValue->GetName() ; + if ( strlen( aStudyObjectName ) ) { + MESSAGE( "Super_Impl::DumpPython aStudyObjectName " << aStudyObjectName << " Depth " + << aDepth ) ; + aStringRebuildData += " aStudyObject" ; + ostringstream astr ; + astr << aDepth ; + aStringRebuildData += astr.str() ; + aStringRebuildData += " = aBuilder.NewObject( aStudyObject" ; + ostringstream newastr ; + newastr << (aDepth - 1 ) ; + aStringRebuildData += newastr.str() ; + aStringRebuildData += " )\n" ; + aStringRebuildData += " anAttr = aBuilder.FindOrCreateAttribute( aStudyObject" ; + aStringRebuildData += astr.str() ; + aStringRebuildData += " , 'AttributeName' )\n" ; + aStringRebuildData += " aName = anAttr._narrow( SALOMEDS.AttributeName )\n" ; + aStringRebuildData += " aName.SetValue( '" ; + aStringRebuildData += aStudyObjectName ; + aStringRebuildData += "' )\n" ; + } + else { + MESSAGE( "Super_Impl::DumpPython strlen( aStudyObjectName ) == 0 ERROR" ) ; + success = false ; + break ; + } + } + } + } + } + if ( !success ) { + isValidScript = false ; + endService( "Super_Impl::DumpPython ERROR" ); + return new Engines::TMPFile( 0 ) ; + } + aStringRebuildData += " sg.updateObjBrowser( 1 )\n" ; + aStringRebuildData += " return 1\n" ; + aStringGraph += aStringRebuildData ; + int aLen = strlen( aStringGraph.c_str() ) ; + CORBA::Octet * anOctetBuffer = (CORBA::Octet * ) aStringGraph.c_str() ; + aStreamPythonvar = new Engines::TMPFile ( aLen+1 , aLen+1 , anOctetBuffer ,1 ) ; + endService( "Super_Impl::DumpPython" ); + return aStreamPythonvar._retn() ; +} + // void SuperV_Impl::Save(const char *IORSComponent, const char *aUrlOfFile) { SALOMEDS::TMPFile* SuperV_Impl::Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, @@ -609,6 +763,14 @@ SUPERV::Value_ptr SuperV_Impl::Value( CORBA::Any * anAny ) { return SUPERV::Value::_duplicate( iobject ) ; } +CORBA::Object_ptr SuperV_Impl::ToObject( CORBA::Object_ptr anObjectRef ) { + beginService( "SuperV_Impl::ToObject" ); + CORBA::Object_ptr anObject ; + anObject = CORBA::Object::_duplicate( anObjectRef ) ; + endService( "SuperV_Impl::ToObject" ); + return anObject ; +} + SUPERV::Graph_ptr SuperV_Impl::Graph(const char * aGraphName ) { beginService( "SuperV_Impl::Graph" ); bool created = true ;