2 //=============================================================================
3 // File : DataFlowBase_DataPort.cxx
5 // Author : Jean Rahuel, CEA
8 //=============================================================================
10 #include "DataFlowBase_DataPort.hxx"
12 GraphBase::DataPort::DataPort(
13 const char *const * NodeName ,
14 const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) :
15 Port( NodeName , aserviceParameter ) {
16 InitialValues( CORBA::Any() ) ;
19 GraphBase::DataPort::~DataPort() {
22 void GraphBase::DataPort::InitialValues(CORBA::Any aValue ) {
23 _theValue = new CORBA::Any( aValue ) ;
24 string _Type = CORBA::string_dup(GetServicesParameter().Parametertype) ;
25 const char * Type = _Type.c_str();
26 CORBA::Any InitialValue ;
27 cdebug << "InitialValues " << NodeName() << " " << PortName() << " " << PortType()
29 if ( !strcmp( Type , "string" ) ) {
30 cdebug << "string" << endl ;
31 InitialValue <<= (char *) NULL ;
33 else if ( !strcmp( Type , "double" ) ) {
34 cdebug << "double" << endl ;
37 else if ( !strcmp( Type , "long" ) ) {
38 cdebug << "long" << endl ;
39 InitialValue <<= (long ) 0 ;
41 else if ( !strcmp( Type , "objref" ) ) {
42 cdebug << "objref" << endl ;
43 InitialValue.replace(CORBA::_tc_Object, NULL);
46 cdebug << "InitialValues ERROR (other) " << Type << endl ;
47 InitialValue <<= (long ) 0 ;
49 _InitialValue = new CORBA::Any( InitialValue ) ;
50 _Value = &_InitialValue ;
53 void GraphBase::DataPort::Value( const CORBA::Any & aDataValue ) {
54 Value( new CORBA::Any( aDataValue ) ) ;
57 void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) {
59 _theValue = aDataValue ;
60 *_Value = aDataValue ;
64 cdebug << "NewValue " << NodeName() << " " << PortName() << " " << PortType()
65 << " : " << _Value << " *_Value " << *_Value << " " ;
66 switch (_theValue->type()->kind()) {
67 case CORBA::tk_string: {
70 cdebug << "Value( " << t << ") (string)";
73 case CORBA::tk_double: {
76 cdebug << "Value( " << d << ") (double)";
79 case CORBA::tk_long: {
82 cdebug << "Value( " << l << ") (long)";
85 case CORBA::tk_objref: {
86 cdebug << "Value( " << ") (object reference)";
90 cdebug << "Value" << " (other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
99 void GraphBase::DataPort::Value( const CORBA::Any ** aDataSharedValue ) {
101 _theValue = *aDataSharedValue ;
102 _Value = aDataSharedValue ;
106 MESSAGE( NodePortName() << " : " << hex << _Value << " " );
107 switch (_theValue->type()->kind()) {
108 case CORBA::tk_string:
111 MESSAGE( "Value( " << t << ") (string)");
113 case CORBA::tk_double:
116 MESSAGE( "Value( " << d << ") (double)");
121 MESSAGE( "Value( " << l << ") (long)");
123 case CORBA::tk_objref:
124 MESSAGE( "Value( " << ") (object reference)");
127 MESSAGE( "Value" << " (other(tk_string,tk_double,tk_long,tk_objref)) ERROR");
134 CORBA::Any const * GraphBase::DataPort::Value() const {
135 const CORBA::Any *const Value = *_Value ;
136 CORBA::Any * theValue ;
137 cdebug << "Value " << NodeName() << " " << PortName() << " " << PortType()
138 << " _Value " << _Value << " *_Value " << *_Value << " " ;
140 theValue = new CORBA::Any( *Value ) ;
141 switch (theValue->type()->kind()) {
142 case CORBA::tk_string: {
145 cdebug << "GraphBase::DataPort::Value() : " << t << " (string) " << endl;
148 case CORBA::tk_double: {
151 cdebug << "GraphBase::DataPort::Value() : " << d << " (double) " << endl;
154 case CORBA::tk_long: {
157 cdebug << "GraphBase::DataPort::Value() : " << l << " (long) " << endl;
160 case CORBA::tk_objref: {
161 CORBA::Object_ptr obj ;
165 retstr = ObjectToString( obj );
166 cdebug << "GraphBase::DataPort::Value() : " << retstr
167 << "(object reference) " << endl;
170 cdebug << "ToString( object ) Catched ERROR" << endl ;
175 cdebug << "GraphBase::DataPort::Value() : "
176 << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR" << endl;
182 cdebug << "GraphBase::DataPort::InitialValue() " << endl;
183 theValue = new CORBA::Any( *Value ) ;
189 bool GraphBase::DataPort::BoolValue() const {
190 bool RetVal = false ;
192 if ( (*_Value)->type()->kind() == CORBA::tk_long ) {
201 const CORBA::Any ** GraphBase::DataPort::ValuePtr() const {
205 void GraphBase::DataPort::StringValue(ostream & f ) const {
207 cdebug << "StringValue " << NodeName() << " " << PortName() << " " << PortType()
208 << " _Value " << _Value << " *_Value "
209 << *_Value << " " << endl ;
210 const CORBA::Any * theValue = *_Value ;
211 switch (theValue->type()->kind()) {
212 case CORBA::tk_string:
215 f << t << " (string)" ;
217 case CORBA::tk_double:
220 f << d << " (double)" ;
225 f << l << " (long)" ;
227 case CORBA::tk_objref:
228 f << "(object reference)" ;
231 f << "(other ERROR)" ;
236 f << "Default(undefined)" ;