2 #include "TypeConversions.hxx"
3 #include "CppPorts.hxx"
10 #include "YacsTrace.hxx"
12 using namespace YACS::ENGINE;
15 InputCppPort::InputCppPort(const std::string& name, Node *node, TypeCode * type)
16 : InputPort(name, node, type), DataPort(name, node, type), Port(node), _data(NULL),_initData(NULL)
20 InputCppPort::~InputCppPort()
24 DEBTRACE("_data ref count: " << _data->getRefCnt());
29 InputCppPort::InputCppPort(const InputCppPort& other, Node *newHelder):InputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder)
31 _initData=other._initData;
35 bool InputCppPort::edIsManuallyInitialized() const
37 return _initData!= NULL;
40 void InputCppPort::edRemoveManInit()
43 InputPort::edRemoveManInit();
46 void InputCppPort::put(const void *data) throw(ConversionException)
48 put((YACS::ENGINE::Any *)data);
51 void InputCppPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
57 DEBTRACE("value ref count: " << _data->getRefCnt());
60 InputPort *InputCppPort::clone(Node *newHelder) const
62 return new InputCppPort(*this,newHelder);
65 YACS::ENGINE::Any * InputCppPort::getCppObj() const
70 void *InputCppPort::get() const throw(Exception)
75 bool InputCppPort::isEmpty()
80 //! Save the current data value for further reinitialization of the port
84 void InputCppPort::exSaveInit()
87 //DEBTRACE("_initData.ob refcnt: " << _initData->ob_refcnt);
88 //DEBTRACE("_data.ob refcnt: " << _data->ob_refcnt);
91 //! Restore the saved data value to current data value
93 * If no data has been saved (_initData == 0) don't restore
95 void InputCppPort::exRestoreInit()
99 //DEBTRACE("_initData.ob refcnt: " << _initData->ob_refcnt);
100 //DEBTRACE("_data.ob refcnt: " << _data->ob_refcnt);
103 std::string InputCppPort::dump()
106 return "<value>None</value>";
108 if (edGetType()->kind() != YACS::ENGINE::Objref)
109 return convertNeutralXml(edGetType(), _data);
110 //return convertCppXml(edGetType(), _data);
111 if (! _stringRef.empty())
114 return convertNeutralXml(edGetType(), _data);
117 // msg << "Cannot retreive init reference string for port " << _name
118 // << " on node " << _node->getName();
119 // throw Exception(msg.str());
124 OutputCppPort::OutputCppPort(const std::string& name, Node *node, TypeCode * type)
125 : OutputPort(name, node, type), DataPort(name, node, type), Port(node)
130 OutputCppPort::~OutputCppPort()
134 DEBTRACE("_data ref count: " << _data->getRefCnt());
139 OutputCppPort::OutputCppPort(const OutputCppPort& other, Node *newHelder):OutputPort(other,newHelder),DataPort(other,newHelder),Port(other,newHelder),
144 void OutputCppPort::put(const void *data) throw(ConversionException)
146 put((YACS::ENGINE::Any *)data);
149 void OutputCppPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
157 OutputPort::put(data);
160 OutputPort *OutputCppPort::clone(Node *newHelder) const
162 return new OutputCppPort(*this,newHelder);
165 YACS::ENGINE::Any * OutputCppPort::get() const
170 std::string OutputCppPort::dump()
173 return "<value>None</value>";
174 string xmldump = convertNeutralXml(edGetType(), _data);