1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : Link_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "StreamLink_Impl.hxx"
39 Link_Impl::Link_Impl( CORBA::ORB_ptr orb ,
40 PortableServer::POA_ptr poa ,
41 PortableServer::ObjectId * contId ,
42 const char *instanceName ,
43 const char *interfaceName ,
44 GraphEditor::DataFlow * DataFlowEditor ,
45 GraphEditor::InNode * DataFlowNode ,
46 const char *InputParameterName ,
47 GraphEditor::InNode * DataFlowOutNode ,
48 const char *OutputParameterName ,
52 Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
53 // MESSAGE("Link_Impl::Link_Impl activate object instanceName("
54 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
55 // << hex << (void *) this << dec )
56 // beginService( "Link_Impl::Link_Impl" );
57 _Orb = CORBA::ORB::_duplicate(orb);
60 _DataFlowEditor = DataFlowEditor ;
61 _DataFlowNode = DataFlowNode ;
62 _DataFlowNodeName = DataFlowNode->Name() ;
63 _InputParameterName = new char[ strlen( InputParameterName ) + 1 ] ;
64 strcpy( _InputParameterName , InputParameterName ) ;
65 _DataFlowOutNode = DataFlowOutNode ;
66 _DataFlowOutNodeName = DataFlowOutNode->Name() ;
67 _OutputParameterName = new char[ strlen( OutputParameterName ) + 1 ] ;
68 strcpy( _OutputParameterName , OutputParameterName ) ;
70 Success = _DataFlowEditor->AddLink( _DataFlowOutNode->Name() ,
71 _OutputParameterName ,
72 _DataFlowNode->Name() ,
73 _InputParameterName ) ;
76 char * DataFlowOutNodeName = NULL ;
77 char * OutParamName = NULL ;
78 Success = _DataFlowEditor->GetLink( _DataFlowNode->Name() ,
80 &DataFlowOutNodeName ,
88 _id = _poa->activate_object(_thisObj) ;
90 // endService( "Link_Impl::Link_Impl" );
93 Link_Impl::Link_Impl() {
96 Link_Impl::~Link_Impl() {
97 beginService( "Link_Impl::~Link_Impl" );
98 endService( "Link_Impl::~Link_Impl" );
101 void Link_Impl::destroy() {
102 beginService( "Link_Impl::destroy" );
104 _poa->deactivate_object(*_id) ;
105 CORBA::release(_poa) ;
107 _thisObj->_remove_ref();
108 endService( "Link_Impl::destroy" );
111 bool Link_Impl::Delete() {
112 // beginService( "Link_Impl::Delete" ) ;
113 bool RetVal = _DataFlowEditor->RemoveLink( _DataFlowOutNode->Name() ,
114 _OutputParameterName ,
115 _DataFlowNode->Name() ,
116 _InputParameterName ) ;
117 // endService( "Link_Impl::Delete" );
121 SUPERV::Port_ptr Link_Impl::InPort() {
122 // beginService( "Link_Impl::InPort" );
123 SUPERV::Port_var iobject = SUPERV::Port::_nil() ;
124 GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _InputParameterName ) ;
126 iobject = anInPort->ObjRef() ;
127 if ( CORBA::is_nil( iobject ) ) {
128 if ( !anInPort->IsDataStream() ) {
129 Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId ,
130 instanceName() , interfaceName() ,
133 (GraphBase::Port * ) anInPort ,
135 PortableServer::ObjectId * id = myPort->getId() ;
136 CORBA::Object_var obj = _poa->id_to_reference(*id);
137 iobject = SUPERV::Port::_narrow(obj) ;
138 anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ;
141 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
142 _Orb , _Poa , _ContId ,
143 instanceName() , interfaceName() ,
146 (GraphBase::Port * ) anInPort ,
148 PortableServer::ObjectId * id = myStreamPort->getId() ;
149 CORBA::Object_var obj = _poa->id_to_reference(*id);
150 SUPERV::StreamPort_var iStreamobject ;
151 iStreamobject = SUPERV::StreamPort::_narrow(obj) ;
152 anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iStreamobject ) ) ;
153 iobject = SUPERV::Port::_narrow( iStreamobject ) ;
157 iobject = anInPort->ObjRef() ;
160 // endService( "Link_Impl::InPort" );
161 return SUPERV::Port::_duplicate( iobject ) ;
164 SUPERV::Port_ptr Link_Impl::OutPort() {
165 // beginService( "Link_Impl::OutPort" );
166 SUPERV::Port_var iobject = SUPERV::Port::_nil() ;
167 GraphBase::OutPort * anOutPort = _DataFlowOutNode->GetChangeOutPort( _OutputParameterName ) ;
169 iobject = anOutPort->ObjRef() ;
170 if ( CORBA::is_nil( iobject ) ) {
171 if ( !anOutPort->IsDataStream() ) {
172 Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId ,
173 instanceName() , interfaceName() ,
176 (GraphBase::Port * ) anOutPort ,
178 PortableServer::ObjectId * id = myPort->getId() ;
179 CORBA::Object_var obj = _poa->id_to_reference(*id);
180 iobject = SUPERV::Port::_narrow(obj) ;
181 anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ;
184 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
185 _Orb , _Poa , _ContId ,
186 instanceName() , interfaceName() ,
189 (GraphBase::Port * ) anOutPort ,
191 PortableServer::ObjectId * id = myStreamPort->getId() ;
192 CORBA::Object_var obj = _poa->id_to_reference(*id);
193 SUPERV::StreamPort_var iStreamobject ;
194 iStreamobject = SUPERV::StreamPort::_narrow(obj) ;
195 anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iStreamobject ) ) ;
196 iobject = SUPERV::Port::_narrow( iStreamobject ) ;
200 iobject = anOutPort->ObjRef() ;
203 // endService( "Link_Impl::OutPort" );
204 return SUPERV::Port::_duplicate( iobject ) ;
207 GraphBase::SLink * Link_Impl::Info() {
208 // beginService( "Link_Impl::Info" );
209 // char* FromNodeName ;
210 // char* FromServiceParameterName ;
211 GraphBase::SLink * RetVal = _DataFlowEditor->GetLink( _DataFlowNode->ComputingNode() ,
212 _InputParameterName ) ;
213 // endService( "Link_Impl::Info" );
217 long Link_Impl::CoordsSize() {
218 // beginService( "Link_Impl::CoordsSize" ) ;
219 long RetVal = _DataFlowEditor->GetLinkCoordSize( _DataFlowOutNode->Name() ,
220 _OutputParameterName ,
221 _DataFlowNode->Name() ,
222 _InputParameterName ) ;
223 // endService( "Link_Impl::CoordsSize" );
226 bool Link_Impl::AddCoord( const long index ,
229 // beginService( "Link_Impl::AddCoord" ) ;
230 bool RetVal = _DataFlowEditor->AddLinkCoord( _DataFlowOutNode->Name() ,
231 _OutputParameterName ,
232 _DataFlowNode->Name() ,
235 // endService( "Link_Impl::AddCoord" );
238 bool Link_Impl::ChangeCoord( const long index ,
241 // beginService( "Link_Impl::ChangeCoord" ) ;
242 bool RetVal = _DataFlowEditor->ChangeLinkCoord( _DataFlowOutNode->Name() ,
243 _OutputParameterName ,
244 _DataFlowNode->Name() ,
247 // endService( "Link_Impl::ChangeCoord" );
250 bool Link_Impl::RemoveCoord( const long index ) {
251 // beginService( "Link_Impl::RemoveCoord" ) ;
252 bool RetVal = _DataFlowEditor->RemoveLinkCoord( _DataFlowOutNode->Name() ,
253 _OutputParameterName ,
254 _DataFlowNode->Name() ,
257 // endService( "Link_Impl::RemoveCoord" );
260 bool Link_Impl::Coords( const long index , long & X , long & Y ) {
261 // beginService( "Link_Impl::Coords" ) ;
262 bool RetVal = _DataFlowEditor->GetLinkCoord( _DataFlowOutNode->Name() ,
263 _OutputParameterName ,
264 _DataFlowNode->Name() ,
267 // endService( "Link_Impl::Coords" );