]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_StreamNode.hxx
Salome HOME
2) new Editing() method of Graph added.
[modules/superv.git] / src / GraphBase / DataFlowBase_StreamNode.hxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : DataFlowBase_StreamNode.hxx
8 //  Author : Jean Rahuel
9 //  Module : SUPERV
10 //  $Header:
11
12 #ifndef _DATAFLOWBASE_STREAMNODE_HXX
13 #define _DATAFLOWBASE_STREAMNODE_HXX
14
15 #include "DataFlowBase_PortsOfNode.hxx"
16
17 namespace GraphEditor {
18
19   class DataFlow ;
20
21 }
22
23 namespace GraphBase {
24
25   class Graph ;
26
27   class StreamNode : public PortsOfNode {
28
29     private:
30     
31       char                 * _Name ;
32       SUPERV::KindOfNode     _Kind ;
33
34 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
35       map< string , int >   _MapOfLinkedNodes ;
36       int                   _LinkedNodesSize ;
37       vector<StreamNode * > _LinkedNodes ;
38       vector<int >          _LinkedInPortsNumber ;
39
40 // Nodes with InStreamPort(s) linked to OutStreamport(s) of this node :
41 // NodeName <--> index of that linked node in _LinkedNodes
42       map< string , int >   _MapOfLinkedStreamNodes ;
43       int                   _LinkedStreamNodesSize ;
44       vector<StreamNode * > _LinkedStreamNodes ;
45       vector<int >          _LinkedInStreamPortsNumber ;
46
47       bool                  _HeadNode ;
48       int                   _LevelNumber ;
49       int                   _SortedIndex ;
50
51       GraphEditor::DataFlow   * _GraphEditor ;
52 // If DataFlowGraph/DataStreamGraph in another graph :
53 // the Graph if MacroNode and MacroNode if Graph
54       SUPERV::Graph_var       _GraphMacroNode ;
55       GraphBase::Graph        * _GraphOfNode ;
56
57       int                   _GraphMacroLevel ;
58       int                   _SubGraphNumber ;
59       int                   _SubStreamGraphNumber ;
60
61     protected:
62
63       int                  * _Graph_prof_debug ;
64       ofstream             * _Graph_fdebug ;
65
66       StreamNode() ;
67
68       StreamNode( const char * NodeName ,
69                   const SUPERV::KindOfNode DataFlowkind ,
70                   int * Graph_prof_debug ,
71                   ofstream * Graph_fdebug ) ;
72
73       StreamNode( int * Graph_prof_debug ,
74                   ofstream * Graph_fdebug ) ;
75
76       virtual ~StreamNode() ;
77
78     public:
79
80       char * Name() const { return my_strdup( _Name ) ; } ;
81       const char *const * NamePtr() const { return &_Name ; } ;
82       bool Name( const char * aName ) ;
83
84       SUPERV::KindOfNode Kind() const {
85             return _Kind; } ;
86       bool Kind( SUPERV::KindOfNode aKind) {
87         _Kind = aKind ;
88         return true ; } ;
89       const bool IsComputingNode() const {
90             return (Kind() == SUPERV::ComputingNode ) ; } ;
91       const bool IsFactoryNode() const {
92             return (Kind() == SUPERV::FactoryNode ) ; } ;
93       const bool IsOneOfGOTONodes() const {
94             return (Kind() == SUPERV::LoopNode ||
95                     Kind() == SUPERV::EndLoopNode ||
96                     Kind() == SUPERV::SwitchNode ||
97                     Kind() == SUPERV::EndSwitchNode ||
98                     Kind() == SUPERV::GOTONode ||
99                     Kind() == SUPERV::MacroNode ) ; } ;
100       const bool IsOneOfInLineNodes() const {
101             return (Kind() == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ;
102       const bool IsInLineNode() const {
103             return (Kind() == SUPERV::InLineNode ) ; } ;
104       const bool IsMacroNode() const {
105             return (Kind() == SUPERV::MacroNode ) ; } ;
106       const bool IsDataFlowNode() const {
107             return (Kind() == SUPERV::DataFlowGraph ) ; } ;
108       const bool IsDataStreamNode() const {
109             return (Kind() == SUPERV::DataStreamGraph ) ; } ;
110       const bool IsLoopNode() const {
111             return (Kind() == SUPERV::LoopNode ) ; } ;
112       const bool IsEndLoopNode() const {
113             return (Kind() == SUPERV::EndLoopNode ) ; } ;
114       const bool IsSwitchNode() const {
115             return (Kind() == SUPERV::SwitchNode ) ; } ;
116       const bool IsEndSwitchNode() const {
117             return (Kind() == SUPERV::EndSwitchNode ) ; } ;
118       const bool IsGOTONode() const {
119             return (Kind() == SUPERV::GOTONode ) ; } ;
120
121       int GetLinkedNodeIndex( const char * name ) {
122           int index = _MapOfLinkedNodes[ name ] -1 ;
123           if ( index >= 0 ) {
124             cdebug << "GetLinkedNodeIndex of " << name
125                    << " in _MapOfLinkedNodes : "
126                    << index << " Node " << hex << (void *) _LinkedNodes[ index ]
127                    << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
128                    << endl ;
129           }
130           return index ; } ;
131       void SetLinkedNodeIndex( const char * name , const int index ) {
132           _MapOfLinkedNodes[ name ] = index +1 ;
133           cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : "
134                  << index << " Node " << hex << (void *) _LinkedNodes[ index ]
135                  << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
136                  << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1
137                  << endl ;
138           } ;
139       void DelLinkedNodeIndex( const char * name ) {
140            _MapOfLinkedNodes.erase( name ) ; } ;
141
142       int LinkedNodesSize() const { return _LinkedNodesSize ; } ;
143
144       const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
145
146       StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
147
148       int GetLinkedStreamNodeIndex( const char * name ) {
149           int index = _MapOfLinkedStreamNodes[ name ] -1 ;
150           if ( index >= 0 ) {
151             cdebug << "GetLinkedStreamNodeIndex of " << name
152                    << " in _MapOfLinkedStreamNodes : "
153                    << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
154                    << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
155                    << endl ;
156           }
157           return index ; } ;
158       void SetLinkedStreamNodeIndex( const char * name , const int index ) {
159           _MapOfLinkedStreamNodes[ name ] = index +1 ;
160           cdebug << "SetLinkedStreamNodeIndex of " << name << " in _MapOfLinkedStreamNodes : "
161                  << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
162                  << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
163                  << " _MapOfLinkedStreamNodes " << _MapOfLinkedStreamNodes[ name ] - 1
164                  << endl ;
165           } ;
166       void DelLinkedStreamNodeIndex( const char * name ) {
167            _MapOfLinkedStreamNodes.erase( name ) ; } ;
168
169       int LinkedStreamNodesSize() const { return _LinkedStreamNodesSize ; } ;
170
171       const int LinkedInStreamPortsNumber( int i ) const { return _LinkedInStreamPortsNumber[ i ] ; } ;
172
173       StreamNode * LinkedStreamNodes( int i ) const { return _LinkedStreamNodes[ i ] ; } ;
174
175       void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
176       const bool IsHeadNode() const { return _HeadNode ; } ;
177
178       int Level() const { return _LevelNumber ; } ;
179       void Level( int LevelNumber ) {
180            _LevelNumber = LevelNumber ; } ;
181
182       void SortedIndex( int aSortedIndex ) {
183            _SortedIndex = aSortedIndex ; } ;
184       int SortedIndex() const {
185            return _SortedIndex ; } ;
186
187       void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ;
188
189       void GraphEditor( GraphEditor::DataFlow * aGraphEditor ) {
190            cdebug << "StreamNode::GraphEditor this " << this << " " << Name() << " : _GraphEditor = " << aGraphEditor << endl ;
191            _GraphEditor = aGraphEditor ; } ;
192       GraphEditor::DataFlow * GraphEditor() const {
193            cdebug << "StreamNode::GraphEditor this " << this << " " << Name() << " : " << _GraphEditor << endl ;
194                           return _GraphEditor ; } ;
195
196       void GraphMacroLevel( int aGraphMacroLevel ) {
197            cdebug << "GraphMacroLevel " << Name() << " " << aGraphMacroLevel << endl ;
198            _GraphMacroLevel = aGraphMacroLevel ; } ;
199       int GraphMacroLevel() const {
200           return _GraphMacroLevel ; } ;
201
202       void MacroObject( SUPERV::Graph_var aGraphMacroNode ) {
203            if ( CORBA::is_nil( aGraphMacroNode ) ) {
204              cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
205                     << " MacroObject(nil object). Error" << endl ;
206            }
207            else {
208              cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
209                     << " MacroObject " << _GraphMacroNode << endl ;
210            }
211            _GraphMacroNode = aGraphMacroNode ; } ;
212       SUPERV::Graph_var MacroObject() const {
213                         if ( CORBA::is_nil( _GraphMacroNode ) ) {
214                           cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
215                                  << " returns nil object. Error" << endl ;
216                         }
217                         return _GraphMacroNode ; } ;
218
219       void GraphOfNode( GraphBase::Graph * aGraph ) {
220            _GraphOfNode = aGraph ; } ;
221       GraphBase::Graph * GraphOfNode() {
222                          return _GraphOfNode ; } ;
223
224       int SubGraph() const { return _SubGraphNumber ; } ;
225       void SubGraph( int SubGraphNumber ) {
226            _SubGraphNumber = SubGraphNumber ; } ;
227
228       int SubStreamGraph() const { return _SubStreamGraphNumber ; } ;
229       void SubStreamGraph( int SubStreamGraphNumber ) {
230            _SubStreamGraphNumber = SubStreamGraphNumber ; } ;
231
232       void AddLinkedNode( StreamNode * aNode ) ;
233       bool RemoveLinkedNode( StreamNode * aNode ) ;
234       void ReNameLinkedNode( const char* OldNodeName ,
235                              const char* NewNodeName ) ;
236
237       void AddStreamLinkedNode( StreamNode * aNode ) ;
238       bool RemoveStreamLinkedNode( StreamNode * aNode ) ;
239       void ReNameStreamLinkedNode( const char* OldNodeName ,
240                                    const char* NewNodeName ) ;
241
242   };
243   
244 };
245
246 #endif