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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GNode_Impl.cxx
23 // Author : Jean Rahuel
32 //#include "utilities.h"
34 #include "GNode_Impl.hxx"
36 GNode_Impl::GNode_Impl() {
39 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
40 PortableServer::POA_ptr poa ,
41 PortableServer::ObjectId * contId ,
42 const char *instanceName ,
43 const char *interfaceName ,
44 const char *aDataFlowName ,
45 const SUPERV::KindOfNode aKindOfNode ) :
46 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
47 // MESSAGE("GNode_Impl::GNode_Impl activate object instanceName("
48 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
49 // << hex << (void *) this << dec )
51 // _id = _poa->activate_object(_thisObj);
52 // MESSAGE( "GNode_Impl::GNode_Impl " << aDataFlowName );
53 // beginService( "GNode_Impl::GNode_Impl" );
54 _Orb = CORBA::ORB::_duplicate(orb);
57 // endService( "INode_Impl::INode_Impl" );
60 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
61 PortableServer::POA_ptr poa ,
62 PortableServer::ObjectId * contId ,
63 const char *instanceName ,
64 const char *interfaceName ,
65 GraphEditor::DataFlow * aDataFlowEditor ,
66 const char * FuncName ,
67 const SUPERV::ListOfStrings & PythonFunction ,
68 const SUPERV::KindOfNode NodeKindOfNode ) :
69 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
70 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , PythonFunction , NodeKindOfNode ) {
71 // MESSAGE( NodeName << " " );
72 // beginService( "GNode_Impl::GNode_Impl" );
74 // cout << "GNode_Impl::GNode_Impl " << (void *) FuncName << " " << FuncName
75 // << " " << strlen( FuncName ) << endl ;
77 if ( NodeKindOfNode == SUPERV::GOTONode ) {
79 _id = _poa->activate_object(_thisObj);
81 _Orb = CORBA::ORB::_duplicate(orb);
84 // DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
85 // NodeInterfaceName , NodeName ,
86 // NodeKindOfNode ) );
87 // DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
89 // NodeKindOfNode ) ) ;
90 // endService( "GNode_Impl::GNode_Impl" );
93 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
94 PortableServer::POA_ptr poa ,
95 PortableServer::ObjectId * contId ,
96 const char *instanceName ,
97 const char *interfaceName ,
98 GraphEditor::DataFlow * aDataFlowEditor ,
99 GraphBase::ListOfFuncName FuncNameList ,
100 GraphBase::ListOfPythonFunctions PythonFunctionList ,
101 const SUPERV::KindOfNode NodeKindOfNode ) :
102 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
103 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncNameList , PythonFunctionList , NodeKindOfNode ) {
104 // MESSAGE( NodeName << " " );
105 // beginService( "GNode_Impl::GNode_Impl" );
106 if ( NodeKindOfNode == SUPERV::GOTONode ) {
108 _id = _poa->activate_object(_thisObj);
110 _Orb = CORBA::ORB::_duplicate(orb);
113 // DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
114 // NodeInterfaceName , NodeName ,
115 // NodeKindOfNode ) );
116 // DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
118 // NodeKindOfNode ) ) ;
119 // endService( "GNode_Impl::GNode_Impl" );
122 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
123 PortableServer::POA_ptr poa ,
124 PortableServer::ObjectId * contId ,
125 const char *instanceName ,
126 const char *interfaceName ,
127 GraphEditor::DataFlow * aDataFlowEditor ,
128 GraphEditor::InNode * aDataFlowNode ) :
129 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
130 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
131 // beginService( "GNode_Impl::GNode_Impl" );
132 if ( DataFlowNode() && DataFlowNode()->IsGOTONode() ) {
133 // MESSAGE( "GNode_Impl::GNode_Impl " << DataFlowNode()->PyFuncName()
134 // << " _poa->activate_object" );
136 _id = _poa->activate_object(_thisObj);
139 // MESSAGE( "GNode_Impl::GNode_Impl NO _poa->activate_object" );
141 _Orb = CORBA::ORB::_duplicate(orb);
144 // endService( "GNode_Impl::GNode_Impl" );
147 GNode_Impl::~GNode_Impl() {
148 beginService( "GNode_Impl::~GNode_Impl" );
149 endService( "GNode_Impl::~GNode_Impl" );
152 void GNode_Impl::destroy() {
153 beginService( "GNode_Impl::Destroy" );
154 if ( DataFlowEditor()->IsEditing() ) {
156 _poa->deactivate_object(*_id) ;
157 // CORBA::release(_poa) ;
159 // _thisObj->_remove_ref();
162 MESSAGE("GNode_Impl::destroy ERROR ") ;
165 // endService( "GNode_Impl::Destroy" );
168 bool GNode_Impl::Delete() {
169 beginService( "GNode_Impl::Delete" );
170 bool RetVal = false ;
171 if ( DataFlowEditor()->IsEditing() ) {
172 if ( DataFlowNode() ) {
173 GraphBase::GOTONode * aGOTONode = DataFlowNode()->GOTONode() ;
175 GraphBase::GOTONode * aCoupledNode = (GraphBase::GOTONode * ) aGOTONode->CoupledNode() ;
176 if ( aCoupledNode && ( aCoupledNode->IsOneOfGOTONodes() || aCoupledNode->IsDataFlowNode() ||
177 aCoupledNode->IsDataStreamNode() ) ) {
178 aCoupledNode->CoupledNode( NULL ) ;
179 aCoupledNode->MacroObject( SUPERV::Graph::_nil() ) ;
180 aCoupledNode->GraphMacroLevel( 0 ) ;
185 RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
187 DataFlowEditor()->UnValid() ;
189 endService( "GNode_Impl::Delete" );
193 SUPERV::INode_ptr GNode_Impl::Coupled() {
194 // beginService( "GNode_Impl::Coupled" );
195 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
196 if ( DataFlowNode() ) {
197 if ( DataFlowNode()->CoupledNode() ) {
198 if ( CORBA::is_nil( DataFlowNode()->CoupledNode()->ObjRef() ) ) {
199 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
200 instanceName() , interfaceName() ,
202 (GraphEditor::InNode *) DataFlowNode()->CoupledNode()->GetInNode() ) ;
203 PortableServer::ObjectId * id = myNode->getId() ;
204 CORBA::Object_var obj = _poa->id_to_reference(*id);
205 iobject = SUPERV::INode::_narrow(obj) ;
206 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
209 iobject = SUPERV::INode::_narrow( DataFlowNode()->CoupledNode()->ObjRef() ) ;
214 if ( DataFlowEditor()->Graph()->CoupledNode() ) {
215 if ( CORBA::is_nil( DataFlowEditor()->Graph()->CoupledNode()->ObjRef() ) ) {
216 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
217 instanceName() , interfaceName() ,
219 (GraphEditor::InNode *) DataFlowEditor()->Graph()->CoupledNode()->GetInNode() ) ;
220 PortableServer::ObjectId * id = myNode->getId() ;
221 CORBA::Object_var obj = _poa->id_to_reference(*id);
222 iobject = SUPERV::INode::_narrow(obj) ;
223 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
226 iobject = SUPERV::INode::_narrow( DataFlowEditor()->Graph()->CoupledNode()->ObjRef() ) ;
230 // endService( "GNode_Impl::Coupled" );
231 return SUPERV::INode::_duplicate( iobject ) ;
234 bool GNode_Impl::SetCoupled( const char * anInLineNode )
236 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
237 if ( !CoupledINode ) {
239 // asv : 2.11.04 : nullify Coupled node if anInLineNode == "" (bug 7113)
240 if ( anInLineNode==NULL || !strlen( anInLineNode ) ) {
241 DataFlowNode()->CoupledNode( NULL );
246 if ( ( IsGOTO() && ( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() || CoupledINode->IsSwitchNode() ) ) ||
247 ( !IsGOTO() && ( IsLoop() || IsSwitch() || IsEndLoop() || IsEndSwitch() ) ) ) {
248 DataFlowNode()->CoupledNode( CoupledINode ) ;
249 if ( CoupledINode && IsSwitch() ) {
250 DataFlowEditor()->AddLink( Name() , "Default" ,CoupledINode->Name() , "Default" ) ;
252 else if ( CoupledINode && ( IsLoop() || IsEndLoop() ) ) {
253 DataFlowEditor()->AddLink( Name() , "DoLoop" , CoupledINode->Name() , "DoLoop" ) ;
255 else if ( CoupledINode && IsGOTO() ) {
256 DataFlowEditor()->AddLink( Name() , "OutGate" ,CoupledINode->Name() , "InGate" ) ;