Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/superv.git] / src / Supervision / GNode_Impl.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : GNode_Impl.cxx
4 // Created   : 2003
5 // Author    : Jean Rahuel
6 // Project   : SALOME
7 // $Header: 
8 //=============================================================================
9
10 #include <stdio.h>
11 #include <fstream>
12 #include <strstream>
13 #include <string>
14
15 #include "utilities.h"
16
17 #include "GNode_Impl.hxx"
18
19 GNode_Impl::GNode_Impl() {
20 }
21
22 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
23                         PortableServer::POA_ptr poa ,
24                         PortableServer::ObjectId * contId , 
25                         const char *instanceName ,
26                         const char *interfaceName ,
27                         GraphEditor::DataFlow * aDataFlowEditor ,
28                         const char * FuncName ,
29                         const SUPERV::ListOfStrings & PythonFunction ,
30                         const SUPERV::KindOfNode NodeKindOfNode ) :
31 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
32   INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncName , PythonFunction , NodeKindOfNode ) {
33 //  MESSAGE( NodeName << " " );
34   beginService( "GNode_Impl::GNode_Impl" );
35   if ( FuncName ) {
36     cout << "GNode_Impl::GNode_Impl " << (void *) FuncName << " " << FuncName
37          << " " << strlen( FuncName ) << endl ;
38   }
39   if ( NodeKindOfNode == SUPERV::GOTONode ) {
40     _thisObj = this ;
41     _id = _poa->activate_object(_thisObj);
42   }
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( "GNode_Impl::GNode_Impl" );  
53 }
54
55 GNode_Impl::GNode_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                         GraphBase::ListOfFuncName FuncNameList ,
62                         GraphBase::ListOfPythonFunctions PythonFunctionList ,
63                         const SUPERV::KindOfNode NodeKindOfNode ) :
64 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
65   INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncNameList , PythonFunctionList , NodeKindOfNode ) {
66 //  MESSAGE( NodeName << " " );
67   beginService( "GNode_Impl::GNode_Impl" );
68   if ( NodeKindOfNode == SUPERV::GOTONode ) {
69     _thisObj = this ;
70     _id = _poa->activate_object(_thisObj);
71   }
72   _Orb = CORBA::ORB::_duplicate(orb);
73   _Poa = poa ;
74   _ContId = contId ;
75 //  DataFlowNode( DataFlowEditor()->AddNode( NodeService , NodeComponentName ,
76 //                                           NodeInterfaceName , NodeName ,
77 //                                           NodeKindOfNode ) );
78 //  DataFlowNode( DataFlowEditor()->AddNode( SALOME_ModuleCatalog::Service() ,
79 //                                           "" , "" , "" ,
80 //                                           NodeKindOfNode ) ) ;
81   endService( "GNode_Impl::GNode_Impl" );  
82 }
83
84 GNode_Impl::GNode_Impl( CORBA::ORB_ptr orb ,
85                       PortableServer::POA_ptr poa ,
86                       PortableServer::ObjectId * contId , 
87                       const char *instanceName ,
88                       const char *interfaceName ,
89                       GraphEditor::DataFlow * aDataFlowEditor ,
90                       GraphEditor::InNode * aDataFlowNode ) :
91 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
92   INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
93   MESSAGE( DataFlowNode()->Name() << " " );
94   beginService( "GNode_Impl::GNode_Impl" );
95   if ( DataFlowNode()->IsGOTONode() ) {
96     _thisObj = this ;
97     _id = _poa->activate_object(_thisObj);
98   }
99   _Orb = CORBA::ORB::_duplicate(orb);
100   _Poa = poa ;
101   _ContId = contId ;
102   endService( "GNode_Impl::GNode_Impl" );  
103 }
104
105 GNode_Impl::~GNode_Impl() {
106   beginService( "GNode_Impl::~GNode_Impl" );
107   endService( "GNode_Impl::~GNode_Impl" );
108 }
109
110 void GNode_Impl::destroy() {
111   beginService( "GNode_Impl::Destroy" );
112   if ( DataFlowEditor()->IsEditing() ) {
113     if ( Delete() ) {
114       _poa->deactivate_object(*_id) ;
115       CORBA::release(_poa) ;
116       delete(_id) ;
117       _thisObj->_remove_ref();
118     }
119   }
120   endService( "GNode_Impl::Destroy" );
121 }
122
123 bool GNode_Impl::Delete() {
124 //  beginService( "GNode_Impl::Delete" );
125   bool RetVal = false ;
126   if ( DataFlowEditor()->IsEditing() ) {
127     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
128     if ( RetVal )
129       RetVal = DataFlowEditor()->IsValid() ;
130   }
131 //  endService( "GNode_Impl::Delete" );
132   return RetVal ;
133 }
134
135 SUPERV::INode_ptr GNode_Impl::Coupled() {
136   beginService( "GNode_Impl::Coupled" );
137   SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
138   if ( DataFlowNode()->CoupledNode() ) {
139     if ( CORBA::is_nil( DataFlowNode()->CoupledNode()->ObjRef() ) ) {
140       INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
141                                             instanceName() , interfaceName() ,
142                                             DataFlowEditor() ,
143                                             (GraphEditor::InNode *) DataFlowNode()->CoupledNode()->GetInNode() ) ;
144       PortableServer::ObjectId * id = myNode->getId() ;
145       CORBA::Object_var obj = _poa->id_to_reference(*id);
146       iobject = SUPERV::INode::_narrow(obj) ;
147       myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
148     }
149     else {
150       iobject = SUPERV::INode::_narrow( DataFlowNode()->CoupledNode()->ObjRef() ) ;
151     }
152   }
153   endService( "GNode_Impl::Coupled" );
154   return SUPERV::INode::_duplicate( iobject ) ;
155 }
156