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 ,
45 Link_Impl( orb , poa , contId , instanceName , interfaceName , DataFlowEditor ,
46 DataFlowNode , InputParameterName , DataFlowOutNode ,
47 OutputParameterName , false , false , Success ) {
48 // MESSAGE("StreamLink_Impl::StreamLink_Impl activate object instanceName("
49 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
50 // << hex << (void *) this << dec )
52 // beginService( "StreamLink_Impl::Link_Impl" );
53 _Orb = CORBA::ORB::_duplicate(orb);
57 Success = DataFlowEditor->AddLink( DataFlowOutNode->Name() ,
59 DataFlowNode->Name() ,
60 InputParameterName ) ;
63 char * DataFlowOutNodeName = NULL ;
64 char * OutParamName = NULL ;
65 Success = DataFlowEditor->GetLink( DataFlowNode->Name() ,
67 &DataFlowOutNodeName ,
71 _id = _poa->activate_object(_thisObj);
72 // endService( "StreamLink_Impl::Link_Impl" );
75 StreamLink_Impl::StreamLink_Impl() {
78 StreamLink_Impl::~StreamLink_Impl() {
79 beginService( "Link_Impl::~Link_Impl" );
80 endService( "Link_Impl::~Link_Impl" );
83 void StreamLink_Impl::destroy() {
84 beginService( "StreamLink_Impl::destroy" );
86 _poa->deactivate_object(*_id) ;
87 CORBA::release(_poa) ;
89 _thisObj->_remove_ref();
90 endService( "StreamLink_Impl::destroy" );
93 bool StreamLink_Impl::Delete() {
94 // beginService( "StreamLink_Impl::Delete" ) ;
95 bool RetVal = DataFlowEditor()->RemoveLink( DataFlowOutNode()->Name() ,
96 OutputParameterName() ,
97 DataFlowNode()->Name() ,
98 InputParameterName() ) ;
100 DataFlowEditor()->UnValid() ;
102 // endService( "StreamLink_Impl::Delete" );
106 SUPERV::StreamPort_ptr StreamLink_Impl::InStreamPort() {
107 // beginService( "Link_Impl::InStreamPort" );
108 SUPERV::StreamPort_var iobject = SUPERV::StreamPort::_nil() ;
109 GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( InputParameterName() ) ;
110 if ( anInPort && anInPort->IsDataStream() ) {
111 iobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ;
112 if ( CORBA::is_nil( iobject ) ) {
113 // MESSAGE( "StreamLink_Impl::InStreamPort creates myStreamPort "
114 // << DataFlowNode()->Name() << "( " << anInPort->PortName() << " )" ) ;
115 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
116 _Orb , _Poa , _ContId ,
117 instanceName() , interfaceName() ,
120 (GraphBase::Port * ) anInPort ,
122 PortableServer::ObjectId * id = myStreamPort->getId() ;
123 CORBA::Object_var obj = _poa->id_to_reference(*id);
124 iobject = SUPERV::StreamPort::_narrow(obj) ;
125 anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ;
128 // MESSAGE( "StreamLink_Impl::InStreamPort Gets ObjRef "
129 // << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
132 // endService( "StreamLink_Impl::InStreamPort" );
133 return SUPERV::StreamPort::_duplicate( iobject ) ;
136 SUPERV::StreamPort_ptr StreamLink_Impl::OutStreamPort() {
137 // beginService( "StreamLink_Impl::OutStreamPort" );
138 SUPERV::StreamPort_var iobject ;
139 GraphBase::OutPort * anOutPort = DataFlowOutNode()->GetChangeOutPort( OutputParameterName() ) ;
140 if ( anOutPort && anOutPort->IsDataStream() ) {
141 iobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ;
142 if ( CORBA::is_nil( iobject ) ) {
143 // MESSAGE( "StreamLink_Impl::OutStreamPort creates myStreamPort "
144 // << DataFlowNode()->Name() << "( " << anOutPort->PortName() << " )" ) ;
145 StreamPort_Impl * myStreamPort = new StreamPort_Impl(
146 _Orb , _Poa , _ContId ,
147 instanceName() , interfaceName() ,
150 (GraphBase::Port * ) anOutPort ,
152 PortableServer::ObjectId * id = myStreamPort->getId() ;
153 CORBA::Object_var obj = _poa->id_to_reference(*id);
154 iobject = SUPERV::StreamPort::_narrow(obj) ;
155 anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ;
158 // MESSAGE( "StreamLink_Impl::OutStreamPort Gets ObjRef "
159 // << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
162 // endService( "StreamLink_Impl::OutStreamPort" );
163 return SUPERV::StreamPort::_duplicate( iobject ) ;