1 #include "AnyInputPort.hxx"
6 #include "YacsTrace.hxx"
8 using namespace YACS::ENGINE;
11 AnyInputPort::AnyInputPort(const std::string& name, Node *node, TypeCode* type):InputPort(name,node,type),DataPort(name,node,type),Port(node),_value(0)
15 AnyInputPort::AnyInputPort(const AnyInputPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),_value(0)
18 _value=other._value->clone();
21 AnyInputPort::~AnyInputPort()
25 DEBTRACE("_value ref count: " << _value->getRefCnt());
30 //! Save the current data value for further reinitialization of the port
34 void AnyInputPort::exSaveInit()
36 if(_initValue) _initValue->decrRef();
38 _initValue->incrRef();
41 //! Restore the saved data value to current data value
43 * If no data has been saved (_initValue == 0) don't restore
45 void AnyInputPort::exRestoreInit()
55 void AnyInputPort::put(Any *data)
61 DEBTRACE("value ref count: " << _value->getRefCnt());
64 bool AnyInputPort::isEmpty()
69 void *AnyInputPort::get() const throw(Exception)
73 std::string what="AnyInputPort::get : no value currently in input whith name \""; what+=_name; what+="\"";
74 throw Exception(what);
76 return (void *)_value;
79 void AnyInputPort::put(const void *data) throw(ConversionException)
84 InputPort *AnyInputPort::clone(Node *newHelder) const
86 return new AnyInputPort(*this,newHelder);
89 std::string AnyInputPort::dump()
93 std::string what="AnyInputPort::get : no value currently in input whith name \""; what+=_name; what+="\"";
94 throw Exception(what);
97 switch (_value->getType()->kind())
100 xmldump << "<value><double>" << _value->getDoubleValue() << "</double></value>" << endl;
103 xmldump << "<value><int>" << _value->getIntValue() << "</int></value>" << endl;
106 xmldump << "<value><boolean>" << _value->getBoolValue() << "</boolean></value>" << endl;
109 xmldump << "<value><string>" << _value->getStringValue() << "</string></value>" << endl;
112 xmldump << "<value><error> NO_SERIALISATION_AVAILABLE </error></value>" << endl;
115 return xmldump.str();