Salome HOME
a7a801aa13fdbc785b13f3494d3e825bc43a0f7f
[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   endService( "FNode_Impl::FNode_Impl" );  
68 //  cout << "<-- FNode_Impl::FNode_Impl" << endl ;
69 }
70
71 FNode_Impl::FNode_Impl( CORBA::ORB_ptr orb ,
72                         PortableServer::POA_ptr poa ,
73                         PortableServer::ObjectId * contId , 
74                         const char * instanceName ,
75                         const char * interfaceName ,
76                         GraphEditor::DataFlow * aDataFlowEditor ,
77                         GraphEditor::InNode * aDataFlowNode ) :
78 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
79   CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
80   MESSAGE( DataFlowNode()->Name() << " " );
81   beginService( "FNode_Impl::FNode_Impl" );
82   _thisObj = this ;
83   _id = _poa->activate_object(_thisObj);
84   _Orb = CORBA::ORB::_duplicate(orb);
85   _Poa = poa ;
86   _ContId = contId ;
87   _isCimpl = true ;
88   endService( "FNode_Impl::FNode_Impl" );  
89 }
90
91 FNode_Impl::~FNode_Impl() {
92   beginService( "FNode_Impl::~Node_Impl" );
93   endService( "FNode_Impl::~Node_Impl" );
94 }
95
96 void FNode_Impl::destroy() {
97   beginService( "FNode_Impl::Destroy" );
98   if ( DataFlowEditor()->IsEditing() ) {
99     if ( Delete() ) {
100       _poa->deactivate_object(*_id) ;
101 //      CORBA::release(_poa) ;
102       delete(_id) ;
103 //      _thisObj->_remove_ref();
104     }
105     else {
106       MESSAGE("FNode_Impl::destroy ERROR ") ;
107     }
108   }
109 //  endService( "FNode_Impl::Destroy" );
110 }
111
112 bool FNode_Impl::Delete() {
113 //  beginService( "FNode_Impl::Delete" );
114   bool RetVal = false ;
115   if ( DataFlowEditor()->IsEditing() ) {
116     DeletePorts() ;
117     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
118     if ( RetVal ) {
119       DataFlowEditor()->UnValid() ;
120     }
121   }
122 //  endService( "FNode_Impl::Delete" );
123   return RetVal ;
124 }
125
126 char * FNode_Impl::GetComponentName() {
127 //  beginService( "FNode_Impl::GetComponentName" );
128   char * RetVal = DataFlowNode()->ComponentName() ;
129 //  endService( "FNode_Impl::GetComponentName" );
130   return CORBA::string_dup( RetVal );
131 }
132 bool FNode_Impl::SetComponentName( const char * aComponentName ) {
133 //  beginService( "FNode_Impl::SetComponentName" );
134   bool RetVal = false ;
135   RetVal = DataFlowNode()->ComponentName( aComponentName ) ;
136 //  endService( "FNode_Impl::SetComponentName" );
137   return RetVal ;
138 }
139 char * FNode_Impl::GetInterfaceName() {
140 //  beginService( "FNode_Impl::GetInterfaceName" );
141   char * RetVal = DataFlowNode()->InterfaceName() ;
142 //  endService( "FNode_Impl::GetInterfaceName" );
143   return CORBA::string_dup( RetVal );
144 }
145 bool FNode_Impl::SetInterfaceName( const char * anInterfaceName ) {
146 //  beginService( "FNode_Impl::SetInterfaceName" );
147   bool RetVal = false ;
148     RetVal = DataFlowNode()->InterfaceName( anInterfaceName ) ;
149 //  endService( "FNode_Impl::SetInterfaceName" );
150   return RetVal ;
151 }
152 char * FNode_Impl::GetContainer() {
153 //  beginService( "FNode_Impl::GetContainer" );
154   char * RetVal = DataFlowNode()->Computer() ;
155 //  endService( "FNode_Impl::GetContainer" );
156   return CORBA::string_dup( RetVal ) ;
157 }
158 bool FNode_Impl::SetContainer( const char * aDataFlowContainer ) {
159 //  beginService( "FNode_Impl::SetContainer" );
160   bool RetVal = false ;
161 //  GraphExecutor::DataFlow * _DataFlowExecutor = DataFlowEditor()->Executor() ;
162 //  if ( DataFlowEditor()->IsEditing() ) {
163     RetVal = DataFlowNode()->Computer( aDataFlowContainer ) ;
164 //  }
165 //  else if ( _DataFlowExecutor && ( _DataFlowExecutor->IsSuspended() ||
166 //            _DataFlowExecutor->IsSuspended( DataFlowNode()->Name() ) ) ) {
167 //    if ( _DataFlowExecutor->Graph()->GetChangeGraphNode( DataFlowNode()->Name() ) ) {
168 //      RetVal = ((GraphEditor::InNode * ) _DataFlowExecutor->Graph()->GetChangeGraphNode( DataFlowNode()->Name() )->GetInNode())->Computer( aDataFlowContainer ) ;
169       DataFlowEditor()->UnValid() ;
170 //    }
171 //  }
172 //  endService( "FNode_Impl::SetContainer" );
173   return RetVal ;
174 }
175