Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / Supervision / FNode_Impl.cxx
1 //  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
2 //
3 //  Copyright (C) 2003  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 //  File   : FNode_Impl.cxx
23 //  Author : Jean Rahuel
24 //  Module : SUPERV
25
26 using namespace std;
27 #include <stdio.h>
28 #include <fstream>
29 //#include <sstream>
30 #include <string>
31
32 //#include "utilities.h"
33
34 #include "FNode_Impl.hxx"
35
36 FNode_Impl::FNode_Impl() {
37 }
38
39 FNode_Impl::FNode_Impl( CORBA::ORB_ptr orb ,
40                         PortableServer::POA_ptr poa ,
41                         PortableServer::ObjectId * contId , 
42                         const char * instanceName ,
43                         const char * interfaceName ,
44                         GraphEditor::DataFlow * aDataFlowEditor ,
45                         const SALOME_ModuleCatalog::Service &NodeService ,
46                         const char * NodeComponentName ,
47                         const char * NodeInterfaceName ,
48                         const char * NodeName ,
49                         const SUPERV::KindOfNode NodeKindOfNode ,
50                         bool isCimpl ) :
51 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
52   CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , NodeService , NodeName , NodeKindOfNode , NULLSTRING , SUPERV::ListOfStrings() , isCimpl ) {
53 //  MESSAGE( NodeName << " " );
54   beginService( "FNode_Impl::FNode_Impl" );
55 //  cout << "FNode_Impl::FNode_Impl -->" << endl ;
56   _thisObj = this ;
57   _id = _poa->activate_object(_thisObj);
58   _Orb = CORBA::ORB::_duplicate(orb);
59   _Poa = poa ;
60   _ContId = contId ;
61   _isCimpl = isCimpl ;
62 //  DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
63 //                                           NodeInterfaceName , NodeName ,
64 //                                           NodeKindOfNode ) ) ;
65   DataFlowNode()->ComponentName( NodeComponentName ) ;
66   DataFlowNode()->InterfaceName( NodeInterfaceName ) ;
67
68   // mkr : PAL13947 -->
69   const char * aContainer = DataFlowEditor()->Graph()->RetrieveFromMapOfComponentNameContainer(NodeComponentName);
70   if ( aContainer ) // container for NodeComponentName component was found in the map
71     SetContainer( aContainer );
72   // mkr : PAL13947 <--
73
74   endService( "FNode_Impl::FNode_Impl" );  
75 //  cout << "<-- FNode_Impl::FNode_Impl" << endl ;
76 }
77
78 FNode_Impl::FNode_Impl( CORBA::ORB_ptr orb ,
79                         PortableServer::POA_ptr poa ,
80                         PortableServer::ObjectId * contId , 
81                         const char * instanceName ,
82                         const char * interfaceName ,
83                         GraphEditor::DataFlow * aDataFlowEditor ,
84                         GraphEditor::InNode * aDataFlowNode ) :
85 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
86   CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
87   MESSAGE( DataFlowNode()->Name() << " " );
88   beginService( "FNode_Impl::FNode_Impl" );
89   _thisObj = this ;
90   _id = _poa->activate_object(_thisObj);
91   _Orb = CORBA::ORB::_duplicate(orb);
92   _Poa = poa ;
93   _ContId = contId ;
94   _isCimpl = true ;
95   endService( "FNode_Impl::FNode_Impl" );  
96 }
97
98 FNode_Impl::~FNode_Impl() {
99   beginService( "FNode_Impl::~Node_Impl" );
100   endService( "FNode_Impl::~Node_Impl" );
101 }
102
103 void FNode_Impl::destroy() {
104   beginService( "FNode_Impl::Destroy" );
105   if ( DataFlowEditor()->IsEditing() ) {
106     if ( Delete() ) {
107       _poa->deactivate_object(*_id) ;
108 //      CORBA::release(_poa) ;
109       delete(_id) ;
110 //      _thisObj->_remove_ref();
111     }
112     else {
113       MESSAGE("FNode_Impl::destroy ERROR ") ;
114     }
115   }
116 //  endService( "FNode_Impl::Destroy" );
117 }
118
119 bool FNode_Impl::Delete() {
120 //  beginService( "FNode_Impl::Delete" );
121   bool RetVal = false ;
122   if ( DataFlowEditor()->IsEditing() ) {
123     DeletePorts() ;
124     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
125     if ( RetVal ) {
126       DataFlowEditor()->UnValid() ;
127     }
128   }
129 //  endService( "FNode_Impl::Delete" );
130   return RetVal ;
131 }
132
133 char * FNode_Impl::GetComponentName() {
134 //  beginService( "FNode_Impl::GetComponentName" );
135   char * RetVal = DataFlowNode()->ComponentName() ;
136 //  endService( "FNode_Impl::GetComponentName" );
137   return CORBA::string_dup( RetVal );
138 }
139 bool FNode_Impl::SetComponentName( const char * aComponentName ) {
140 //  beginService( "FNode_Impl::SetComponentName" );
141   bool RetVal = false ;
142   RetVal = DataFlowNode()->ComponentName( aComponentName ) ;
143 //  endService( "FNode_Impl::SetComponentName" );
144   return RetVal ;
145 }
146 char * FNode_Impl::GetInterfaceName() {
147 //  beginService( "FNode_Impl::GetInterfaceName" );
148   char * RetVal = DataFlowNode()->InterfaceName() ;
149 //  endService( "FNode_Impl::GetInterfaceName" );
150   return CORBA::string_dup( RetVal );
151 }
152 bool FNode_Impl::SetInterfaceName( const char * anInterfaceName ) {
153 //  beginService( "FNode_Impl::SetInterfaceName" );
154   bool RetVal = false ;
155     RetVal = DataFlowNode()->InterfaceName( anInterfaceName ) ;
156 //  endService( "FNode_Impl::SetInterfaceName" );
157   return RetVal ;
158 }
159 char * FNode_Impl::GetContainer() {
160 //  beginService( "FNode_Impl::GetContainer" );
161   char * RetVal = DataFlowNode()->Computer() ;
162 //  endService( "FNode_Impl::GetContainer" );
163   return CORBA::string_dup( RetVal ) ;
164 }
165 bool FNode_Impl::SetContainer( const char * aDataFlowContainer ) {
166 //  beginService( "FNode_Impl::SetContainer" );
167   bool RetVal = false ;
168 //  GraphExecutor::DataFlow * _DataFlowExecutor = DataFlowEditor()->Executor() ;
169 //  if ( DataFlowEditor()->IsEditing() ) {
170     RetVal = DataFlowNode()->Computer( aDataFlowContainer ) ;
171
172     // insert modified container into < ComponentName, Container > map
173     DataFlowEditor()->Graph()->InsertToMapOfComponentNameContainer( GetComponentName(), aDataFlowContainer ) ; // mkr : PAL13947
174
175 //  }
176 //  else if ( _DataFlowExecutor && ( _DataFlowExecutor->IsSuspended() ||
177 //            _DataFlowExecutor->IsSuspended( DataFlowNode()->Name() ) ) ) {
178 //    if ( _DataFlowExecutor->Graph()->GetChangeGraphNode( DataFlowNode()->Name() ) ) {
179 //      RetVal = ((GraphEditor::InNode * ) _DataFlowExecutor->Graph()->GetChangeGraphNode( DataFlowNode()->Name() )->GetInNode())->Computer( aDataFlowContainer ) ;
180       DataFlowEditor()->UnValid() ;
181 //    }
182 //  }
183 //  endService( "FNode_Impl::SetContainer" );
184   return RetVal ;
185 }
186