GraphBase::DataPort::DataPort() :
Port() {
pthread_mutex_init( &_MutexWait , NULL ) ;
- _State = SUPERV::UndefinedState ;
+ _PortState = SUPERV::UndefinedState ;
_Done = false ;
InitialValues( CORBA::Any() ) ;
}
const SALOME_ModuleCatalog::DataStreamDependency aDependency ) :
Port( NodeName , aserviceParameter , aKind , aDependency ) {
pthread_mutex_init( &_MutexWait , NULL ) ;
- _State = SUPERV::UndefinedState ;
+ _PortState = SUPERV::UndefinedState ;
_Done = false ;
InitialValues( CORBA::Any() ) ;
}
void GraphBase::DataPort::InitialValues(CORBA::Any aValue ) {
_theValue = new CORBA::Any( aValue ) ;
- string _Type = CORBA::string_dup(GetServicesParameter().Parametertype) ;
+//JR 24.02.2005 Memory Leak string _Type = CORBA::string_dup(GetServicesParameter().Parametertype) ;
+ string _Type = string( GetServicesParameter().Parametertype ) ;
const char * Type = _Type.c_str();
CORBA::Any InitialValue ;
cdebug << "InitialValues " << NodeName() << " " << PortName() << " " << PortType()
Value( aValue ) ;
}
+#define ValueTrace 0
void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) {
// cdebug << pthread_self() << " Value(aDataValue) --> pthread_mutex_lock " << &_MutexWait
// << endl ;
delete _theValue ;
- string _Type = CORBA::string_dup( GetServicesParameter().Parametertype ) ;
- const char * Type = _Type.c_str() ;
+//JR 21.02.2005 Debug Memory leak : string _Type = CORBA::string_dup( GetServicesParameter().Parametertype ) ;
+// const char * Type = _Type.c_str() ;
+ const char * Type = GetServicesParameter().Parametertype ;
_Value = &_theValue ;
+#if ValueTrace
cdebug << "NewValue " << NodeName() << " " << PortName() << " " << PortType()
<< " : " << aDataValue << " kind " << aDataValue->type()->kind() << " " ;
+#endif
switch (aDataValue->type()->kind()) { // Input Value
case CORBA::tk_string: { // Input string Value
char * t;
*aDataValue >>= t;
+#if ValueTrace
cdebug << t << " (string)" ;
+#endif
if ( !strcmp( Type , "string" ) ) { // SuperVision Value
_theValue = aDataValue ;
*_theValue >>= t;
+#if ValueTrace
cdebug << " == Value( " << t << ") (string)";
+#endif
}
else {
CORBA::Any * theValue = new CORBA::Any() ;
sscanf( t , "%ld" , &l ) ;
*theValue <<= l ;
*theValue >>= l;
+#if ValueTrace
cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ;
+#endif
}
else if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) {
double d ;
sscanf( t , "%lf" , &d ) ;
*theValue <<= d ;
*theValue >>= d;
+#if ValueTrace
cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ;
+#endif
}
else { // Default
CORBA::Object_ptr ObjRef ;
*theValue <<= CORBA::Object::_nil() ;
}
*theValue >>= ObjRef ;
+#if ValueTrace
cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind "
<< theValue->type()->kind() ;
+#endif
}
_theValue = theValue ;
*_Value = theValue ;
+//JR 21.02.2005 Debug Memory leak :
+ delete aDataValue ;
}
break;
}
case CORBA::tk_long: { // Input long Value
long l;
*aDataValue >>= l;
+#if ValueTrace
cdebug << "Value( " << l << ") (long)";
+#endif
if ( !strcmp( Type , "boolean" ) || !strcmp( Type , "char" ) ||
!strcmp( Type , "short" ) || !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) { // SuperVision Value
_theValue = aDataValue ;
*_Value = aDataValue ;
*_theValue >>= l;
+#if ValueTrace
cdebug << " == Value( " << l << ") (long)";
+#endif
}
else {
CORBA::Any * theValue = new CORBA::Any() ;
*theValue <<= t ;
char *tt ;
*theValue >>= tt ;
+#if ValueTrace
cdebug << " --> Value( " << t << ") (string) kind " << theValue->type()->kind() ;
+#endif
}
else if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) {
double d = l ;
*theValue <<= d ;
*theValue >>= d ;
+#if ValueTrace
cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ;
+#endif
}
else { // Default
CORBA::Object_ptr ObjRef ;
*theValue <<= CORBA::Object::_nil() ;
*theValue >>= ObjRef ;
+#if ValueTrace
cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind "
<< theValue->type()->kind() ;
+#endif
}
_theValue = theValue ;
*_Value = theValue ;
+//JR 21.02.2005 Debug Memory leak :
+ delete aDataValue ;
}
break;
}
case CORBA::tk_double: { // Input double Value
double d;
*aDataValue >>= d;
+#if ValueTrace
cdebug << "Value( " << d << ") (double)";
+#endif
if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) { // SuperVision Value
_theValue = aDataValue ;
*_Value = aDataValue ;
*_theValue >>= d;
+#if ValueTrace
cdebug << " == Value( " << d << ") (double)";
+#endif
}
else {
CORBA::Any * theValue = new CORBA::Any() ;
*theValue <<= t ;
char *tt ;
*theValue >>= tt ;
+#if ValueTrace
cdebug << " --> Value( " << t << ") (string) kind " << theValue->type()->kind() ;
+#endif
}
else if ( !strcmp( Type , "boolean" ) || !strcmp( Type , "char" ) ||
!strcmp( Type , "short" ) || !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
long l = (long ) d ;
*theValue <<= l ;
*theValue >>= l;
+#if ValueTrace
cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ;
+#endif
}
else { // Default
CORBA::Object_ptr ObjRef ;
*theValue <<= CORBA::Object::_nil() ;
*theValue >>= ObjRef ;
+#if ValueTrace
cdebug << " --> Value( " << ObjectToString( ObjRef ) << ") (object reference) kind "
<< theValue->type()->kind() ;
+#endif
}
_theValue = theValue ;
*_Value = theValue ;
+//JR 21.02.2005 Debug Memory leak :
+ delete aDataValue ;
}
break;
}
case CORBA::tk_objref: { // Input objref Value
CORBA::Object_ptr obj ;
*aDataValue >>= obj;
+#if ValueTrace
cdebug << "Value( " << ObjectToString( obj ) << ") (object reference)";
+#endif
if ( strcmp( Type , "string" ) &&
strcmp( Type , "boolean" ) && strcmp( Type , "char" ) &&
strcmp( Type , "short" ) && strcmp( Type , "long" ) &&
_theValue = aDataValue ;
*_Value = aDataValue ;
*_theValue >>= obj;
+#if ValueTrace
cdebug << " == Value( " << ObjectToString( obj ) << ") (object reference)";
+#endif
}
else {
CORBA::Any * theValue = new CORBA::Any() ;
if ( !strcmp( Type , "string" ) ) {
*theValue <<= ObjectToString( obj ) ;
*theValue >>= obj ;
+#if ValueTrace
cdebug << " --> Value( " << ObjectToString( obj ) << ") (string) kind " << theValue->type()->kind() ;
+#endif
}
else if ( !strcmp( Type , "boolean" ) || !strcmp( Type , "char" ) ||
!strcmp( Type , "short" ) || !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
long l = (long ) obj ;
*theValue <<= l ;
*theValue >>= l;
+#if ValueTrace
cdebug << " --> Value( " << l << ") (long) kind " << theValue->type()->kind() ;
+#endif
}
else if ( !strcmp( Type , "float" ) || !strcmp( Type , "double" ) ) {
double d = (double ) 0. ;
*theValue <<= d ;
*theValue >>= d;
+#if ValueTrace
cdebug << " --> Value( " << d << ") (double) kind " << theValue->type()->kind() ;
+#endif
}
_theValue = theValue ;
*_Value = theValue ;
+//JR 21.02.2005 Debug Memory leak :
+ delete aDataValue ;
}
break;
}
break;
}
}
+#if ValueTrace
cdebug << endl ;
+#endif
if ( pthread_mutex_unlock( &_MutexWait ) ) {
perror( "unlock DataValue" ) ;
exit( 0 ) ;
}
-void GraphBase::DataPort::Value( const CORBA::Any ** aDataSharedValue ) {
- delete _theValue ;
- _theValue = *aDataSharedValue ;
- _Value = aDataSharedValue ;
-// Done( true ) ;
-
-#if 0
- MESSAGE( NodePortName() << " : " << hex << _Value << " " );
- switch (_theValue->type()->kind()) {
- case CORBA::tk_string:
- char * t;
- *_theValue >>= t;
- MESSAGE( "Value( " << t << ") (string)");
- break;
- case CORBA::tk_double:
- double d;
- *_theValue >>= d;
- MESSAGE( "Value( " << d << ") (double)");
- break;
- case CORBA::tk_long:
- long l;
- *_theValue >>= l;
- MESSAGE( "Value( " << l << ") (long)");
- break;
- case CORBA::tk_objref:
- MESSAGE( "Value( " << ") (object reference)");
- break;
- default:
- MESSAGE( "Value" << " (other(tk_string,tk_double,tk_long,tk_objref)) ERROR");
- break;
- }
- MESSAGE();
-#endif
-}
-
-CORBA::Any const * GraphBase::DataPort::Value() const {
+// PAL8506
+//JR 30.03.2005 Memory Leak + Debug(crash) CORBA::Any const * GraphBase::DataPort::Value() const {
+const CORBA::Any GraphBase::DataPort::Value() const {
pthread_mutex_t * aMutexWait = (pthread_mutex_t *) &_MutexWait ;
// cdebug << pthread_self() << " Value() --> pthread_mutex_lock " << aMutexWait << endl ;
if ( pthread_mutex_lock( aMutexWait ) ) {
}
// cdebug << pthread_self() << " Value() --> pthread_mutex_locked " << aMutexWait << endl ;
const CORBA::Any *const Value = *_Value ;
- CORBA::Any * theValue ;
+//JR 30.03.2005 CORBA::Any * theValue ;
+ CORBA::Any theValue ;
// cdebug << pthread_self() << " Value " << NodeName() << " " << PortName() << " "
// << PortType() << " _Value " << _Value << " *_Value " << *_Value << " Value->type "
// << Value->type() ;
else {
// cdebug << " Null" << endl ;
}
- if ( Done() ) {
- theValue = new CORBA::Any( *Value ) ;
- switch ( theValue->type()->kind() ) {
+ if ( PortDone() ) {
+//JR 21.02.2005 Debug Memory leak : theValue = new CORBA::Any( *Value ) ;
+//JR 30.03.2005 theValue = (CORBA::Any * ) Value ;
+ theValue = *Value ;
+//JR 30.03.2005 switch ( theValue->type()->kind() ) {
+ switch ( theValue.type()->kind() ) {
case CORBA::tk_string: {
char * t;
- *theValue >>= t;
+//JR 30.03.2005 *theValue >>= t;
+ theValue >>= t;
// cdebug << "GraphBase::DataPort::Value() : " << t << " (string) " << endl ;
break;
}
case CORBA::tk_double: {
double d;
- *theValue >>= d;
+//JR 30.03.2005 *theValue >>= d;
+ theValue >>= d;
// cdebug << "GraphBase::DataPort::Value() : " << d << " (double) " << endl ;
break;
}
case CORBA::tk_long: {
long l;
- *theValue >>= l;
+//JR 30.03.2005 *theValue >>= l;
+ theValue >>= l;
// cdebug << "GraphBase::DataPort::Value() : " << l << " (long) " << endl ;
break;
}
CORBA::Object_ptr obj ;
char * retstr ;
try {
- *theValue >>= obj ;
+//JR 30.03.2005 *theValue >>= obj ;
+ theValue >>= obj ;
retstr = ObjectToString( obj );
// cdebug << "GraphBase::DataPort::Value() : " << retstr
// << "(object reference) " << endl;
}
else {
// cdebug << "GraphBase::DataPort::InitialValue() " << endl ;
- theValue = new CORBA::Any( *Value ) ;
+//JR 21.02.2005 Debug Memory leak : theValue = new CORBA::Any( *Value ) ;
+//JR 30.03.2005 theValue = (CORBA::Any * ) Value ;
+ theValue = *Value ;
}
if ( pthread_mutex_unlock( aMutexWait ) ) {
perror( "unlock DataValue" ) ;
bool GraphBase::DataPort::BoolValue() const {
bool RetVal = false ;
- long val ;
pthread_mutex_t * aMutexWait = (pthread_mutex_t *) &_MutexWait ;
// cdebug << pthread_self() << " BoolValue() --> pthread_mutex_lock " << aMutexWait << endl ;
if ( pthread_mutex_lock( aMutexWait ) ) {
// cdebug << pthread_self() << " BoolValue() --> pthread_mutex_locked " << aMutexWait
// << endl ;
if ( (*_Value)->type()->kind() == CORBA::tk_long ) {
+ long val ;
+ **_Value >>= val ;
+ if ( val ) {
+ RetVal = true ;
+ }
+ }
+ else if ( (*_Value)->type()->kind() == CORBA::tk_boolean ) {
+ bool val ;
**_Value >>= val ;
if ( val ) {
RetVal = true ;
perror( "unlock DataValue" ) ;
exit( 0 ) ;
}
-// cdebug << pthread_self() << " BoolValue() --> pthread_mutex_unlocked " << aMutexWait
-// << endl ;
+// cdebug << pthread_self() << " " << NodeName() << "( " << PortName() << " ) BoolValue " << RetVal << endl ;
return RetVal ;
}
-const CORBA::Any ** GraphBase::DataPort::ValuePtr() const {
- return _Value ;
-}
-
void GraphBase::DataPort::StringValue(ostream & f ) const {
pthread_mutex_t * aMutexWait = (pthread_mutex_t *) &_MutexWait ;
-// cdebug << pthread_self() << " StringValue() --> pthread_mutex_lock " << aMutexWait
-// << endl ;
+// cdebug_in << pthread_self() << " StringValue() --> pthread_mutex_lock " << aMutexWait
+// << endl ;
if ( pthread_mutex_lock( aMutexWait ) ) {
perror( "lock DataValue" ) ;
exit( 0 ) ;
}
// cdebug << pthread_self() << " StringValue() --> pthread_mutex_locked " << aMutexWait
// << endl ;
- if ( Done() ) {
+ if ( PortDone() ) {
// cdebug << "StringValue " << NodeName() << " " << PortName() << " " << PortType()
// << " _Value " << _Value << " *_Value "
// << *_Value << " " << endl ;
}
}
else {
- f << " Default (undefined) NOT DONE" ;
+ f << " Default (undefined) DATAPORT NOT DONE" ;
}
if ( pthread_mutex_unlock( aMutexWait ) ) {
perror( "unlock DataValue" ) ;
exit( 0 ) ;
}
-// cdebug << pthread_self() << " StringValue() --> pthread_mutex_unlocked " << aMutexWait
-// << endl ;
+// cdebug_out << pthread_self() << " StringValue() --> pthread_mutex_unlocked " << aMutexWait
+// << endl ;
}