1 #include "InputPort.hxx"
3 #include "ComposedNode.hxx"
10 #include "YacsTrace.hxx"
12 using namespace YACS::ENGINE;
15 const char InputPort::NAME[]="InputPort";
17 InputPort::InputPort(const InputPort& other, Node *newHelder):DataFlowPort(other,newHelder),InPort(other,newHelder),
18 DataPort(other,newHelder),Port(other,newHelder),
22 _initValue=other._initValue->clone();
25 InputPort::InputPort(const std::string& name, Node *node, TypeCode* type)
26 : DataFlowPort(name,node,type), InPort(name,node,type),DataPort(name,node,type),Port(node), _initValue(0)
30 string InputPort::getNameOfTypeOfCurrentInstance() const
35 void InputPort::exInit(bool start)
37 checkBasicConsistency();
42 bool InputPort::isEmpty()
47 //! Specifies if this port has been \b manually set by the call of InputPort::edInit
48 bool InputPort::edIsManuallyInitialized() const
54 * Perform a quick and not complete check. Use ComposedNode::CheckConsistency instead.
56 bool InputPort::edIsInitialized() const
58 return (edIsManuallyInitialized() or _backLinks.size()!=0 );
61 InputPort::~InputPort()
64 _initValue->decrRef();
67 void InputPort::edInit(Any *value)
69 InputPort *manuallySet=getRuntime()->adapt(this,
70 Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME,_type);
71 manuallySet->put((const void *) value);
77 void InputPort::edInit(const std::string& impl,const void* value)
79 InputPort *manuallySet=getRuntime()->adapt(this,impl,_type);
80 manuallySet->put(value);
86 //! Removes eventually previous manual initialisation.
87 void InputPort::edRemoveManInit()
90 _initValue->decrRef();
94 //! Check basisically that this port has one chance to be specified on time. It's a necessary condition \b not \b sufficient at all.
95 void InputPort::checkBasicConsistency() const throw(Exception)
97 if(!edIsManuallyInitialized() and _backLinks.size()==0 )
100 stream << "InputPort::checkBasicConsistency : Port " << _name << " of node with name " << _node->getName() << " neither initialized nor linked back";
101 throw Exception(stream.str());
105 std::string InputPort::dump()
107 string xmldump = "<value><error> NO_SERIALISATION_AVAILABLE </error></value>";
111 void InputPort::setStringRef(std::string strRef)
116 ProxyPort::ProxyPort(InputPort* p):InputPort("Convertor", p->getNode(), p->edGetType()),DataPort("Convertor", p->getNode(), p->edGetType()),
122 ProxyPort::~ProxyPort()
124 //For the moment, there is no case in YACS we have a proxy port in a proxy port
125 //So don't test that. _port may be already deleted. The test is not sure.
127 if(_port->isIntermediate())
132 void ProxyPort::edRemoveAllLinksLinkedWithMe() throw(Exception)
134 _port->edRemoveAllLinksLinkedWithMe();
138 * \note : Should never been called because Node clone process does not duplicate data attributes relative to links.
139 * This part is done afterwards on relink process.
141 InputPort *ProxyPort::clone(Node *newHelder) const
143 throw Exception("ProxyPort::clone : internal error - should never happened");
146 void ProxyPort::edNotifyReferencedBy(OutPort *fromPort)
148 _port->edNotifyReferencedBy(fromPort);
151 void ProxyPort::edNotifyDereferencedBy(OutPort *fromPort)
153 _port->edNotifyDereferencedBy(fromPort);
156 std::set<OutPort *> ProxyPort::edSetOutPort() const
158 return _port->edSetOutPort();
161 int ProxyPort::edGetNumberOfLinks() const
163 return _port->edGetNumberOfLinks();
166 void ProxyPort::exRestoreInit()
168 _port->exRestoreInit();
171 void ProxyPort::exSaveInit()
176 InputPort *ProxyPort::getPublicRepresentant()
178 return _port->getPublicRepresentant();
181 void *ProxyPort::get() const throw(Exception)
186 void ProxyPort::put(const void *data) throw(ConversionException)
191 void ProxyPort::getAllRepresentants(std::set<InPort *>& repr) const
193 _port->getAllRepresentants(repr);