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 : StreamPort_Impl.cxx
25 // Author : Jean Rahuel
31 #include "StreamPort_Impl.hxx"
33 StreamPort_Impl::StreamPort_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 GraphBase::Port * DataFlowPort ,
42 const CORBA::Any * anAny ) :
43 Port_Impl( orb , poa , contId , instanceName , interfaceName ,
44 DataFlowEditor , DataFlowNode , DataFlowPort , InputPort , anAny ) {
45 // MESSAGE("StreamPort_Impl::StreamPort_Impl activate object instanceName("
46 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
47 // << hex << (void *) this << dec )
48 _Orb = CORBA::ORB::_duplicate(orb);
52 _id = _poa->activate_object(_thisObj);
55 StreamPort_Impl::StreamPort_Impl( CORBA::ORB_ptr orb ,
56 PortableServer::POA_ptr poa ,
57 PortableServer::ObjectId * contId ,
58 const char *instanceName ,
59 const char *interfaceName ,
60 GraphEditor::DataFlow * DataFlowEditor ,
61 GraphEditor::InNode * DataFlowNode ,
62 GraphBase::Port * DataFlowPort ,
64 Port_Impl( orb , poa , contId , instanceName , interfaceName ,
65 DataFlowEditor , DataFlowNode , DataFlowPort , InputPort ) {
66 // MESSAGE("StreamPort_Impl::StreamPorte_Impl activate object instanceName("
67 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
68 // << hex << (void *) this << dec )
69 _Orb = CORBA::ORB::_duplicate(orb);
73 _id = _poa->activate_object(_thisObj);
76 StreamPort_Impl::StreamPort_Impl() {
79 StreamPort_Impl::~StreamPort_Impl() {
80 beginService( "StreamPort_Impl::~StreamPort_Impl" );
81 endService( "StreamPort_Impl::~StreamPort_Impl" );
84 void StreamPort_Impl::destroy() {
85 beginService( "StreamPort_Impl::destroy" );
86 bool destroyed = false ;
87 if ( DataFlowNode()->IsOneOfInLineNodes() ) {
89 GraphBase::InPort * anInPort = (GraphBase::InPort * ) DataFlowPort() ;
90 if ( anInPort->GetOutPort() ) {
91 anInPort->GetOutPort()->RemoveInPort( anInPort ) ;
93 DataFlowNode()->DelInPort( DataFlowPort()->PortName() ) ;
97 DataFlowNode()->DelOutPort( DataFlowPort()->PortName() ) ;
101 DataFlowEditor()->UnValid() ;
105 _poa->deactivate_object(*_id) ;
106 CORBA::release(_poa) ;
108 _thisObj->_remove_ref();
110 endService( "StreamPort_Impl::destroy" );
114 SUPERV::StreamLink_ptr StreamPort_Impl::StreamLink() {
116 SUPERV::StreamLink_var iobject = SUPERV::StreamLink::_nil() ;
117 char * FromNodeName = NULL ;
118 char * FromServiceParameterName = NULL ;
119 bool status = DataFlowEditor()->GetLink( DataFlowNode()->Name() ,
120 DataFlowPort()->PortName() ,
122 & FromServiceParameterName ) ;
124 // cout << "Port_Impl::Link " << FromNodeName << "("
125 // << FromServiceParameterName << ") --> " << _DataFlowNode->Name()
126 // << "(" << _DataFlowPort->PortName() << ")" << endl ;
127 // SUPERV::Port_ptr theOutPort = Port( FromServiceParameterName ) ;
129 GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( DataFlowPort()->PortName() ) ;
130 if ( anInPort->GetOutPort() ) {
131 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
132 if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
134 beginService( "Port_Impl::Link" ) ;
137 StreamLink_Impl * myStreamLink = new StreamLink_Impl( _Orb , _Poa , _ContId ,
138 instanceName() , interfaceName() ,
141 DataFlowPort()->PortName() ,
142 (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( FromNodeName )->GetInNode() ,
143 FromServiceParameterName ,
145 PortableServer::ObjectId * id = myStreamLink->getId() ;
146 CORBA::Object_var obj = _poa->id_to_reference(*id);
147 iobject = SUPERV::StreamLink::_narrow(obj) ;
148 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ;
151 iobject = SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ;
156 MESSAGE( "Link " << iobject->OutPort()->Node()->Name() << "( " << iobject->OutPort()->Name() << " ) --> "
157 << iobject->InPort()->Node()->Name() << "( " << iobject->InPort()->Name() << " ) " ) ;
158 endService( "StreamPort_Impl::StreamLink" ) ;
160 return SUPERV::StreamLink::_duplicate( iobject ) ;
163 SALOME_ModuleCatalog::DataStreamDependency StreamPort_Impl::Dependency() {
164 // beginService( "StreamPort_Impl::Dependency" );
165 SALOME_ModuleCatalog::DataStreamDependency RetVal = DataFlowPort()->Dependency() ;
166 // endService( "StreamPort_Impl::Dependency" );
170 bool StreamPort_Impl::SetDependency( const SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
171 // beginService( "StreamPort_Impl::SetDependency" );
172 DataFlowPort()->Dependency( aDependency ) ;
173 // endService( "StreamPort_Impl::SetDependency" );
177 bool StreamPort_Impl::SetParams( const SUPERV::KindOfSchema aKindOfSchema ,
178 const SUPERV::KindOfInterpolation aKindOfInterpolation ,
179 const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) {
180 // beginService( "StreamPort_Impl::SetParams" );
181 bool RetVal = false ;
183 GraphBase::InDataStreamPort * anInStreamPort = (GraphBase::InDataStreamPort * ) DataFlowPort() ;
184 RetVal = anInStreamPort->SetParams( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
185 MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation
186 << " , " << aKindOfExtrapolation << " ) sts " << RetVal ) ;
189 MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation
190 << " , " << aKindOfExtrapolation << " ) ERROR : OutPort" ) ;
192 // endService( "StreamPort_Impl::SetParams" );
196 bool StreamPort_Impl::Params( SUPERV::KindOfSchema & aKindOfSchema ,
197 SUPERV::KindOfInterpolation & aKindOfInterpolation ,
198 SUPERV::KindOfExtrapolation & aKindOfExtrapolation ) {
199 // beginService( "StreamPort_Impl::Params" );
200 bool RetVal = false ;
202 GraphBase::InDataStreamPort * anInStreamPort = (GraphBase::InDataStreamPort * ) DataFlowPort() ;
203 anInStreamPort->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
204 MESSAGE( "InStreamPort_Impl::Params( " << aKindOfSchema << " , " << aKindOfInterpolation << " , " << aKindOfExtrapolation << " )" ) ;
208 aKindOfSchema = (SUPERV::KindOfSchema ) -1 ;
209 aKindOfInterpolation = (SUPERV::KindOfInterpolation ) -1 ;
210 aKindOfExtrapolation = (SUPERV::KindOfExtrapolation ) -1 ;
211 MESSAGE( "OutStreamPort_Impl::Params( " << aKindOfSchema << " , " << aKindOfInterpolation
212 << " , " << aKindOfExtrapolation << " ) ERROR: OutPort" ) ;
214 // endService( "StreamPort_Impl::Params" );
218 bool StreamPort_Impl::SetNumberOfValues( const long aNumberOfValues ) {
219 // beginService( "StreamPort_Impl::SetNumberOfValues" );
220 bool RetVal = false ;
222 GraphBase::OutDataStreamPort * anOutStreamPort = (GraphBase::OutDataStreamPort * ) DataFlowPort() ;
223 anOutStreamPort->NumberOfValues( aNumberOfValues ) ;
227 MESSAGE( "OutStreamPort_Impl::SetNumberOfValues( " << aNumberOfValues << " ) ERROR : InPort" ) ;
229 // endService( "StreamPort_Impl::SetNumberOfValues" );
233 long StreamPort_Impl::NumberOfValues() {
234 // beginService( "StreamPort_Impl::NumberOfValues" );
237 GraphBase::OutDataStreamPort * anOutStreamPort = (GraphBase::OutDataStreamPort * ) DataFlowPort() ;
238 RetVal = anOutStreamPort->NumberOfValues() ;
239 MESSAGE( "OutStreamPort_Impl::NumberOfValues() " << RetVal ) ;
242 MESSAGE( "OutStreamPort_Impl::NumberOfValues() ERROR : InPort" ) ;
244 // endService( "StreamPort_Impl::NumberOfValues" );