1 #include "AnyInputPort.hxx"
2 #include "TypeCode.hxx"
7 #include "YacsTrace.hxx"
9 using namespace YACS::ENGINE;
12 AnyInputPort::AnyInputPort(const std::string& name, Node *node, TypeCode* type):InputPort(name,node,type),DataPort(name,node,type),Port(node),_value(0)
16 AnyInputPort::AnyInputPort(const AnyInputPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),_value(0)
19 _value=other._value->clone();
22 AnyInputPort::~AnyInputPort()
26 DEBTRACE("_value ref count: " << _value->getRefCnt());
31 //! Save the current data value for further reinitialization of the port
35 void AnyInputPort::exSaveInit()
37 if(_initValue) _initValue->decrRef();
39 _initValue->incrRef();
42 //! Restore the saved data value to current data value
44 * If no data has been saved (_initValue == 0) don't restore
46 void AnyInputPort::exRestoreInit()
56 void AnyInputPort::put(Any *data)
62 DEBTRACE("value ref count: " << _value->getRefCnt());
65 bool AnyInputPort::isEmpty()
70 void *AnyInputPort::get() const
72 return (void *)_value;
75 void AnyInputPort::put(const void *data) throw(ConversionException)
80 InputPort *AnyInputPort::clone(Node *newHelder) const
82 return new AnyInputPort(*this,newHelder);
85 std::string AnyInputPort::dump()
89 std::string what="AnyInputPort::get : no value currently in input whith name \""; what+=_name; what+="\"";
90 throw Exception(what);
93 switch (_value->getType()->kind())
96 xmldump << "<value><double>" << _value->getDoubleValue() << "</double></value>" << endl;
99 xmldump << "<value><int>" << _value->getIntValue() << "</int></value>" << endl;
102 xmldump << "<value><boolean>" << _value->getBoolValue() << "</boolean></value>" << endl;
105 xmldump << "<value><string>" << _value->getStringValue() << "</string></value>" << endl;
108 xmldump << "<value><error> NO_SERIALISATION_AVAILABLE </error></value>" << endl;
111 return xmldump.str();