]> SALOME platform Git repositories - modules/superv.git/blob - src/Supervision/Link_Impl.cxx
Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/superv.git] / src / Supervision / Link_Impl.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : Link_Impl.cxx
4 // Created   : Nov 2001
5 // Author    : Jean Rahuel
6 // Project   : SALOME
7 // $Header: 
8 //=============================================================================
9
10 #include <stdio.h>
11 #include <fstream>
12 #include <strstream>
13 #include <string>
14
15 #include "utilities.h"
16
17 #include "Link_Impl.hxx"
18
19 Link_Impl::Link_Impl( CORBA::ORB_ptr orb ,
20                       PortableServer::POA_ptr poa ,
21                       PortableServer::ObjectId * contId , 
22                       const char *instanceName ,
23                       const char *interfaceName ,
24                       GraphEditor::DataFlow * DataFlowEditor ,
25                       GraphEditor::InNode * DataFlowNode ,
26                       const char *InputParameterName ,
27                       GraphEditor::InNode * DataFlowOutNode ,
28                       const char *OutputParameterName ,
29                       const bool Create ) :
30 //                      const SUPERV::Value_ptr aValue ) :
31   Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
32 //  MESSAGE("Link_Impl::Link_Impl activate object instanceName("
33 //          << instanceName << ") interfaceName(" << interfaceName << ") --> "
34 //          << hex << (void *) this << dec )
35   bool linksts ;
36   beginService( "Link_Impl::Link_Impl" );
37   _Orb = CORBA::ORB::_duplicate(orb);
38   _Poa = poa ;
39   _ContId = contId ;
40   _DataFlowEditor = DataFlowEditor ;
41   _DataFlowNode = DataFlowNode ;
42   _DataFlowNodeName = DataFlowNode->Name() ;
43   _InputParameterName = new char[ strlen( InputParameterName ) + 1 ] ;
44   strcpy( _InputParameterName , InputParameterName ) ;
45   _DataFlowOutNode = DataFlowOutNode ;
46   _DataFlowOutNodeName = DataFlowOutNode->Name() ;
47   _OutputParameterName = new char[ strlen( OutputParameterName ) + 1 ] ;
48   strcpy( _OutputParameterName , OutputParameterName ) ;
49   if ( Create ) {
50     linksts = _DataFlowEditor->AddLink( _DataFlowOutNode->Name() ,
51                                         _OutputParameterName , 
52                                         _DataFlowNode->Name() ,
53                                         _InputParameterName ) ;
54   }
55   else {
56     char * DataFlowOutNodeName = NULL ;
57     char * OutParamName = NULL ;
58     linksts = _DataFlowEditor->GetLink( _DataFlowNode->Name() ,
59                                         _InputParameterName , 
60                                         &DataFlowOutNodeName ,
61                                         &OutParamName ) ;
62   }
63   _thisObj = this ;
64   _id = _poa->activate_object(_thisObj);
65   endService( "Link_Impl::Link_Impl" );
66 }
67
68 Link_Impl::Link_Impl() {
69 }
70
71 Link_Impl::~Link_Impl() {
72   beginService( "Link_Impl::~Link_Impl" );
73   endService( "Link_Impl::~Link_Impl" );
74 }
75
76 void Link_Impl::destroy() {
77   beginService( "Link_Impl::destroy" );
78   Delete() ;
79   _poa->deactivate_object(*_id) ;
80   CORBA::release(_poa) ;
81   delete(_id) ;
82   _thisObj->_remove_ref();
83   endService( "Link_Impl::destroy" );
84 }
85
86 bool Link_Impl::Delete() {
87 //  beginService( "Link_Impl::Delete" ) ;
88   bool RetVal = _DataFlowEditor->RemoveLink( _DataFlowOutNode->Name() ,
89                                              _OutputParameterName ,
90                                              _DataFlowNode->Name() ,
91                                              _InputParameterName ) ;
92 //  endService( "Link_Impl::Delete" );
93   return RetVal ;
94 }
95
96 SUPERV::Port_ptr Link_Impl::InPort() {
97 //  beginService( "Link_Impl::InPort" );
98   GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _InputParameterName ) ;
99   Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId ,
100                                        instanceName() , interfaceName() ,
101                                        _DataFlowEditor ,
102                                        _DataFlowNode ,
103 //                                       _InputParameterName ) ;
104                                        (GraphBase::Port * ) anInPort ,
105                                        true ) ;
106   PortableServer::ObjectId * id = myPort->getId() ;
107   CORBA::Object_var obj = _poa->id_to_reference(*id);
108   SUPERV::Port_var iobject ;
109   iobject = SUPERV::Port::_narrow(obj) ;
110 //  endService( "Link_Impl::InPort" );
111   return SUPERV::Port::_duplicate( iobject ) ;
112 }
113
114 SUPERV::Port_ptr Link_Impl::OutPort() {
115 //  beginService( "Link_Impl::OutPort" );
116   GraphBase::OutPort * anOutPort = _DataFlowOutNode->GetChangeOutPort( _OutputParameterName ) ;
117   Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId ,
118                                        instanceName() , interfaceName() ,
119                                        _DataFlowEditor ,
120                                        _DataFlowOutNode ,
121 //                                       _OutputParameterName ) ;
122                                        (GraphBase::Port * ) anOutPort ,
123                                        false ) ;
124   PortableServer::ObjectId * id = myPort->getId() ;
125   CORBA::Object_var obj = _poa->id_to_reference(*id);
126   SUPERV::Port_var iobject ;
127   iobject = SUPERV::Port::_narrow(obj) ;
128 //  endService( "Link_Impl::OutPort" );
129   return SUPERV::Port::_duplicate( iobject ) ;
130 }
131
132 GraphBase::SLink * Link_Impl::Info() {
133 //  beginService( "Link_Impl::Info" );
134   char* FromNodeName ;
135   char* FromServiceParameterName ;
136   GraphBase::SLink * RetVal = _DataFlowEditor->GetLink( _DataFlowNode->ComputingNode() ,
137                                                         _InputParameterName ) ;
138 //  endService( "Link_Impl::Info" );
139   return RetVal ;
140 }
141
142 long Link_Impl::CoordsSize() {
143 //  beginService( "Link_Impl::CoordsSize" ) ;
144   long RetVal = _DataFlowEditor->GetLinkCoordSize( _DataFlowOutNode->Name() ,
145                                                    _OutputParameterName ,
146                                                    _DataFlowNode->Name() ,
147                                                    _InputParameterName ) ;
148 //  endService( "Link_Impl::CoordsSize" );
149   return RetVal ;
150 }
151 bool Link_Impl::AddCoord( const long index ,
152                           const long X ,
153                           const long Y ) {
154 //  beginService( "Link_Impl::AddCoord" ) ;
155   bool RetVal = _DataFlowEditor->AddLinkCoord( _DataFlowOutNode->Name() ,
156                                                _OutputParameterName ,
157                                                _DataFlowNode->Name() ,
158                                                _InputParameterName,
159                                                index , X , Y ) ;
160 //  endService( "Link_Impl::AddCoord" );
161   return RetVal ;
162 }
163 bool Link_Impl::ChangeCoord( const long index ,
164                              const long X ,
165                              const long Y ) {
166 //  beginService( "Link_Impl::ChangeCoord" ) ;
167   bool RetVal = _DataFlowEditor->ChangeLinkCoord( _DataFlowOutNode->Name() ,
168                                                   _OutputParameterName ,
169                                                   _DataFlowNode->Name() ,
170                                                   _InputParameterName,
171                                                   index , X , Y ) ;
172 //  endService( "Link_Impl::ChangeCoord" );
173   return RetVal ;
174 }
175 bool Link_Impl::RemoveCoord( const long index ) {
176 //  beginService( "Link_Impl::RemoveCoord" ) ;
177   bool RetVal = _DataFlowEditor->RemoveLinkCoord( _DataFlowOutNode->Name() ,
178                                                   _OutputParameterName ,
179                                                   _DataFlowNode->Name() ,
180                                                   _InputParameterName,
181                                                   index ) ;
182 //  endService( "Link_Impl::RemoveCoord" );
183   return RetVal ;
184 }
185 bool Link_Impl::Coords( const long index , long & X , long & Y ) {
186 //  beginService( "Link_Impl::Coords" ) ;
187   bool RetVal = _DataFlowEditor->GetLinkCoord( _DataFlowOutNode->Name() ,
188                                                _OutputParameterName ,
189                                                _DataFlowNode->Name() ,
190                                                _InputParameterName,
191                                                index ,  X , Y ) ;
192 //  endService( "Link_Impl::Coords" );
193   return RetVal ;
194 }
195