1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : DataFlowBase_StreamNode.hxx
8 // Author : Jean Rahuel
12 #ifndef _DATAFLOWBASE_STREAMNODE_HXX
13 #define _DATAFLOWBASE_STREAMNODE_HXX
15 #include "DataFlowBase_PortsOfNode.hxx"
17 namespace GraphEditor {
27 class StreamNode : public PortsOfNode {
32 SUPERV::KindOfNode _Kind ;
34 // _LinkedNodes are the nodes with link(s) from OutPort(s) of this node
35 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
36 map< string , int > _MapOfLinkedNodes ;
37 int _LinkedNodesSize ;
38 vector<StreamNode * > _LinkedNodes ;
39 vector<int > _LinkedInPortsNumber ;
41 // _LinkedFromNodes are the nodes with link(s) to InPort(s) of this node
42 map< string , int > _MapOfLinkedFromNodes ;
43 int _LinkedFromNodesSize ;
44 vector<StreamNode * > _LinkedFromNodes ;
45 vector<int > _LinkedFromInPortsNumber ;
47 // Nodes with InStreamPort(s) linked to OutStreamport(s) of this node :
48 // NodeName <--> index of that linked node in _LinkedNodes
49 map< string , int > _MapOfLinkedStreamNodes ;
50 int _LinkedStreamNodesSize ;
51 vector<StreamNode * > _LinkedStreamNodes ;
52 vector<int > _LinkedInStreamPortsNumber ;
54 bool _NodeDoneInBranchOfSwitch ;
60 GraphEditor::DataFlow * _GraphEditor ;
61 // If DataFlowGraph/DataStreamGraph in another graph :
62 // the Graph if MacroNode and MacroNode if Graph
63 SUPERV::Graph_var _GraphMacroNode ;
64 GraphBase::Graph * _GraphOfNode ;
66 int _GraphMacroLevel ;
68 int _SubStreamGraphNumber ;
72 int * _Graph_prof_debug ;
73 ofstream * _Graph_fdebug ;
77 StreamNode( const char * NodeName ,
78 const SUPERV::KindOfNode DataFlowkind ,
79 int * Graph_prof_debug ,
80 ofstream * Graph_fdebug ) ;
82 StreamNode( int * Graph_prof_debug ,
83 ofstream * Graph_fdebug ) ;
85 virtual ~StreamNode() ;
89 //JR 17.02.2005 Memory Leak char * Name() const { return my_strdup( _Name ) ; } ;
91 // cdebug << "StreamNode::Name " << (void * ) _Name << " = " << _Name << endl ;
92 //JR 21.02.2005 Memory Leak return my_strdup( _Name ) ; } ;
94 const char *const * NamePtr() const {
95 // cdebug << "StreamNode::NamePtr " << (void ** ) &_Name << " = Name " << (void * ) _Name
96 // << " = " << _Name << endl ;
98 bool Name( const char * aName ) ;
100 SUPERV::KindOfNode Kind() const {
102 bool Kind( SUPERV::KindOfNode aKind) {
105 const bool IsComputingNode() const {
106 return (Kind() == SUPERV::ComputingNode ) ; } ;
107 const bool IsFactoryNode() const {
108 return (Kind() == SUPERV::FactoryNode ) ; } ;
109 const bool IsOneOfGOTONodes() const {
110 return (Kind() == SUPERV::LoopNode ||
111 Kind() == SUPERV::EndLoopNode ||
112 Kind() == SUPERV::SwitchNode ||
113 Kind() == SUPERV::EndSwitchNode ||
114 Kind() == SUPERV::GOTONode ||
115 Kind() == SUPERV::MacroNode ) ; } ;
116 const bool IsOneOfInLineNodes() const {
117 return (Kind() == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ;
118 const bool IsInLineNode() const {
119 return (Kind() == SUPERV::InLineNode ) ; } ;
120 const bool IsMacroNode() const {
121 return (Kind() == SUPERV::MacroNode ) ; } ;
122 const bool IsDataFlowNode() const {
123 return (Kind() == SUPERV::DataFlowGraph ) ; } ;
124 const bool IsDataStreamNode() const {
125 return (Kind() == SUPERV::DataStreamGraph ) ; } ;
126 const bool IsLoopNode() const {
127 return (Kind() == SUPERV::LoopNode ) ; } ;
128 const bool IsEndLoopNode() const {
129 return (Kind() == SUPERV::EndLoopNode ) ; } ;
130 const bool IsSwitchNode() const {
131 return (Kind() == SUPERV::SwitchNode ) ; } ;
132 const bool IsEndSwitchNode() const {
133 return (Kind() == SUPERV::EndSwitchNode ) ; } ;
134 const bool IsGOTONode() const {
135 return (Kind() == SUPERV::GOTONode ) ; } ;
137 int GetLinkedNodeIndex( const char * name ) {
138 int index = _MapOfLinkedNodes[ name ] -1 ;
140 cdebug << "GetLinkedNodeIndex of " << name
141 << " in _MapOfLinkedNodes : "
142 << index << " Node " << hex << (void *) _LinkedNodes[ index ]
143 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
147 void SetLinkedNodeIndex( const char * name , const int index ) {
148 _MapOfLinkedNodes[ name ] = index +1 ;
149 cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : index "
150 << index << " of " << Name() << " Node " << hex << (void *) _LinkedNodes[ index ]
151 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
152 << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1
155 void DelLinkedNodeIndex( const char * name ) {
156 _MapOfLinkedNodes.erase( name ) ; } ;
158 int LinkedNodesSize() const { return _LinkedNodesSize ; } ;
160 const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
162 StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
164 int GetLinkedFromNodeIndex( const char * name ) {
165 int index = _MapOfLinkedFromNodes[ name ] -1 ;
167 cdebug << "GetLinkedFromNodeIndex of " << name
168 << " in _MapOfLinkedFromNodes : "
169 << index << " FromNode " << hex << (void *) _LinkedFromNodes[ index ]
170 << dec << " '" << _LinkedFromNodes[ index ]->Name() << "'"
174 void SetLinkedFromNodeIndex( const char * name , const int index ) {
175 _MapOfLinkedFromNodes[ name ] = index +1 ;
176 cdebug << "SetLinkedFromNodeIndex of " << name << " in _MapOfLinkedFromNodes : index "
177 << index << " of " << Name() << " FromNode " << hex
178 << (void *) _LinkedFromNodes[ index ]
179 << dec << " '" << _LinkedFromNodes[ index ]->Name() << "'"
180 << " _MapOfLinkedFromNodes " << _MapOfLinkedFromNodes[ name ] - 1
183 void DelLinkedFromNodeIndex( const char * name ) {
184 _MapOfLinkedFromNodes.erase( name ) ; } ;
186 int LinkedFromNodesSize() const { return _LinkedFromNodesSize ; } ;
188 const int LinkedFromInPortsNumber( int i ) const { return _LinkedFromInPortsNumber[ i ] ; } ;
190 StreamNode * LinkedFromNodes( int i ) const { return _LinkedFromNodes[ i ] ; } ;
192 int GetLinkedStreamNodeIndex( const char * name ) {
193 int index = _MapOfLinkedStreamNodes[ name ] -1 ;
195 cdebug << "GetLinkedStreamNodeIndex of " << name
196 << " in _MapOfLinkedStreamNodes : "
197 << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
198 << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
202 void SetLinkedStreamNodeIndex( const char * name , const int index ) {
203 _MapOfLinkedStreamNodes[ name ] = index +1 ;
204 cdebug << "SetLinkedStreamNodeIndex of " << name << " in _MapOfLinkedStreamNodes : "
205 << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
206 << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
207 << " _MapOfLinkedStreamNodes " << _MapOfLinkedStreamNodes[ name ] - 1
210 void DelLinkedStreamNodeIndex( const char * name ) {
211 _MapOfLinkedStreamNodes.erase( name ) ; } ;
213 int LinkedStreamNodesSize() const { return _LinkedStreamNodesSize ; } ;
215 const int LinkedInStreamPortsNumber( int i ) const { return _LinkedInStreamPortsNumber[ i ] ; } ;
217 StreamNode * LinkedStreamNodes( int i ) const { return _LinkedStreamNodes[ i ] ; } ;
219 bool BranchOfSwitchDone( bool aNodeDoneInBranchOfSwitch ) {
220 bool prevalue = _NodeDoneInBranchOfSwitch ;
221 _NodeDoneInBranchOfSwitch = aNodeDoneInBranchOfSwitch ;
222 if ( prevalue && !aNodeDoneInBranchOfSwitch ) {
226 bool BranchOfSwitchDone() {
227 return _NodeDoneInBranchOfSwitch ; } ;
229 void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
230 const bool IsHeadNode() const { return _HeadNode ; } ;
232 int Level() const { return _LevelNumber ; } ;
233 void Level( int LevelNumber ) {
234 _LevelNumber = LevelNumber ; } ;
236 void SortedIndex( int aSortedIndex ) {
237 _SortedIndex = aSortedIndex ; } ;
238 int SortedIndex() const {
239 return _SortedIndex ; } ;
241 void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ;
243 void GraphEditor( GraphEditor::DataFlow * aGraphEditor ) {
244 cdebug << "StreamNode::GraphEditor this " << this << " " << Name() << " : _GraphEditor = " << aGraphEditor << endl ;
245 _GraphEditor = aGraphEditor ; } ;
246 GraphEditor::DataFlow * GraphEditor() const {
247 cdebug << "StreamNode::GraphEditor this " << this << " " << Name() << " : " << _GraphEditor << endl ;
248 return _GraphEditor ; } ;
250 void GraphMacroLevel( int aGraphMacroLevel ) {
251 cdebug << "GraphMacroLevel " << Name() << " " << aGraphMacroLevel << endl ;
252 _GraphMacroLevel = aGraphMacroLevel ; } ;
253 int GraphMacroLevel() const {
254 return _GraphMacroLevel ; } ;
256 void MacroObject( SUPERV::Graph_var aGraphMacroNode ) {
257 if ( CORBA::is_nil( aGraphMacroNode ) ) {
258 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
259 << " MacroObject(nil object). Error" << endl ;
262 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
263 << " MacroObject " << _GraphMacroNode << endl ;
265 _GraphMacroNode = aGraphMacroNode ; } ;
266 SUPERV::Graph_var MacroObject() const {
267 if ( CORBA::is_nil( _GraphMacroNode ) ) {
268 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
269 << " returns nil object. Error" << endl ;
271 return _GraphMacroNode ; } ;
273 void GraphOfNode( GraphBase::Graph * aGraph ) {
274 _GraphOfNode = aGraph ; } ;
275 GraphBase::Graph * GraphOfNode() const {
276 return _GraphOfNode ; } ;
277 GraphBase::Graph * GraphOfNode() {
278 return _GraphOfNode ; } ;
280 int SubGraph() const { return _SubGraphNumber ; } ;
281 void SubGraph( int SubGraphNumber ) {
282 _SubGraphNumber = SubGraphNumber ; } ;
284 int SubStreamGraph() const { return _SubStreamGraphNumber ; } ;
285 void SubStreamGraph( int SubStreamGraphNumber ) {
286 _SubStreamGraphNumber = SubStreamGraphNumber ; } ;
288 void AddLinkedNode( StreamNode * ToNode ) ;
289 bool RemoveLinkedNode( StreamNode * ToNode ,
290 bool DoLinkedFromNode = true ) ;
291 void ReNameLinkedNode( const char* OldNodeName ,
292 const char* NewNodeName ) ;
293 void ReNameLinkedFromNode( const char* OldNodeName ,
294 const char* NewNodeName ) ;
296 void AddStreamLinkedNode( StreamNode * ToNode ) ;
297 bool RemoveStreamLinkedNode( StreamNode * ToNode ) ;
298 void ReNameStreamLinkedNode( const char* OldNodeName ,
299 const char* NewNodeName ) ;