2 #include "CORBAPorts.hxx"
3 #include "RuntimeSALOME.hxx"
4 #include "TypeConversions.hxx"
10 using namespace YACS::ENGINE;
14 InputCorbaPort::InputCorbaPort(const string& name,
17 : InputPort(name, node, type), Port(node)
20 _orb = getSALOMERuntime()->getOrb();
23 void InputCorbaPort::put(const void *data) throw (ConversionException)
25 put((CORBA::Any *)data);
29 void InputCorbaPort::put(CORBA::Any *data) throw (ConversionException)
31 cerr << "InputCorbaPort::put" << endl;
32 // cerr << "addr data: " << data << endl;
33 // cerr << "addr data.value(): " << data->value() << endl;
34 switch(type()->kind())
39 cerr << "Double: " << d << endl;
44 cerr << "Int: " << l << endl;
51 // on fait une copie du any (protection contre la destruction du any source)
52 // la gestion des destructions est correctement faite par omniorb
54 // cerr << "addr _data: " << &_data << endl;
55 // cerr << "addr _data.value(): " << _data.value() << endl;
58 CORBA::Any * InputCorbaPort::getAny()
60 // cerr << "_data: " << &_data << endl;
61 // cerr << "_data.value(): " << _data.value() << endl;
62 // cerr << "_data.NP_pd(): " << _data.NP_pd() << endl;
63 // --- on retourne un pointeur sur le any interne
68 OutputCorbaPort::OutputCorbaPort(const string& name,
71 : OutputPort(name, node, type), Port(node)
74 _orb = getSALOMERuntime()->getOrb();
77 void OutputCorbaPort::put(const void *data) throw (ConversionException)
79 put((CORBA::Any *)data);
82 void OutputCorbaPort::put(CORBA::Any *data) throw (ConversionException)
84 cerr << "OutputCorbaPort::put" << endl;
85 // cerr << "addr data: " << data << endl;
87 // on fait une copie du any source
88 // (protection contre la destruction de la source)
90 set<InputPort *>::iterator iter;
91 for(iter=_setOfInputPort.begin(); iter!=_setOfInputPort.end(); iter++)
94 // on pousse le pointeur mais put fait normalement une copie
99 CORBA::Any * OutputCorbaPort::getAny()
101 // cerr << "_data: " << &_data << endl;
102 // cerr << "_data.value(): " << _data.value() << endl;
103 // cerr << "_data.NP_pd(): " << _data.NP_pd() << endl;
104 // on retourne un pointeur sur le any interne
108 CORBA::Any * OutputCorbaPort::getAnyOut()
110 CORBA::Any* a=&_data;
111 DynType kind=type()->kind();
115 a->replace(CORBA::_tc_long, (void*) 0);
117 else if(kind == String)
119 a->replace(CORBA::_tc_string, (void*) 0);
121 else if(kind == Double)
123 a->replace(CORBA::_tc_double, (void*) 0);
125 else if(kind == Objref)
127 a->replace(CORBA::_tc_Object, (void*) 0);
129 else if(kind == Sequence)
131 CORBA::TypeCode_var t;
132 t = getCorbaTC(type());
133 a->replace(t, (void*) 0);
135 else if(kind == Bool)
138 msg << "Cannot set Any Out for Bool" << __FILE__ << ":" << __LINE__;
139 throw Exception(msg.str());
141 else if(kind == None)
144 msg << "Cannot set Any Out for None" << __FILE__ << ":" << __LINE__;
145 throw Exception(msg.str());
150 msg << "Cannot set Any Out for unknown type" << __FILE__
152 throw Exception(msg.str());
155 // on retourne un pointeur sur le any interne reinitialisé
156 // cerr << "getAnyOut::_data: " << a << endl;
160 ostream& YACS::ENGINE::operator<<(ostream& os, const OutputCorbaPort& p)
164 os << p._name << " : " << l ;