X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSupervision%2FValue_Impl.cxx;h=96e7d75df06afec9ac3efbe76bf1bf5b68374035;hb=cdb2f93a5988bb23d473aae5cd019eac07c05c4d;hp=bd87bcb3841c99a988aff340868661aa155c4de4;hpb=08511b1f8b8a960573a076bd47e21fac8afe23b7;p=modules%2Fsuperv.git diff --git a/src/Supervision/Value_Impl.cxx b/src/Supervision/Value_Impl.cxx index bd87bcb..96e7d75 100644 --- a/src/Supervision/Value_Impl.cxx +++ b/src/Supervision/Value_Impl.cxx @@ -29,13 +29,16 @@ using namespace std; #include #include -#include +//#include +//#include #include -#include "utilities.h" +//#include "utilities.h" #include "Value_Impl.hxx" +#include "DataFlowExecutor_DataFlow.hxx" + Value_Impl::Value_Impl( CORBA::ORB_ptr orb , PortableServer::POA_ptr poa , PortableServer::ObjectId * contId , @@ -62,9 +65,17 @@ Value_Impl::Value_Impl( CORBA::ORB_ptr orb , if ( ParameterName != NULL ) { _ParameterName = new char[ strlen( ParameterName ) + 1 ] ; strcpy( _ParameterName , ParameterName ) ; + if ( DataFlowNode ) { + _NodeName = new char[ strlen( DataFlowNode->Name() ) + 1 ] ; + strcpy( _NodeName , DataFlowNode->Name() ) ; + } + else { + _NodeName = NULL ; + } } else { _ParameterName = NULL ; + _NodeName = NULL ; } _InputValue = false ; _Any = new CORBA::Any( *anAny ) ; @@ -95,9 +106,17 @@ Value_Impl::Value_Impl( CORBA::ORB_ptr orb , if ( ParameterName != NULL ) { _ParameterName = new char[ strlen( ParameterName ) + 1 ] ; strcpy( _ParameterName , ParameterName ) ; + if ( DataFlowNode ) { + _NodeName = new char[ strlen( DataFlowNode->Name() ) + 1 ] ; + strcpy( _NodeName , DataFlowNode->Name() ) ; + } + else { + _NodeName = NULL ; + } } else { _ParameterName = NULL ; + _NodeName = NULL ; } _InputValue = false ; _Any = new CORBA::Any() ; @@ -135,6 +154,7 @@ bool Value_Impl::Input( const CORBA::Any * anAny ) { } CORBA::Any * Value_Impl::ToAny() { + beginService( "Value_Impl::ToAny" ); CORBA::Any * anAny ; if ( _DataFlowEditor ) { char * name ; @@ -142,8 +162,9 @@ CORBA::Any * Value_Impl::ToAny() { name = _DataFlowNode->Name() ; } else { - name = _DataFlowEditor->Name() ; + name = _DataFlowEditor->Graph()->Name() ; } + MESSAGE( "ToAny " << name<< "( " << _ParameterName << " )" ) ; if ( _InputPort ) { if ( _DataFlowNode ) { _InputValue = _DataFlowNode->HasInput( _ParameterName ) ; @@ -151,57 +172,53 @@ CORBA::Any * Value_Impl::ToAny() { else { _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; } - if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = new CORBA::Any( * _DataFlowEditor->GetInData( name , + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { +//JR 30.03.2005 anAny = new CORBA::Any( * _DataFlowExecutor->GetInData( name , + anAny = new CORBA::Any( _DataFlowExecutor->GetInData( name , _ParameterName ) ) ; } + else if ( _InputValue ) { +//JR 30.03.2005 anAny = new CORBA::Any( * _DataFlowEditor->GetInData( name , + anAny = new CORBA::Any( _DataFlowEditor->GetInData( name , + _ParameterName ) ) ; + } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = new CORBA::Any( * _DataFlowExecutor->GetInData( name , - _ParameterName ) ) ; - } - else { - anAny = new CORBA::Any( *_Any ) ; - } + anAny = new CORBA::Any( *_Any ) ; } } else { - if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = new CORBA::Any( * _DataFlowEditor->GetOutData( name , + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { +//JR 30.03.2005 anAny = new CORBA::Any( * _DataFlowExecutor->GetOutData( name , + anAny = new CORBA::Any( _DataFlowExecutor->GetOutData( name , _ParameterName ) ) ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = new CORBA::Any( * _DataFlowExecutor->GetOutData( name , - _ParameterName ) ) ; - } - else { - anAny = new CORBA::Any( *_Any ) ; - } + anAny = new CORBA::Any( *_Any ) ; } } } else { anAny = new CORBA::Any( *_Any ) ; } + endService( "Value_Impl::ToAny" ); return anAny ; } char * Value_Impl::ToString() { // beginService( "Value_Impl::ToString" ); - CORBA::Any anAny = *ToAny() ; -// cout << "Value_Impl::ToString " << _DataFlowNode->Name() << " " -// << _ParameterName << " " ; +//JR 22.03.2005 Memory Leak CORBA::Any anAny = *ToAny() ; + CORBA::Any anAny ; if ( _DataFlowEditor ) { char * name ; if ( _DataFlowNode ) { name = _DataFlowNode->Name() ; } else { - name = _DataFlowEditor->Name() ; + name = _DataFlowEditor->Graph()->Name() ; } +// MESSAGE( "ToString " << name<< "( " << _ParameterName << " )" ) ; if ( _InputPort ) { if ( _DataFlowNode ) { _InputValue = _DataFlowNode->HasInput( _ParameterName ) ; @@ -209,64 +226,81 @@ char * Value_Impl::ToString() { else { _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; } - if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = * _DataFlowEditor->GetInData( name , - _ParameterName ) ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { +// cout << "-->_DataFlowExecutor->GetInData " << name << " " << _ParameterName << endl ; +//JR 30.03.2005 const CORBA::Any * AnyPtr = _DataFlowExecutor->GetInData( name , + const CORBA::Any AnyRef = _DataFlowExecutor->GetInData( name , + _ParameterName ) ; +//JR 30.03.2005 cout << "<--_DataFlowExecutor->GetInData " << AnyPtr << endl ; +//JR 30.03.2005 anAny = * AnyPtr ; + anAny = AnyRef ; + } + else if ( _InputValue ) { +// cout << "_DataFlowEditor->GetInData _DataFlowNode " << _DataFlowNode +// << " _InputValue " << _InputValue << endl ; +//JR 30.03.2005 anAny = * _DataFlowEditor->GetInData( name , + anAny = _DataFlowEditor->GetInData( name , + _ParameterName ) ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = * _DataFlowExecutor->GetInData( name , - _ParameterName ) ; - } + anAny = *_Any ; } } else { - if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = * _DataFlowEditor->GetOutData( name , - _ParameterName ) ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { +// cout << "-->_DataFlowExecutor->GetOutData " << name << " " << _ParameterName << endl ; +//JR 30.03.2005 const CORBA::Any * AnyPtr = _DataFlowExecutor->GetOutData( name , + const CORBA::Any AnyRef = _DataFlowExecutor->GetOutData( name , + _ParameterName ) ; +//JR 30.03.2005 cout << "<--_DataFlowExecutor->GetOutData " << AnyPtr << endl ; +//JR 30.03.2005 anAny = * AnyPtr ; + anAny = AnyRef ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = * _DataFlowExecutor->GetOutData( name , - _ParameterName ) ; - } + anAny = *_Any ; } } } - char* retstr ; + ostringstream astr ; + const char * retstr ; + int startstr = 0 ; switch (anAny.type()->kind()) { case CORBA::tk_string: { anAny >>= retstr; -// MESSAGE( "ToString( string ) " << retstr ); - break ; - } - case CORBA::tk_double: { - double d; - anAny >>= d; - retstr = new char[13]; - snprintf(retstr, 13, "%lf", d); -// MESSAGE( "ToString( double ) " << retstr ); +// MESSAGE( "ToString( string ) '" << retstr << "'" ); break ; } case CORBA::tk_long: { long l; anAny >>= l; - retstr = new char[13]; - snprintf(retstr, 13, "%ld", l); -// MESSAGE( "ToString( long ) " << retstr ); + astr << l << ends ; + retstr = astr.str().c_str() ; +// MESSAGE( "ToString( long ) '" << l << " " << retstr << "'" ); + break ; + } + case CORBA::tk_double: { + double d; + anAny >>= d; + astr << setw(25) << setprecision(18) << d << ends ; + retstr = astr.str().c_str() ; + int i = 0 ; + while ( i < (int ) strlen( retstr ) && retstr[ i++ ] == ' ' ) { + startstr = i ; + } +// MESSAGE( "ToString( double ) '" << d << "' '" << retstr << "' '" << &retstr[ startstr ] << "'"); break ; } case CORBA::tk_objref: { CORBA::Object_ptr obj ; try { anAny >>= obj ; - retstr = _Orb->object_to_string(obj ); -// MESSAGE( "ToString( object ) " << retstr ); + retstr = _Orb->object_to_string( obj ); +// MESSAGE( "ToString( object ) '" << retstr << "'" ); } catch ( ... ) { - retstr = "Unknown CORBA::Any Type" ; + retstr = "object_to_string catched " ; } break ; } @@ -277,7 +311,7 @@ char * Value_Impl::ToString() { } } // endService( "Value_Impl::ToString" ); - return CORBA::string_dup( retstr ) ; + return CORBA::string_dup( &retstr[ startstr ] ) ; } bool Value_Impl::IsIOR() { @@ -288,7 +322,7 @@ bool Value_Impl::IsIOR() { name = _DataFlowNode->Name() ; } else { - name = _DataFlowEditor->Name() ; + name = _DataFlowEditor->Graph()->Name() ; } if ( _InputPort ) { if ( _DataFlowNode ) { @@ -298,27 +332,31 @@ bool Value_Impl::IsIOR() { _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; } if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = * _DataFlowEditor->GetInData( name , - _ParameterName ) ; +//JR 30.03.2005 anAny = * _DataFlowEditor->GetInData( name , + anAny = _DataFlowEditor->GetInData( name , + _ParameterName ) ; } else { GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; if ( _DataFlowExecutor ) { - anAny = * _DataFlowExecutor->GetInData( name , - _ParameterName ) ; +//JR 30.03.2005 anAny = * _DataFlowExecutor->GetInData( name , + anAny = _DataFlowExecutor->GetInData( name , + _ParameterName ) ; } } } else { if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = * _DataFlowEditor->GetOutData( name , - _ParameterName ) ; +//JR 30.03.2005 anAny = * _DataFlowEditor->GetOutData( name , + anAny = _DataFlowEditor->GetOutData( name , + _ParameterName ) ; } else { GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; if ( _DataFlowExecutor ) { - anAny = * _DataFlowExecutor->GetOutData( name , - _ParameterName ) ; +//JR 30.03.2005 anAny = * _DataFlowExecutor->GetOutData( name , + anAny = _DataFlowExecutor->GetOutData( name , + _ParameterName ) ; } } } @@ -328,7 +366,7 @@ bool Value_Impl::IsIOR() { char* Value_Impl::ComponentDataType() { GraphExecutor::DataFlow* _DataFlowExecutor = _DataFlowEditor->Executor(); - const GraphBase::ComputingNode* node = _DataFlowExecutor->GetGraphNode(_DataFlowNode->Name()); + const GraphBase::ComputingNode* node = _DataFlowExecutor->Graph()->GetGraphNode(_DataFlowNode->Name()); if ( node->IsFactoryNode() ) { Engines::Component_var compo = ((GraphBase::FactoryNode * ) node )->Component(); if ( CORBA::is_nil( compo ) ) {