1 #include "OutputPort.hxx"
2 #include "InputPort.hxx"
4 using namespace YACS::ENGINE;
7 const char OutputPort::NAME[]="OutputPort";
9 OutputPort::OutputPort(const std::string& name, Node *node, DynType type):DataFlowPort(name,node,type),OutPort(node),Port(node)
13 std::string OutputPort::getNameOfTypeOfCurrentInstance() const
18 Data OutputPort::foGet() const
23 void OutputPort::exInit()
28 void OutputPort::exPut(Data data) throw(ConversionException)
31 for(list<InputPort *>::iterator iter=_listOfInputPort.begin();iter!=_listOfInputPort.end();iter++)
32 (*iter)->exAccept(data);
35 bool OutputPort::edAddInputPort(InputPort *inputPort) throw(ConversionException)
37 if(!Data::areStaticallyCompatible(edGetType(),inputPort->edGetType()))
38 throw ConversionException(Data::edGetTypeInPrintableForm(edGetType()),Data::edGetTypeInPrintableForm(inputPort->edGetType()));
39 if(!isAlreadyInList(inputPort))
41 _listOfInputPort.push_back(inputPort);
42 inputPort->edNotifyReferenced();
49 list<InputPort *> OutputPort::edListInputPort()
51 return _listOfInputPort;
54 void OutputPort::edRemoveInputPort(InputPort *inputPort) throw(Exception)
56 if(isAlreadyInList(inputPort))
57 _listOfInputPort.remove(inputPort);
59 throw Exception("OutputPort::edRemoveInputPort : link does not exist, unable to remove it");
62 OutputPort::~OutputPort()
66 bool OutputPort::isAlreadyInList(InputPort *inputPort) const
69 for(list<InputPort *>::const_iterator iter=_listOfInputPort.begin();iter!=_listOfInputPort.end() && !ret;iter++)
70 if((*iter)==inputPort)
75 bool OutputPort::addInPort(InPort *inPort) throw(Exception)
77 if(inPort->getNameOfTypeOfCurrentInstance()!=InputPort::NAME)
79 std::string what="not compatible type of port requested during building of link FROM ";
80 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
81 throw Exception(what);
83 return edAddInputPort(static_cast<InputPort*>(inPort));
86 void OutputPort::removeInPort(InPort *inPort) throw(Exception)
88 if(inPort->getNameOfTypeOfCurrentInstance()!=InputPort::NAME)
90 std::string what="not compatible type of port requested during destruction of for link FROM ";
91 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
92 throw Exception(what);
94 edRemoveInputPort(static_cast<InputPort*>(inPort));
97 bool OutputPort::isLinked()
99 return _listOfInputPort.empty();