Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / DataPort.cxx
1 #include "DataPort.hxx"
2 #include <iostream>
3
4 using namespace YACS::ENGINE;
5 using namespace std;
6
7 const char DataPort::NAME[]="DataPort";
8
9 DataPort::~DataPort()
10 {
11   _type->decrRef();
12 }
13
14 DataPort::DataPort(const std::string& name, Node *node, TypeCode* type):Port(node),_name(name),_type(type)
15 {
16   _type->incrRef();
17 }
18
19 DataPort::DataPort(const DataPort& other, Node *newHelder):Port(other,newHelder),_name(other._name),_type(other._type)
20 {
21   _type->incrRef();
22 }
23
24 void DataPort::edSetType(TypeCode* type)
25 {
26   if(_type)
27     _type->decrRef();
28   _type=type;
29   if(_type)
30     _type->incrRef();
31 }
32
33 string DataPort::getNameOfTypeOfCurrentInstance() const
34 {
35   return NAME;
36 }
37
38
39 /*!
40  * If in historyOfLink different type of Port are detected : The first one (by starting from the end of 'historyOfLink')
41  * is returned. Else 0 is returned if they are all of the same type.
42  */
43 DataPort *DataPort::isCrossingType(const std::vector<DataPort *>& historyOfLink)
44 {
45   vector<DataPort *>::const_reverse_iterator iter=historyOfLink.rbegin()+1;
46   const DataPort *base=historyOfLink.back();
47   for(;iter!=historyOfLink.rend();iter++)
48     if(base->isDifferentTypeOf(*iter))
49       return *iter;
50   return 0;
51 }