Salome HOME
Crash in the destructor with omniORB4
[modules/superv.git] / src / Supervision / SNode_Impl.cxx
1 //  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SNode_Impl.cxx
8 //  Author : Jean Rahuel
9 //  Module : SUPERV
10 //  $Header: 
11
12 using namespace std;
13 #include <stdio.h>
14 #include <fstream>
15 //#include <sstream>
16 #include <string>
17
18 //#include "utilities.h"
19
20 #include "SNode_Impl.hxx"
21
22 SNode_Impl::SNode_Impl() {
23 }
24
25 SNode_Impl::SNode_Impl( CORBA::ORB_ptr orb ,
26                         PortableServer::POA_ptr poa ,
27                         PortableServer::ObjectId * contId , 
28                         const char *instanceName ,
29                         const char *interfaceName ,
30                         GraphEditor::DataFlow * aDataFlowEditor ,
31                         const char * FuncName , 
32                         const SUPERV::ListOfStrings & PythonFunction ,
33                         const SUPERV::KindOfNode NodeKindOfNode ) :
34 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
35   GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , PythonFunction , NodeKindOfNode ) {
36 //  MESSAGE( NodeName << " " );
37   beginService( "SNode_Impl::SNode_Impl" );
38   _thisObj = this ;
39   _id = _poa->activate_object(_thisObj);
40   _Orb = CORBA::ORB::_duplicate(orb);
41   _Poa = poa ;
42   _ContId = contId ;
43 //  DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
44 //                                           NodeInterfaceName , NodeName ,
45 //                                           NodeKindOfNode ) ) ;
46 //  DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
47 //                                           "" , "" , "" ,
48 //                                           NodeKindOfNode ) ) ;
49   endService( "SNode_Impl::SNode_Impl" );  
50 }
51
52 SNode_Impl::SNode_Impl( CORBA::ORB_ptr orb ,
53                       PortableServer::POA_ptr poa ,
54                       PortableServer::ObjectId * contId , 
55                       const char *instanceName ,
56                       const char *interfaceName ,
57                       GraphEditor::DataFlow * aDataFlowEditor ,
58                       GraphEditor::InNode * aDataFlowNode ) :
59 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
60   GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
61   MESSAGE( DataFlowNode()->Name() << " " );
62   beginService( "SNode_Impl::SNode_Impl" );
63   _thisObj = this ;
64   _id = _poa->activate_object(_thisObj);
65   _Orb = CORBA::ORB::_duplicate(orb);
66   _Poa = poa ;
67   _ContId = contId ;
68   endService( "SNode_Impl::SNode_Impl" );  
69 }
70
71 SNode_Impl::~SNode_Impl() {
72   beginService( "SNode_Impl::~SNode_Impl" );
73   endService( "SNode_Impl::~SNode_Impl" );
74 }
75
76 void SNode_Impl::destroy() {
77   beginService( "SNode_Impl::Destroy" );
78   if ( DataFlowEditor()->IsEditing() ) {
79     SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
80     if ( Delete() ) {
81       _poa->deactivate_object(*_id) ;
82 //      CORBA::release(_poa) ;
83       delete(_id) ;
84 //      _thisObj->_remove_ref();
85     }
86     else {
87       MESSAGE("SNode_Impl::destroy ERROR ") ;
88     }
89     if ( !CORBA::is_nil( aCoupled ) ) {
90 //      aCoupled->SetCoupled( "" ) ; : Used in GraphBase::Graph::RemoveNode( EndSwitchNode ) :
91       aCoupled->destroy() ;
92     }
93 // Valid() only after deletion of the corresponding EndSwitchNode :
94     DataFlowEditor()->UnValid() ;
95   }
96   endService( "SNode_Impl::Destroy" );
97 }
98
99 bool SNode_Impl::Delete() {
100   beginService( "SNode_Impl::Delete" );
101   bool RetVal = false ;
102   if ( DataFlowEditor()->IsEditing() ) {
103     DeletePorts() ;
104     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
105 // Valid() only after deletion of the corresponding EndLoopNode :
106 //    if ( RetVal ) {
107 //      RetVal = DataFlowEditor()->IsValid() ;
108 //    }
109   }
110   endService( "SNode_Impl::Delete" );
111   return RetVal ;
112 }
113