]> SALOME platform Git repositories - modules/superv.git/blob - src/Supervision/StreamLink_Impl.cxx
Salome HOME
*** empty log message ***
[modules/superv.git] / src / Supervision / StreamLink_Impl.cxx
1 //  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : StreamLink_Impl.cxx
25 //  Author : Jean Rahuel
26 //  Module : SUPERV
27 //  $Header: 
28
29 using namespace std;
30
31 #include "StreamLink_Impl.hxx"
32
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 ,
43                                   const bool Create ) :
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 )
50   bool linksts ;
51 //  beginService( "StreamLink_Impl::Link_Impl" );
52   _Orb = CORBA::ORB::_duplicate(orb);
53   _Poa = poa ;
54   _ContId = contId ;
55   if ( Create ) {
56     linksts = DataFlowEditor->AddLink( DataFlowOutNode->Name() ,
57                                        OutputParameterName , 
58                                        DataFlowNode->Name() ,
59                                        InputParameterName ) ;
60   }
61   else {
62     char * DataFlowOutNodeName = NULL ;
63     char * OutParamName = NULL ;
64     linksts = DataFlowEditor->GetLink( DataFlowNode->Name() ,
65                                        InputParameterName , 
66                                        &DataFlowOutNodeName ,
67                                        &OutParamName ) ;
68   }
69   _thisObj = this ;
70   _id = _poa->activate_object(_thisObj);
71 //  endService( "StreamLink_Impl::Link_Impl" );
72 }
73
74 StreamLink_Impl::StreamLink_Impl() {
75 }
76
77 StreamLink_Impl::~StreamLink_Impl() {
78   beginService( "Link_Impl::~Link_Impl" );
79   endService( "Link_Impl::~Link_Impl" );
80 }
81
82 void StreamLink_Impl::destroy() {
83   beginService( "StreamLink_Impl::destroy" );
84   Delete() ;
85   _poa->deactivate_object(*_id) ;
86   CORBA::release(_poa) ;
87   delete(_id) ;
88   _thisObj->_remove_ref();
89   endService( "StreamLink_Impl::destroy" );
90 }
91
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" );
99   return RetVal ;
100 }
101
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() ,
114                                        DataFlowEditor() ,
115                                        DataFlowNode() ,
116                                        (GraphBase::Port * ) anInPort ,
117                                        true ) ;
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 ) ) ;
122     }
123     else {
124 //      MESSAGE( "StreamLink_Impl::InStreamPort Gets ObjRef "
125 //               << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
126     }
127   }
128 //  endService( "StreamLink_Impl::InStreamPort" );
129   return SUPERV::StreamPort::_duplicate( iobject ) ;
130 }
131
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() ,
144                                        DataFlowEditor() ,
145                                        DataFlowOutNode() ,
146                                        (GraphBase::Port * ) anOutPort ,
147                                        false ) ;
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 ) ) ;
152     }
153     else {
154 //      MESSAGE( "StreamLink_Impl::OutStreamPort Gets ObjRef "
155 //               << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
156     }
157   }
158 //  endService( "StreamLink_Impl::OutStreamPort" );
159   return SUPERV::StreamPort::_duplicate( iobject ) ;
160 }
161