]> SALOME platform Git repositories - modules/yacs.git/blobdiff - src/engine/DataPort.cxx
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / DataPort.cxx
diff --git a/src/engine/DataPort.cxx b/src/engine/DataPort.cxx
new file mode 100644 (file)
index 0000000..ef679fe
--- /dev/null
@@ -0,0 +1,51 @@
+#include "DataPort.hxx"
+#include <iostream>
+
+using namespace YACS::ENGINE;
+using namespace std;
+
+const char DataPort::NAME[]="DataPort";
+
+DataPort::~DataPort()
+{
+  _type->decrRef();
+}
+
+DataPort::DataPort(const std::string& name, Node *node, TypeCode* type):Port(node),_name(name),_type(type)
+{
+  _type->incrRef();
+}
+
+DataPort::DataPort(const DataPort& other, Node *newHelder):Port(other,newHelder),_name(other._name),_type(other._type)
+{
+  _type->incrRef();
+}
+
+void DataPort::edSetType(TypeCode* type)
+{
+  if(_type)
+    _type->decrRef();
+  _type=type;
+  if(_type)
+    _type->incrRef();
+}
+
+string DataPort::getNameOfTypeOfCurrentInstance() const
+{
+  return NAME;
+}
+
+
+/*!
+ * If in historyOfLink different type of Port are detected : The first one (by starting from the end of 'historyOfLink')
+ * is returned. Else 0 is returned if they are all of the same type.
+ */
+DataPort *DataPort::isCrossingType(const std::vector<DataPort *>& historyOfLink)
+{
+  vector<DataPort *>::const_reverse_iterator iter=historyOfLink.rbegin()+1;
+  const DataPort *base=historyOfLink.back();
+  for(;iter!=historyOfLink.rend();iter++)
+    if(base->isDifferentTypeOf(*iter))
+      return *iter;
+  return 0;
+}