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