1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : GNode_Impl.cxx
8 // Author : Jean Rahuel
18 //#include "utilities.h"
20 #include "GNode_Impl.hxx"
22 GNode_Impl::GNode_Impl() {
25 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
26 PortableServer::POA_ptr poa ,
27 PortableServer::ObjectId * contId ,
28 const char *instanceName ,
29 const char *interfaceName ,
30 const char *aDataFlowName ,
31 const SUPERV::KindOfNode aKindOfNode ) :
32 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
33 // MESSAGE("GNode_Impl::GNode_Impl activate object instanceName("
34 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
35 // << hex << (void *) this << dec )
37 // _id = _poa->activate_object(_thisObj);
38 // MESSAGE( "GNode_Impl::GNode_Impl " << aDataFlowName );
39 // beginService( "GNode_Impl::GNode_Impl" );
40 _Orb = CORBA::ORB::_duplicate(orb);
43 // endService( "INode_Impl::INode_Impl" );
46 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
47 PortableServer::POA_ptr poa ,
48 PortableServer::ObjectId * contId ,
49 const char *instanceName ,
50 const char *interfaceName ,
51 GraphEditor::DataFlow * aDataFlowEditor ,
52 const char * FuncName ,
53 const SUPERV::ListOfStrings & PythonFunction ,
54 const SUPERV::KindOfNode NodeKindOfNode ) :
55 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
56 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , PythonFunction , NodeKindOfNode ) {
57 // MESSAGE( NodeName << " " );
58 // beginService( "GNode_Impl::GNode_Impl" );
60 // cout << "GNode_Impl::GNode_Impl " << (void *) FuncName << " " << FuncName
61 // << " " << strlen( FuncName ) << endl ;
63 if ( NodeKindOfNode == SUPERV::GOTONode ) {
65 _id = _poa->activate_object(_thisObj);
67 _Orb = CORBA::ORB::_duplicate(orb);
70 // DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
71 // NodeInterfaceName , NodeName ,
72 // NodeKindOfNode ) );
73 // DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
75 // NodeKindOfNode ) ) ;
76 // endService( "GNode_Impl::GNode_Impl" );
79 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
80 PortableServer::POA_ptr poa ,
81 PortableServer::ObjectId * contId ,
82 const char *instanceName ,
83 const char *interfaceName ,
84 GraphEditor::DataFlow * aDataFlowEditor ,
85 GraphBase::ListOfFuncName FuncNameList ,
86 GraphBase::ListOfPythonFunctions PythonFunctionList ,
87 const SUPERV::KindOfNode NodeKindOfNode ) :
88 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
89 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncNameList , PythonFunctionList , NodeKindOfNode ) {
90 // MESSAGE( NodeName << " " );
91 // beginService( "GNode_Impl::GNode_Impl" );
92 if ( NodeKindOfNode == SUPERV::GOTONode ) {
94 _id = _poa->activate_object(_thisObj);
96 _Orb = CORBA::ORB::_duplicate(orb);
99 // DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
100 // NodeInterfaceName , NodeName ,
101 // NodeKindOfNode ) );
102 // DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
104 // NodeKindOfNode ) ) ;
105 // endService( "GNode_Impl::GNode_Impl" );
108 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
109 PortableServer::POA_ptr poa ,
110 PortableServer::ObjectId * contId ,
111 const char *instanceName ,
112 const char *interfaceName ,
113 GraphEditor::DataFlow * aDataFlowEditor ,
114 GraphEditor::InNode * aDataFlowNode ) :
115 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
116 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
117 // beginService( "GNode_Impl::GNode_Impl" );
118 if ( DataFlowNode() && DataFlowNode()->IsGOTONode() ) {
119 // MESSAGE( "GNode_Impl::GNode_Impl " << DataFlowNode()->PyFuncName()
120 // << " _poa->activate_object" );
122 _id = _poa->activate_object(_thisObj);
125 // MESSAGE( "GNode_Impl::GNode_Impl NO _poa->activate_object" );
127 _Orb = CORBA::ORB::_duplicate(orb);
130 // endService( "GNode_Impl::GNode_Impl" );
133 GNode_Impl::~GNode_Impl() {
134 beginService( "GNode_Impl::~GNode_Impl" );
135 endService( "GNode_Impl::~GNode_Impl" );
138 void GNode_Impl::destroy() {
139 beginService( "GNode_Impl::Destroy" );
140 if ( DataFlowEditor()->IsEditing() ) {
142 _poa->deactivate_object(*_id) ;
143 CORBA::release(_poa) ;
145 _thisObj->_remove_ref();
148 // endService( "GNode_Impl::Destroy" );
151 bool GNode_Impl::Delete() {
152 beginService( "GNode_Impl::Delete" );
153 bool RetVal = false ;
154 if ( DataFlowEditor()->IsEditing() ) {
155 if ( DataFlowNode() ) {
156 GraphBase::GOTONode * aGOTONode = DataFlowNode()->GOTONode() ;
158 GraphBase::GOTONode * aCoupledNode = (GraphBase::GOTONode * ) aGOTONode->CoupledNode() ;
159 if ( aCoupledNode && ( aCoupledNode->IsOneOfGOTONodes() || aCoupledNode->IsDataFlowNode() ||
160 aCoupledNode->IsDataStreamNode() ) ) {
161 aCoupledNode->CoupledNode( NULL ) ;
162 aCoupledNode->MacroObject( SUPERV::Graph::_nil() ) ;
163 aCoupledNode->GraphMacroLevel( 0 ) ;
168 RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
170 RetVal = DataFlowEditor()->IsValid() ;
172 endService( "GNode_Impl::Delete" );
176 SUPERV::INode_ptr GNode_Impl::Coupled() {
177 // beginService( "GNode_Impl::Coupled" );
178 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
179 if ( DataFlowNode() ) {
180 if ( DataFlowNode()->CoupledNode() ) {
181 if ( CORBA::is_nil( DataFlowNode()->CoupledNode()->ObjRef() ) ) {
182 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
183 instanceName() , interfaceName() ,
185 (GraphEditor::InNode *) DataFlowNode()->CoupledNode()->GetInNode() ) ;
186 PortableServer::ObjectId * id = myNode->getId() ;
187 CORBA::Object_var obj = _poa->id_to_reference(*id);
188 iobject = SUPERV::INode::_narrow(obj) ;
189 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
192 iobject = SUPERV::INode::_narrow( DataFlowNode()->CoupledNode()->ObjRef() ) ;
197 if ( DataFlowEditor()->Graph()->CoupledNode() ) {
198 if ( CORBA::is_nil( DataFlowEditor()->Graph()->CoupledNode()->ObjRef() ) ) {
199 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
200 instanceName() , interfaceName() ,
202 (GraphEditor::InNode *) DataFlowEditor()->Graph()->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( DataFlowEditor()->Graph()->CoupledNode()->ObjRef() ) ;
213 // endService( "GNode_Impl::Coupled" );
214 return SUPERV::INode::_duplicate( iobject ) ;
217 bool GNode_Impl::SetCoupled( const char * anInLineNode )
219 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
220 if ( !CoupledINode ) {
222 // asv : 2.11.04 : nullify Coupled node if anInLineNode == "" (bug 7113)
223 if ( anInLineNode==NULL || !strlen( anInLineNode ) ) {
224 DataFlowNode()->CoupledNode( NULL );
229 if ( ( IsGOTO() && ( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() || CoupledINode->IsSwitchNode() ) ) ||
230 ( !IsGOTO() && ( IsLoop() || IsSwitch() || IsEndLoop() || IsEndSwitch() ) ) ) {
231 DataFlowNode()->CoupledNode( CoupledINode ) ;
232 if ( CoupledINode && IsSwitch() ) {
233 DataFlowEditor()->AddLink( Name() , "Default" ,CoupledINode->Name() , "Default" ) ;
235 else if ( CoupledINode && ( IsLoop() || IsEndLoop() ) ) {
236 DataFlowEditor()->AddLink( Name() , "DoLoop" , CoupledINode->Name() , "DoLoop" ) ;
238 else if ( CoupledINode && IsGOTO() ) {
239 DataFlowEditor()->AddLink( Name() , "OutGate" ,CoupledINode->Name() , "InGate" ) ;