1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
23 // File : StreamLink_Impl.cxx
24 // Author : Jean Rahuel
30 #include "StreamLink_Impl.hxx"
32 StreamLink_Impl::StreamLink_Impl( CORBA::ORB_ptr orb ,
33 PortableServer::POA_ptr poa ,
34 PortableServer::ObjectId * contId ,
35 const char *instanceName ,
36 const char *interfaceName ,
37 GraphEditor::DataFlow * DataFlowEditor ,
38 GraphEditor::InNode * DataFlowNode ,
39 const char *InputParameterName ,
40 GraphEditor::InNode * DataFlowOutNode ,
41 const char *OutputParameterName ,
44 Link_Impl( orb , poa , contId , instanceName , interfaceName , DataFlowEditor ,
45 DataFlowNode , InputParameterName , DataFlowOutNode ,
46 OutputParameterName , false , false , Success ) {
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 Success = DataFlowEditor->AddLink( DataFlowOutNode->Name() ,
58 DataFlowNode->Name() ,
59 InputParameterName ) ;
62 char * DataFlowOutNodeName = NULL ;
63 char * OutParamName = NULL ;
64 Success = 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() ) ;
99 DataFlowEditor()->UnValid() ;
101 // endService( "StreamLink_Impl::Delete" );
105 SUPERV::StreamPort_ptr StreamLink_Impl::InStreamPort() {
106 // beginService( "Link_Impl::InStreamPort" );
107 SUPERV::StreamPort_var iobject = SUPERV::StreamPort::_nil() ;
108 GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( InputParameterName() ) ;
109 if ( anInPort && anInPort->IsDataStream() ) {
110 iobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ;
111 if ( CORBA::is_nil( iobject ) ) {
112 // MESSAGE( "StreamLink_Impl::InStreamPort creates myStreamPort "
113 // << DataFlowNode()->Name() << "( " << anInPort->PortName() << " )" ) ;
114 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
115 _Orb , _Poa , _ContId ,
116 instanceName() , interfaceName() ,
119 (GraphBase::Port * ) anInPort ,
121 PortableServer::ObjectId * id = myStreamPort->getId() ;
122 CORBA::Object_var obj = _poa->id_to_reference(*id);
123 iobject = SUPERV::StreamPort::_narrow(obj) ;
124 anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ;
127 // MESSAGE( "StreamLink_Impl::InStreamPort Gets ObjRef "
128 // << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
131 // endService( "StreamLink_Impl::InStreamPort" );
132 return SUPERV::StreamPort::_duplicate( iobject ) ;
135 SUPERV::StreamPort_ptr StreamLink_Impl::OutStreamPort() {
136 // beginService( "StreamLink_Impl::OutStreamPort" );
137 SUPERV::StreamPort_var iobject ;
138 GraphBase::OutPort * anOutPort = DataFlowOutNode()->GetChangeOutPort( OutputParameterName() ) ;
139 if ( anOutPort && anOutPort->IsDataStream() ) {
140 iobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ;
141 if ( CORBA::is_nil( iobject ) ) {
142 // MESSAGE( "StreamLink_Impl::OutStreamPort creates myStreamPort "
143 // << DataFlowNode()->Name() << "( " << anOutPort->PortName() << " )" ) ;
144 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
145 _Orb , _Poa , _ContId ,
146 instanceName() , interfaceName() ,
149 (GraphBase::Port * ) anOutPort ,
151 PortableServer::ObjectId * id = myStreamPort->getId() ;
152 CORBA::Object_var obj = _poa->id_to_reference(*id);
153 iobject = SUPERV::StreamPort::_narrow(obj) ;
154 anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ;
157 // MESSAGE( "StreamLink_Impl::OutStreamPort Gets ObjRef "
158 // << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
161 // endService( "StreamLink_Impl::OutStreamPort" );
162 return SUPERV::StreamPort::_duplicate( iobject ) ;