]> SALOME platform Git repositories - modules/superv.git/blob - src/Supervision/StreamLink_Impl.cxx
Salome HOME
Update copyright information
[modules/superv.git] / src / Supervision / StreamLink_Impl.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
23 //  File   : StreamLink_Impl.cxx
24 //  Author : Jean Rahuel
25 //  Module : SUPERV
26 //  $Header: 
27 //
28 using namespace std;
29
30 #include "StreamLink_Impl.hxx"
31
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 ,
42                                   const bool Create ,
43                                   bool & Success ) :
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 )
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     Success = DataFlowEditor->AddLink( DataFlowOutNode->Name() ,
57                                        OutputParameterName , 
58                                        DataFlowNode->Name() ,
59                                        InputParameterName ) ;
60   }
61   else {
62     char * DataFlowOutNodeName = NULL ;
63     char * OutParamName = NULL ;
64     Success = 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   if ( RetVal ) {
99     DataFlowEditor()->UnValid() ;
100   }
101 //  endService( "StreamLink_Impl::Delete" );
102   return RetVal ;
103 }
104
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() ,
117                                        DataFlowEditor() ,
118                                        DataFlowNode() ,
119                                        (GraphBase::Port * ) anInPort ,
120                                        true ) ;
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 ) ) ;
125     }
126     else {
127 //      MESSAGE( "StreamLink_Impl::InStreamPort Gets ObjRef "
128 //               << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
129     }
130   }
131 //  endService( "StreamLink_Impl::InStreamPort" );
132   return SUPERV::StreamPort::_duplicate( iobject ) ;
133 }
134
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() ,
147                                        DataFlowEditor() ,
148                                        DataFlowOutNode() ,
149                                        (GraphBase::Port * ) anOutPort ,
150                                        false ) ;
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 ) ) ;
155     }
156     else {
157 //      MESSAGE( "StreamLink_Impl::OutStreamPort Gets ObjRef "
158 //               << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ;
159     }
160   }
161 //  endService( "StreamLink_Impl::OutStreamPort" );
162   return SUPERV::StreamPort::_duplicate( iobject ) ;
163 }
164