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" ) ;
138 StreamLink_Impl * myStreamLink = new StreamLink_Impl( _Orb , _Poa , _ContId ,
139 instanceName() , interfaceName() ,
142 DataFlowPort()->PortName() ,
143 (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( FromNodeName )->GetInNode() ,
144 FromServiceParameterName ,
147 PortableServer::ObjectId * id = myStreamLink->getId() ;
148 CORBA::Object_var obj = _poa->id_to_reference(*id);
149 iobject = SUPERV::StreamLink::_narrow(obj) ;
150 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ;
154 iobject = SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ;
159 MESSAGE( "Link " << iobject->OutPort()->Node()->Name() << "( " << iobject->OutPort()->Name() << " ) --> "
160 << iobject->InPort()->Node()->Name() << "( " << iobject->InPort()->Name() << " ) " ) ;
161 endService( "StreamPort_Impl::StreamLink" ) ;
163 return SUPERV::StreamLink::_duplicate( iobject ) ;
166 SALOME_ModuleCatalog::DataStreamDependency StreamPort_Impl::Dependency() {
167 // beginService( "StreamPort_Impl::Dependency" );
168 SALOME_ModuleCatalog::DataStreamDependency RetVal = DataFlowPort()->Dependency() ;
169 // endService( "StreamPort_Impl::Dependency" );
173 bool StreamPort_Impl::SetDependency( const SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
174 // beginService( "StreamPort_Impl::SetDependency" );
175 DataFlowPort()->Dependency( aDependency ) ;
176 // endService( "StreamPort_Impl::SetDependency" );
180 bool StreamPort_Impl::SetParams( const SUPERV::KindOfSchema aKindOfSchema ,
181 const SUPERV::KindOfInterpolation aKindOfInterpolation ,
182 const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) {
183 // beginService( "StreamPort_Impl::SetParams" );
184 bool RetVal = false ;
186 GraphBase::InDataStreamPort * anInStreamPort = (GraphBase::InDataStreamPort * ) DataFlowPort() ;
187 RetVal = anInStreamPort->SetParams( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
189 MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation
190 << " , " << aKindOfExtrapolation << " ) SUCCESS " ) ;
191 DataFlowEditor()->UnValid() ;
194 MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation
195 << " , " << aKindOfExtrapolation << " ) FAILED " ) ;
199 MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation
200 << " , " << aKindOfExtrapolation << " ) ERROR : OutPort" ) ;
202 // endService( "StreamPort_Impl::SetParams" );
206 bool StreamPort_Impl::Params( SUPERV::KindOfSchema & aKindOfSchema ,
207 SUPERV::KindOfInterpolation & aKindOfInterpolation ,
208 SUPERV::KindOfExtrapolation & aKindOfExtrapolation ) {
209 // beginService( "StreamPort_Impl::Params" );
210 bool RetVal = false ;
212 GraphBase::InDataStreamPort * anInStreamPort = (GraphBase::InDataStreamPort * ) DataFlowPort() ;
213 anInStreamPort->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
214 MESSAGE( "InStreamPort_Impl::Params( " << aKindOfSchema << " , " << aKindOfInterpolation << " , " << aKindOfExtrapolation << " )" ) ;
218 aKindOfSchema = (SUPERV::KindOfSchema ) -1 ;
219 aKindOfInterpolation = (SUPERV::KindOfInterpolation ) -1 ;
220 aKindOfExtrapolation = (SUPERV::KindOfExtrapolation ) -1 ;
221 MESSAGE( "OutStreamPort_Impl::Params( " << aKindOfSchema << " , " << aKindOfInterpolation
222 << " , " << aKindOfExtrapolation << " ) ERROR: OutPort" ) ;
224 // endService( "StreamPort_Impl::Params" );
228 bool StreamPort_Impl::SetNumberOfValues( const long aNumberOfValues ) {
229 // beginService( "StreamPort_Impl::SetNumberOfValues" );
230 bool RetVal = false ;
232 GraphBase::OutDataStreamPort * anOutStreamPort = (GraphBase::OutDataStreamPort * ) DataFlowPort() ;
233 anOutStreamPort->NumberOfValues( aNumberOfValues ) ;
234 DataFlowEditor()->UnValid() ;
238 MESSAGE( "OutStreamPort_Impl::SetNumberOfValues( " << aNumberOfValues << " ) ERROR : InPort" ) ;
240 // endService( "StreamPort_Impl::SetNumberOfValues" );
244 long StreamPort_Impl::NumberOfValues() {
245 // beginService( "StreamPort_Impl::NumberOfValues" );
248 GraphBase::OutDataStreamPort * anOutStreamPort = (GraphBase::OutDataStreamPort * ) DataFlowPort() ;
249 RetVal = anOutStreamPort->NumberOfValues() ;
250 MESSAGE( "OutStreamPort_Impl::NumberOfValues() " << RetVal ) ;
253 MESSAGE( "OutStreamPort_Impl::NumberOfValues() ERROR : InPort" ) ;
255 // endService( "StreamPort_Impl::NumberOfValues" );