1 #include "OutputPort.hxx"
2 #include "InputPort.hxx"
8 using namespace YACS::ENGINE;
11 const char OutputPort::NAME[]="OutputPort";
13 OutputPort::OutputPort(const string& name, Node *node, TypeCode* type):DataFlowPort(name,node,type),OutPort(node),Port(node)
17 string OutputPort::getNameOfTypeOfCurrentInstance() const
22 void OutputPort::exInit()
28 void OutputPort::put(const void *data) throw(ConversionException)
30 // _data = (void *)data;
31 cerr << _name << endl;
32 cerr << _impl << endl;
34 msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
35 throw Exception(msg.str());
40 * check if output type is an input type and if a data converter exists before link
43 bool OutputPort::edAddInputPort(InputPort *inputPort) throw(ConversionException)
45 InputPort *pwrap = getRuntime()->adapt(inputPort->getImpl(),
50 if(!isAlreadyInSet(pwrap))
52 _setOfInputPort.insert(pwrap);
53 inputPort->edNotifyReferenced();
58 if ( dynamic_cast<ProxyPort*> (pwrap) )
60 cerr << "ProxyPort destruction, while creating the same link twice..." << endl;
67 set<InputPort *> OutputPort::edSetInputPort()
69 return _setOfInputPort;
72 void OutputPort::edRemoveInputPort(InputPort *inputPort) throw(Exception)
74 if(isAlreadyInSet(inputPort))
75 _setOfInputPort.erase(inputPort);
77 throw Exception("OutputPort::edRemoveInputPort : link does not exist, unable to remove it");
80 //Idem OutputPort::edRemoveInputPort but without any check.
81 void OutputPort::edRemoveInputPortOneWay(InputPort *inputPort)
83 _setOfInputPort.erase(inputPort);
86 OutputPort::~OutputPort()
90 bool OutputPort::isAlreadyInSet(InputPort *inputPort) const
93 for(set<InputPort *>::const_iterator iter=_setOfInputPort.begin();iter!=_setOfInputPort.end() && !ret;iter++)
94 if((*iter)==inputPort)
100 * check compatibility of port class ( an inputPort) before trying to create the link
103 bool OutputPort::addInPort(InPort *inPort) throw(Exception)
105 if(inPort->getNameOfTypeOfCurrentInstance()!=InputPort::NAME)
107 string what="not compatible type of port requested during building of link FROM ";
108 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
109 throw Exception(what);
111 return edAddInputPort(static_cast<InputPort*>(inPort));
114 void OutputPort::removeInPort(InPort *inPort) throw(Exception)
116 if(inPort->getNameOfTypeOfCurrentInstance()!=InputPort::NAME)
118 string what="not compatible type of port requested during destruction of for link FROM ";
119 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
120 throw Exception(what);
122 edRemoveInputPort(static_cast<InputPort*>(inPort));
125 bool OutputPort::isLinked()
127 return _setOfInputPort.empty();