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);
78 void InputPort::edInit(const std::string& impl,const void* value)
80 InputPort *manuallySet=getRuntime()->adapt(this,impl,_type);
81 manuallySet->put(value);
88 //! Removes eventually previous manual initialisation.
89 void InputPort::edRemoveManInit()
92 _initValue->decrRef();
96 //! Check basically that this port has one chance to be specified on time. It's a necessary condition \b not \b sufficient at all.
97 void InputPort::checkBasicConsistency() const throw(Exception)
99 if(!edIsManuallyInitialized() and _backLinks.size()==0 )
101 ostringstream stream;
102 stream << "InputPort::checkBasicConsistency : Port " << _name << " of node with name " << _node->getName() << " neither initialized nor linked back";
103 throw Exception(stream.str());
107 std::string InputPort::dump()
109 string xmldump = "<value><error> NO_SERIALISATION_AVAILABLE </error></value>";
113 void InputPort::setStringRef(std::string strRef)
118 ProxyPort::ProxyPort(InputPort* p):InputPort("Convertor", p->getNode(), p->edGetType()),DataPort("Convertor", p->getNode(), p->edGetType()),
124 ProxyPort::~ProxyPort()
126 //For the moment, there is no case in YACS we have a proxy port in a proxy port
127 //So don't test that. _port may be already deleted. The test is not sure.
129 if(_port->isIntermediate())
134 void ProxyPort::edRemoveAllLinksLinkedWithMe() throw(Exception)
136 _port->edRemoveAllLinksLinkedWithMe();
140 * \note : Should never been called because Node clone process does not duplicate data attributes relative to links.
141 * This part is done afterwards on relink process.
143 InputPort *ProxyPort::clone(Node *newHelder) const
145 throw Exception("ProxyPort::clone : internal error - should never happened");
148 void ProxyPort::edNotifyReferencedBy(OutPort *fromPort)
150 _port->edNotifyReferencedBy(fromPort);
153 void ProxyPort::edNotifyDereferencedBy(OutPort *fromPort)
155 _port->edNotifyDereferencedBy(fromPort);
158 std::set<OutPort *> ProxyPort::edSetOutPort() const
160 return _port->edSetOutPort();
163 int ProxyPort::edGetNumberOfLinks() const
165 return _port->edGetNumberOfLinks();
168 void ProxyPort::exRestoreInit()
170 _port->exRestoreInit();
173 void ProxyPort::exSaveInit()
179 InPort *ProxyPort::getPublicRepresentant()
181 InputPort *ProxyPort::getPublicRepresentant()
184 return _port->getPublicRepresentant();
187 void *ProxyPort::get() const
192 void ProxyPort::put(const void *data) throw(ConversionException)
197 void ProxyPort::getAllRepresentants(std::set<InPort *>& repr) const
199 DEBTRACE("ProxyPort::getAllRepresentants");
200 _port->getAllRepresentants(repr);