Salome HOME
ee2230f26487dea03b911441d9b07ce3f465c810
[modules/superv.git] / src / Supervision / ESNode_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   : ESNode_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 "ESNode_Impl.hxx"
21
22 ESNode_Impl::ESNode_Impl() {
23 }
24
25 ESNode_Impl::ESNode_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::KindOfNode NodeKindOfNode ) :
33 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
34   GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , SUPERV::ListOfStrings() , NodeKindOfNode ) {
35 //  MESSAGE( NodeName << " " );
36   beginService( "ESNode_Impl::ESNode_Impl" );
37 //  if ( FuncName ) {
38 //    cout << "ESNode_Impl::GNode_Impl " << (void *) FuncName << " " << FuncName
39 //         << " " << strlen( FuncName ) << endl ;
40 //  }
41   _thisObj = this ;
42   _id = _poa->activate_object(_thisObj);
43   _Orb = CORBA::ORB::_duplicate(orb);
44   _Poa = poa ;
45   _ContId = contId ;
46 //  DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
47 //                                           NodeInterfaceName , NodeName ,
48 //                                           NodeKindOfNode ) ) ;
49 //  DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
50 //                                           "" , "" , "" ,
51 //                                           NodeKindOfNode ) ) ;
52   endService( "ESNode_Impl::ESNode_Impl" );  
53 }
54
55 ESNode_Impl::ESNode_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 * aDataFlowEditor ,
61                       GraphEditor::InNode * aDataFlowNode ) :
62 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
63   GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
64   MESSAGE( DataFlowNode()->Name() << " " );
65   beginService( "ESNode_Impl::ESNode_Impl" );
66   _thisObj = this ;
67   _id = _poa->activate_object(_thisObj);
68   _Orb = CORBA::ORB::_duplicate(orb);
69   _Poa = poa ;
70   _ContId = contId ;
71   endService( "ESNode_Impl::ESNode_Impl" );  
72 }
73
74 ESNode_Impl::~ESNode_Impl() {
75   beginService( "ESNode_Impl::~ESNode_Impl" );
76   endService( "ESNode_Impl::~ESNode_Impl" );
77 }
78
79 void ESNode_Impl::destroy() {
80   beginService( "ESNode_Impl::Destroy" );
81   if ( DataFlowEditor()->IsEditing() ) {
82     SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
83     if ( Delete() ) {
84       _poa->deactivate_object(*_id) ;
85       CORBA::release(_poa) ;
86       delete(_id) ;
87       _thisObj->_remove_ref();
88     }
89     if ( !CORBA::is_nil( aCoupled ) ) {
90       aCoupled->SetCoupled( "" ) ;
91       aCoupled->destroy() ;
92     }
93   }
94   endService( "ESNode_Impl::Destroy" );
95 }
96
97 bool ESNode_Impl::Delete() {
98 //  beginService( "ESNode_Impl::Delete" );
99   bool RetVal = false ;
100   if ( DataFlowEditor()->IsEditing() ) {
101     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
102     if ( RetVal )
103       RetVal = DataFlowEditor()->IsValid() ;
104   }
105 //  endService( "ESNode_Impl::Delete" );
106   return RetVal ;
107 }
108