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 : StreamLink_Impl.cxx
25 // Author : Jean Rahuel
31 #include "StreamLink_Impl.hxx"
33 StreamLink_Impl::StreamLink_Impl( CORBA::ORB_ptr orb ,
34 PortableServer::POA_ptr poa ,
35 PortableServer::ObjectId * contId ,
36 const char *instanceName ,
37 const char *interfaceName ,
38 GraphEditor::DataFlow * DataFlowEditor ,
39 GraphEditor::InNode * DataFlowNode ,
40 const char *InputParameterName ,
41 GraphEditor::InNode * DataFlowOutNode ,
42 const char *OutputParameterName ,
44 Link_Impl( orb , poa , contId , instanceName , interfaceName , DataFlowEditor ,
45 DataFlowNode , InputParameterName , DataFlowOutNode ,
46 OutputParameterName , false , false ) {
47 // MESSAGE("StreamLink_Impl::StreamLink_Impl activate object instanceName("
48 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
49 // << hex << (void *) this << dec )
51 // beginService( "StreamLink_Impl::Link_Impl" );
52 _Orb = CORBA::ORB::_duplicate(orb);
56 linksts = DataFlowEditor->AddLink( DataFlowOutNode->Name() ,
58 DataFlowNode->Name() ,
59 InputParameterName ) ;
62 char * DataFlowOutNodeName = NULL ;
63 char * OutParamName = NULL ;
64 linksts = DataFlowEditor->GetLink( DataFlowNode->Name() ,
66 &DataFlowOutNodeName ,
70 _id = _poa->activate_object(_thisObj);
71 // endService( "StreamLink_Impl::Link_Impl" );
74 StreamLink_Impl::StreamLink_Impl() {
77 StreamLink_Impl::~StreamLink_Impl() {
78 beginService( "Link_Impl::~Link_Impl" );
79 endService( "Link_Impl::~Link_Impl" );
82 void StreamLink_Impl::destroy() {
83 beginService( "StreamLink_Impl::destroy" );
85 _poa->deactivate_object(*_id) ;
86 CORBA::release(_poa) ;
88 _thisObj->_remove_ref();
89 endService( "StreamLink_Impl::destroy" );
92 bool StreamLink_Impl::Delete() {
93 // beginService( "StreamLink_Impl::Delete" ) ;
94 bool RetVal = DataFlowEditor()->RemoveLink( DataFlowOutNode()->Name() ,
95 OutputParameterName() ,
96 DataFlowNode()->Name() ,
97 InputParameterName() ) ;
98 // endService( "StreamLink_Impl::Delete" );
102 SUPERV::StreamPort_ptr StreamLink_Impl::InStreamPort() {
103 // beginService( "Link_Impl::InStreamPort" );
104 SUPERV::StreamPort_var iobject = SUPERV::StreamPort::_nil() ;
105 GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( InputParameterName() ) ;
106 if ( anInPort && anInPort->IsDataStream() ) {
107 iobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ;
108 if ( CORBA::is_nil( iobject ) ) {
109 // MESSAGE( "StreamLink_Impl::InStreamPort creates myStreamPort "
110 // << DataFlowNode()->Name() << "( " << anInPort->PortName() << " )" ) ;
111 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
112 _Orb , _Poa , _ContId ,
113 instanceName() , interfaceName() ,
116 (GraphBase::Port * ) anInPort ,
118 PortableServer::ObjectId * id = myStreamPort->getId() ;
119 CORBA::Object_var obj = _poa->id_to_reference(*id);
120 iobject = SUPERV::StreamPort::_narrow(obj) ;
121 anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ;
124 // MESSAGE( "StreamLink_Impl::InStreamPort Gets ObjRef "
125 // << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
128 // endService( "StreamLink_Impl::InStreamPort" );
129 return SUPERV::StreamPort::_duplicate( iobject ) ;
132 SUPERV::StreamPort_ptr StreamLink_Impl::OutStreamPort() {
133 // beginService( "StreamLink_Impl::OutStreamPort" );
134 SUPERV::StreamPort_var iobject ;
135 GraphBase::OutPort * anOutPort = DataFlowOutNode()->GetChangeOutPort( OutputParameterName() ) ;
136 if ( anOutPort && anOutPort->IsDataStream() ) {
137 iobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ;
138 if ( CORBA::is_nil( iobject ) ) {
139 // MESSAGE( "StreamLink_Impl::OutStreamPort creates myStreamPort "
140 // << DataFlowNode()->Name() << "( " << anOutPort->PortName() << " )" ) ;
141 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
142 _Orb , _Poa , _ContId ,
143 instanceName() , interfaceName() ,
146 (GraphBase::Port * ) anOutPort ,
148 PortableServer::ObjectId * id = myStreamPort->getId() ;
149 CORBA::Object_var obj = _poa->id_to_reference(*id);
150 iobject = SUPERV::StreamPort::_narrow(obj) ;
151 anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ;
154 // MESSAGE( "StreamLink_Impl::OutStreamPort Gets ObjRef "
155 // << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
158 // endService( "StreamLink_Impl::OutStreamPort" );
159 return SUPERV::StreamPort::_duplicate( iobject ) ;