1 //=============================================================================
2 // File : DataFlowBase_Graph.hxx
4 // Author : Jean Rahuel, CEA
7 //=============================================================================
9 #ifndef _DATAFLOWBASE_GRAPH_HXX
10 #define _DATAFLOWBASE_GRAPH_HXX
12 #include "DataFlowBase_FactoryNode.hxx"
13 #include "DataFlowBase_LoopNode.hxx"
14 #include "DataFlowBase_EndOfLoopNode.hxx"
15 #include "DataFlowBase_SwitchNode.hxx"
16 #include "DataFlowBase_EndOfSwitchNode.hxx"
17 #include "DataFlowBase_DataNode.hxx"
23 class Graph : public DataNode {
27 int _Graph_prof_debug;
28 ostream * _Graph_fdebug;
30 SUPERV::Graph_var _Graph ;
31 Graph_Impl * _GraphImpl ;
33 // Map of InNodes of the OutNode
34 map< string , int > _MapOfGraphNodes ;
35 long _GraphNodesSize ;
36 vector<bool > _Sorted ;
37 vector<ComputingNode *> _GraphNodes ;
39 // _SortedNodes[ _LevelsNumber ] : topological sort from 0 to _LevelsNumber
40 // _SortedNodes[ _level ][ _NodesNumber[ _level ] ] : _NodesNumber[ _level ] Nodes
44 vector<int > _NodesNumber ;
45 vector<vector<ComputingNode *> > _SortedNodes ;
47 vector<int > _CnxInPortsNumber ;
48 vector<int > _DecrInPortsNumber ;
51 vector<ComputingNode *> _HeadNodes ;
52 long _QueueNodesSize ;
53 vector<ComputingNode *> _QueueNodes ;
54 bool _ParallelExecutionNodes ;
56 bool AddLink( GraphBase::ComputingNode *fromNode ,
57 GraphBase::OutPort *fromPort ,
58 GraphBase::ComputingNode *toNode ,
59 GraphBase::InPort *toPort ) ;
64 Graph( CORBA::ORB_ptr ORB ,
65 SALOME_NamingService* ptrNamingService ,
66 const char *DataFlowName ,
67 const char * DebugFileName ) ;
68 Graph( CORBA::ORB_ptr ORB ,
69 SALOME_NamingService* ptrNamingService ,
70 const SALOME_ModuleCatalog::Service& DataFlowService ,
71 const char *DataFlowComponentName ,
72 const char *DataFlowInterfaceName ,
73 const char *DataFlowName ,
74 const SUPERV::KindOfNode DataFlowkind ,
75 const SUPERV::SDate DataFlowFirstCreation ,
76 const SUPERV::SDate DataFlowLastModification ,
77 const char * DataFlowEditorRelease ,
78 const char * DataFlowAuthor ,
79 const char * DataFlowComputer ,
80 const char * DataFlowComment ,
81 const char * DebugFileName ) ;
84 void Set_prof_debug( CORBA::ORB_ptr ORB ,
85 const char * DebugFileName ) ;
86 int * Graph_prof_debug() { return &_Graph_prof_debug ; } ;
87 ostream * Graph_fdebug() { return _Graph_fdebug ; } ;
89 SUPERV::Graph_var ObjRef() const { return _Graph ; } ;
90 void SetObjRef( SUPERV::Graph_var aGraph ) {
92 Graph_Impl * ObjImpl() const { return _GraphImpl ; } ;
93 void SetObjImpl( Graph_Impl * aGraphImpl ) {
94 _GraphImpl = aGraphImpl ; } ;
96 void AddLink( const char* FromNodeName , GraphBase::ComputingNode * anOutNode ) {
97 GetChangeGraphNode( FromNodeName )->AddLink( anOutNode ) ; } ;
99 const int GetGraphNodeIndex( const char *name ) {
100 const int index = _MapOfGraphNodes[ name ] - 1 ;
102 // cdebug << "GetGraphNodeIndex of " << name << " in _MapOfGraphNodes : "
103 // << index << " Node " << hex << (void *) _GraphNodes[ index ]
104 // << dec << " '" << _GraphNodes[ index ]->Name() << "'" << endl ;
106 void SetGraphNodeIndex( const char *name , const int index ) {
107 _MapOfGraphNodes[ name ] = index + 1 ;
108 cdebug << "SetGraphNodeIndex of " << name << " in _MapOfGraphNodes : "
109 << index << " Node " << hex << (void *) _GraphNodes[ index ]
110 << " '" << _GraphNodes[ index ]->Name() << "'" << endl ;
112 void DelGraphNodeIndex( const char *name ) {
113 _MapOfGraphNodes.erase( name ) ; } ;
114 const GraphBase::ComputingNode * GetGraphNode( const int index ) const {
115 const ComputingNode * aNode = GetChangeGraphNode( index ) ;
117 ComputingNode * GetChangeGraphNode( const int index ) const {
118 if ( index >= 0 && index < _GraphNodesSize ) {
119 ComputingNode * aNode = _GraphNodes[ index ] ;
124 const ComputingNode * GetGraphNode( const char *name ) {
125 const ComputingNode * aNode = GetChangeGraphNode( name ) ;
127 ComputingNode * GetChangeGraphNode( const char *name ) {
128 int index = GetGraphNodeIndex( name ) ;
129 if ( index >= 0 && index < _GraphNodesSize ) {
130 ComputingNode * aNode = GetChangeGraphNode( index ) ;
136 const int GraphNodesSize() const {
137 return _GraphNodesSize ; } ;
138 ComputingNode * GraphNodes( int i ) const {
139 return _GraphNodes[ i ] ; } ;
141 const int HeadNodesSize() const {
142 return _HeadNodesSize ; } ;
143 ComputingNode * HeadNodes( int i ) const {
144 return _HeadNodes[ i ] ; } ;
146 const int QueueNodesSize() const {
147 return _QueueNodesSize ; } ;
148 ComputingNode * QueueNodes( int i ) const {
149 return _QueueNodes[ i ] ; } ;
151 const GraphBase::InPort *GetInPort( const char* ToNodeName ,
152 const char* ToServiceParameterName ) {
153 ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ;
155 return aNode->GetInPort(ToServiceParameterName);
159 GraphBase::InPort *GetChangeInPort( const char* ToNodeName ,
160 const char* ToServiceParameterName ) {
161 ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ;
163 return aNode->GetChangeInPort(ToServiceParameterName);
167 GraphBase::OutPort *GetChangeOutPort(
168 const char* FromNodeName ,
169 const char* FromServiceParameterName ) {
170 ComputingNode * aNode = GetChangeGraphNode( FromNodeName ) ;
172 return aNode->GetChangeOutPort( FromServiceParameterName );
177 SUPERV::GraphState PortState( const char* NodeName ,
178 const char* ServiceParameterName ) ;
179 bool PortDone( const char* NodeName ,
180 const char* ServiceParameterName ) {
182 SUPERV::GraphState aState = PortState( NodeName ,
183 ServiceParameterName ) ;
184 if ( aState == SUPERV::DoneState )
187 const CORBA::Any * PortInData( const char* ToNodeName ,
188 const char* ToServiceParameterName ) ;
189 const CORBA::Any * PortOutData( const char* FromNodeName ,
190 const char* FromServiceParameterName ) ;
192 bool LoadXml( CORBA::ORB_ptr Orb , const char* anXmlFile ,
193 GraphBase::SGraph & aDataFlow ) ;
195 GraphBase::SNode * GetInfo() const ;
196 GraphBase::ListOfNodes * GetNodes() const ;
197 GraphBase::ListOfLinks * GetLinks() const ;
198 GraphBase::ListOfGraphs * GetGraphs() const ;
199 GraphBase::ListOfLinks * GetDatas() const ;
200 // SALOME_ModuleCatalog::Service * GetService() const ;
202 bool AddNode( ComputingNode * aNode ) ;
203 bool RemoveNode( const char* NodeName ) ;
204 bool ReNameNode( const char* OldNodeName ,
205 const char* NewNodeName ) ;
207 bool AddLink( const char* FromNodeName ,
208 const char* FromServiceParameterName ,
209 const char* ToNodeName ,
210 const char* ToServiceParameterName ,
211 const CORBA::Any aValue ) ;
212 bool RemoveLink( const char* FromNodeName ,
213 const char* FromServiceParameterName ,
214 const char* ToNodeName ,
215 const char* ToServiceParameterName ) ;
216 bool GetLink( const char* ToNodeName ,
217 const char* ToServiceParameterName ,
218 char** FromNodeName ,
219 char** FromServiceParameterName ) ;
220 GraphBase::SLink * GetLink( GraphBase::ComputingNode * aNode ,
221 GraphBase::InPort* toPort ) ;
223 bool AddInputData( const char* ToNodeName ,
224 const char* ToParameterName ,
225 const CORBA::Any aValue ) ;
226 bool ChangeInputData( const char* ToNodeName ,
227 const char* ToParameterName ,
228 const CORBA::Any aValue ) ;
229 bool AddInputData( const char* ToNodeName1 ,
230 const char* ToParameterName1 ,
231 const char* ToNodeName2 ,
232 const char* ToParameterName2 ) ;
234 bool AddInputData( const char* ToNodeName ,
235 const char* ToParameterName ,
236 const CORBA::Any ** aValue ) ;
238 bool AddOutputData( const char* FromNodeName ,
239 const char* FromParameterName ,
240 const CORBA::Any aValue ) ;
242 bool CreateService() ;
243 bool InLineServices() ;
246 bool ComputingNodes() const ;
247 bool DataServerNodes() const ;
250 return _LevelsNumber + 1 ; } ;
251 SUPERV::ListOfStrings * LevelNodes(long aLevel ) ;
253 return _ThreadsMax ; } ;
254 long GraphsNumber() {
255 return _GraphsNumber ; } ;
257 int NodesNumber(const int aLevel ) {
258 return _NodesNumber[ aLevel ] ; } ;
259 GraphBase::ComputingNode * SortedNodes( const int aLevel , const int index ) {
260 return (_SortedNodes[ aLevel ])[ index ] ; } ;
262 bool StartComponent( const int aThread ,
263 const char * ComputerContainer ,
264 const char * ComponentName ,
265 Engines::Container_var & myContainer ,
266 Engines::Component_var & objComponent ) ;