]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_Graph.hxx
Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/superv.git] / src / GraphBase / DataFlowBase_Graph.hxx
1 //=============================================================================
2 // File      : DataFlowBase_Graph.hxx
3 // Created   : 2002
4 // Author    : Jean Rahuel, CEA
5 // Project   : SALOME
6 // $Header:
7 //=============================================================================
8
9 #ifndef _DATAFLOWBASE_GRAPH_HXX
10 #define _DATAFLOWBASE_GRAPH_HXX
11
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"
18
19 class Graph_Impl ;
20
21 namespace GraphBase {
22
23   class Graph : public DataNode {
24
25     private:
26
27       int                 _Graph_prof_debug;
28       ostream           * _Graph_fdebug;
29       CORBA::ORB_ptr      _Orb ;
30       SUPERV::Graph_var   _Graph ;
31       Graph_Impl        * _GraphImpl ;
32
33 // Map of InNodes of the OutNode
34       map< string , int >      _MapOfGraphNodes ;
35       long                     _GraphNodesSize ;
36       vector<bool >            _Sorted ;
37       vector<ComputingNode *>  _GraphNodes ;
38
39 // _SortedNodes[ _LevelsNumber ] : topological sort from 0 to _LevelsNumber
40 // _SortedNodes[ _level ][ _NodesNumber[ _level ] ] : _NodesNumber[ _level ] Nodes
41       int                              _LevelsNumber ;
42       int                              _ThreadsMax ;
43       int                              _GraphsNumber ;
44       vector<int >                     _NodesNumber ;
45       vector<vector<ComputingNode *> > _SortedNodes ;
46
47       vector<int >             _CnxInPortsNumber ;
48       vector<int >             _DecrInPortsNumber ;
49
50       long                     _HeadNodesSize ; 
51       vector<ComputingNode *>  _HeadNodes ;
52       long                     _QueueNodesSize ; 
53       vector<ComputingNode *>  _QueueNodes ;
54       bool                     _ParallelExecutionNodes ;
55
56       bool AddLink( GraphBase::ComputingNode *fromNode ,
57                     GraphBase::OutPort *fromPort ,
58                     GraphBase::ComputingNode *toNode ,
59                     GraphBase::InPort *toPort ) ;
60
61     public:
62
63       Graph() ;
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 ) ;
82       virtual ~Graph() ;
83
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 ; } ;
88
89       SUPERV::Graph_var ObjRef() const { return _Graph ; } ;
90       void SetObjRef( SUPERV::Graph_var aGraph ) {
91                       _Graph = aGraph ; } ;
92       Graph_Impl * ObjImpl() const { return _GraphImpl ; } ;
93       void SetObjImpl( Graph_Impl * aGraphImpl ) {
94                        _GraphImpl = aGraphImpl ; } ;
95
96       void AddLink( const char* FromNodeName , GraphBase::ComputingNode * anOutNode ) {
97            GetChangeGraphNode( FromNodeName )->AddLink( anOutNode ) ; } ;
98
99       const int GetGraphNodeIndex( const char *name ) {
100             const int index = _MapOfGraphNodes[ name ] - 1 ;
101 //            if ( index >= 0 )
102 //              cdebug << "GetGraphNodeIndex of " << name << " in _MapOfGraphNodes : "
103 //                     << index << " Node " << hex << (void *) _GraphNodes[ index ]
104 //                     << dec << " '" << _GraphNodes[ index ]->Name() << "'" << endl ;
105             return index ; } ;
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 ;
111            } ;
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 ) ;
116             return aNode ; } ;
117       ComputingNode * GetChangeGraphNode( const int index ) const {
118             if ( index >= 0 && index < _GraphNodesSize ) {
119               ComputingNode * aNode = _GraphNodes[ index ] ;
120               return aNode ;
121             }
122             else
123               return NULL ; } ;
124       const ComputingNode * GetGraphNode( const char *name ) {
125             const ComputingNode * aNode = GetChangeGraphNode( name ) ;
126             return aNode ; } ;
127       ComputingNode * GetChangeGraphNode( const char *name ) {
128             int index = GetGraphNodeIndex( name ) ;
129             if ( index >= 0 && index < _GraphNodesSize ) {
130               ComputingNode * aNode = GetChangeGraphNode( index ) ;
131               return aNode ;
132             }
133             else
134               return NULL ; } ;
135
136       const int GraphNodesSize() const {
137             return _GraphNodesSize ; } ;
138       ComputingNode * GraphNodes( int i ) const {
139             return _GraphNodes[ i ] ; } ;
140
141       const int HeadNodesSize() const {
142             return _HeadNodesSize ; } ;
143       ComputingNode * HeadNodes( int i ) const {
144             return _HeadNodes[ i ] ; } ;
145
146       const int QueueNodesSize() const {
147             return _QueueNodesSize ; } ;
148       ComputingNode * QueueNodes( int i ) const {
149             return _QueueNodes[ i ] ; } ;
150
151       const GraphBase::InPort *GetInPort( const char* ToNodeName ,
152                                           const char* ToServiceParameterName ) {
153             ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ;
154             if ( aNode ) {
155               return aNode->GetInPort(ToServiceParameterName);
156             }
157             else
158               return NULL ; } ;
159       GraphBase::InPort *GetChangeInPort( const char* ToNodeName ,
160                                           const char* ToServiceParameterName ) {
161             ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ;
162             if ( aNode ) {
163               return aNode->GetChangeInPort(ToServiceParameterName);
164             }
165             else
166               return NULL ; } ;
167       GraphBase::OutPort *GetChangeOutPort(
168                                       const char* FromNodeName ,
169                                       const char* FromServiceParameterName ) {
170             ComputingNode * aNode = GetChangeGraphNode( FromNodeName ) ;
171             if ( aNode ) {
172               return aNode->GetChangeOutPort( FromServiceParameterName );
173             }
174             else
175               return NULL ; } ;
176
177       SUPERV::GraphState PortState( const char* NodeName ,
178                                     const char* ServiceParameterName ) ;
179       bool PortDone( const char* NodeName ,
180                      const char* ServiceParameterName ) {
181         bool aRet = false ;
182         SUPERV::GraphState aState = PortState( NodeName ,
183                                                 ServiceParameterName ) ;
184         if ( aState == SUPERV::DoneState )
185           aRet = true ;
186         return aRet ; } ;
187       const CORBA::Any * PortInData( const char* ToNodeName ,
188                                      const char* ToServiceParameterName ) ;
189       const CORBA::Any * PortOutData( const char* FromNodeName ,
190                                       const char* FromServiceParameterName ) ;
191
192       bool LoadXml( CORBA::ORB_ptr Orb , const char* anXmlFile ,
193                     GraphBase::SGraph & aDataFlow ) ;
194
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 ;
201
202       bool AddNode( ComputingNode * aNode ) ;
203       bool RemoveNode( const char* NodeName ) ;
204       bool ReNameNode( const char* OldNodeName ,
205                        const char* NewNodeName ) ;
206
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 ) ;
222
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 ) ;
233
234       bool AddInputData( const char* ToNodeName ,
235                          const char* ToParameterName ,
236                          const CORBA::Any ** aValue ) ;
237
238       bool AddOutputData( const char* FromNodeName ,
239                           const char* FromParameterName ,
240                           const CORBA::Any aValue ) ;
241
242       bool CreateService() ;
243       bool InLineServices() ;
244
245       bool Sort() ;
246       bool ComputingNodes() const ;
247       bool DataServerNodes() const ;
248   
249       long LevelMax() {
250            return _LevelsNumber + 1 ; } ;
251       SUPERV::ListOfStrings * LevelNodes(long aLevel ) ;
252       long ThreadsMax() {
253            return _ThreadsMax ; } ;
254       long GraphsNumber() {
255            return _GraphsNumber ; } ;
256
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 ] ; } ;
261
262       bool StartComponent( const int aThread ,
263                            const char * ComputerContainer ,
264                            const char * ComponentName ,
265                            Engines::Container_var & myContainer ,
266                            Engines::Component_var & objComponent ) ;
267
268   };
269   
270 };
271
272 #endif