1 #include "OutputDataStreamPort.hxx"
2 #include "InputDataStreamPort.hxx"
3 #include "ComposedNode.hxx"
7 using namespace YACS::ENGINE;
10 const char OutputDataStreamPort::NAME[]="OutputDataStreamPort";
12 OutputDataStreamPort::OutputDataStreamPort(const OutputDataStreamPort& other, Node *newHelder):DataStreamPort(other,newHelder),
13 OutPort(other,newHelder),
14 DataPort(other,newHelder),
19 OutputDataStreamPort::OutputDataStreamPort(const std::string& name, Node *node, TypeCode* type):DataStreamPort(name,node,type),
20 OutPort(name,node,type),
21 DataPort(name,node,type),
26 OutputDataStreamPort::~OutputDataStreamPort()
30 OutputDataStreamPort *OutputDataStreamPort::clone(Node *newHelder) const
32 return new OutputDataStreamPort(*this,newHelder);
35 std::set<InPort *> OutputDataStreamPort::edSetInPort() const
38 for(set<InputDataStreamPort *>::iterator iter=_setOfInputDataStreamPort.begin();iter!=_setOfInputDataStreamPort.end();iter++)
39 (*iter)->getAllRepresentants(s);
43 bool OutputDataStreamPort::isAlreadyLinkedWith(InPort *with) const
46 set<InputDataStreamPort *>::iterator iter;
47 for(iter=_setOfInputDataStreamPort.begin();iter!=_setOfInputDataStreamPort.end();iter++)
50 for(iter=_setOfInputDataStreamPort.begin();iter!=_setOfInputDataStreamPort.end();iter++)
51 (*iter)->getAllRepresentants(s);
52 for(set<InPort *>::iterator iter2=s.begin();iter2!=s.end();iter2++)
58 string OutputDataStreamPort::getNameOfTypeOfCurrentInstance() const
63 bool OutputDataStreamPort::edAddInputDataStreamPort(InputDataStreamPort *port)
64 throw(ConversionException)
66 if(!isAlreadyInSet(port))
68 _setOfInputDataStreamPort.insert(port);
75 int OutputDataStreamPort::edRemoveInputDataStreamPort(InputDataStreamPort *inPort, bool forward) throw(Exception)
80 inPort->getAllRepresentants(s);
81 for(set<InPort *>::iterator iter=s.begin();iter!=s.end();iter++)
82 _node->getRootNode()->edRemoveLink(this,*iter);
87 set<InputDataStreamPort *>::iterator iter=_setOfInputDataStreamPort.find(inPort);
88 if(iter!=_setOfInputDataStreamPort.end())
90 _setOfInputDataStreamPort.erase(iter);
91 return edGetNumberOfOutLinks();
94 throw Exception("OutputDataStreamPort::edRemoveInputPort : link does not exist, unable to remove it");
98 bool OutputDataStreamPort::addInPort(InPort *inPort) throw(Exception)
100 if(inPort->getNameOfTypeOfCurrentInstance()!=InputDataStreamPort::NAME)
102 string what="not compatible type of port requested during building of link FROM ";
103 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
104 throw Exception(what);
106 return edAddInputDataStreamPort(static_cast<InputDataStreamPort*>(inPort));
109 void OutputDataStreamPort::edRemoveAllLinksLinkedWithMe() throw(Exception)
111 set<InputDataStreamPort *>::iterator iter;
112 set<InputDataStreamPort *> vec(_setOfInputDataStreamPort);
113 for( set<InputDataStreamPort *>::iterator iter2=vec.begin();iter2!=vec.end();iter2++)
114 edRemoveInputDataStreamPort(*iter2,true);
115 _setOfInputDataStreamPort.clear();
118 int OutputDataStreamPort::removeInPort(InPort *inPort, bool forward) throw(Exception)
120 if(inPort->getNameOfTypeOfCurrentInstance()!=InputDataStreamPort::NAME && !forward)
122 string what="not compatible type of port requested during destruction of for link FROM ";
123 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
124 throw Exception(what);
126 return edRemoveInputDataStreamPort(static_cast<InputDataStreamPort *>(inPort),forward);
129 bool OutputDataStreamPort::isAlreadyInSet(InputDataStreamPort *inPort) const
131 return _setOfInputDataStreamPort.find(inPort)!=_setOfInputDataStreamPort.end();