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 ;
58 GraphEditor::DataFlow * _GraphEditor ;
59 // If DataFlowGraph/DataStreamGraph in another graph :
60 // the Graph if MacroNode and MacroNode if Graph
61 SUPERV::Graph_var _GraphMacroNode ;
62 GraphBase::Graph * _GraphOfNode ;
64 int _GraphMacroLevel ;
66 int _SubStreamGraphNumber ;
70 int * _Graph_prof_debug ;
71 ofstream * _Graph_fdebug ;
75 StreamNode( const char * NodeName ,
76 const SUPERV::KindOfNode DataFlowkind ,
77 int * Graph_prof_debug ,
78 ofstream * Graph_fdebug ) ;
80 StreamNode( int * Graph_prof_debug ,
81 ofstream * Graph_fdebug ) ;
83 virtual ~StreamNode() ;
87 char * Name() const { return my_strdup( _Name ) ; } ;
88 const char *const * NamePtr() const { return &_Name ; } ;
89 bool Name( const char * aName ) ;
91 SUPERV::KindOfNode Kind() const {
93 bool Kind( SUPERV::KindOfNode aKind) {
96 const bool IsComputingNode() const {
97 return (Kind() == SUPERV::ComputingNode ) ; } ;
98 const bool IsFactoryNode() const {
99 return (Kind() == SUPERV::FactoryNode ) ; } ;
100 const bool IsOneOfGOTONodes() const {
101 return (Kind() == SUPERV::LoopNode ||
102 Kind() == SUPERV::EndLoopNode ||
103 Kind() == SUPERV::SwitchNode ||
104 Kind() == SUPERV::EndSwitchNode ||
105 Kind() == SUPERV::GOTONode ||
106 Kind() == SUPERV::MacroNode ) ; } ;
107 const bool IsOneOfInLineNodes() const {
108 return (Kind() == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ;
109 const bool IsInLineNode() const {
110 return (Kind() == SUPERV::InLineNode ) ; } ;
111 const bool IsMacroNode() const {
112 return (Kind() == SUPERV::MacroNode ) ; } ;
113 const bool IsDataFlowNode() const {
114 return (Kind() == SUPERV::DataFlowGraph ) ; } ;
115 const bool IsDataStreamNode() const {
116 return (Kind() == SUPERV::DataStreamGraph ) ; } ;
117 const bool IsLoopNode() const {
118 return (Kind() == SUPERV::LoopNode ) ; } ;
119 const bool IsEndLoopNode() const {
120 return (Kind() == SUPERV::EndLoopNode ) ; } ;
121 const bool IsSwitchNode() const {
122 return (Kind() == SUPERV::SwitchNode ) ; } ;
123 const bool IsEndSwitchNode() const {
124 return (Kind() == SUPERV::EndSwitchNode ) ; } ;
125 const bool IsGOTONode() const {
126 return (Kind() == SUPERV::GOTONode ) ; } ;
128 int GetLinkedNodeIndex( const char * name ) {
129 int index = _MapOfLinkedNodes[ name ] -1 ;
131 cdebug << "GetLinkedNodeIndex of " << name
132 << " in _MapOfLinkedNodes : "
133 << index << " Node " << hex << (void *) _LinkedNodes[ index ]
134 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
138 void SetLinkedNodeIndex( const char * name , const int index ) {
139 _MapOfLinkedNodes[ name ] = index +1 ;
140 cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : index "
141 << index << " of " << Name() << " Node " << hex << (void *) _LinkedNodes[ index ]
142 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
143 << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1
146 void DelLinkedNodeIndex( const char * name ) {
147 _MapOfLinkedNodes.erase( name ) ; } ;
149 int LinkedNodesSize() const { return _LinkedNodesSize ; } ;
151 const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
153 StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
155 int GetLinkedFromNodeIndex( const char * name ) {
156 int index = _MapOfLinkedFromNodes[ name ] -1 ;
158 cdebug << "GetLinkedFromNodeIndex of " << name
159 << " in _MapOfLinkedFromNodes : "
160 << index << " FromNode " << hex << (void *) _LinkedFromNodes[ index ]
161 << dec << " '" << _LinkedFromNodes[ index ]->Name() << "'"
165 void SetLinkedFromNodeIndex( const char * name , const int index ) {
166 _MapOfLinkedFromNodes[ name ] = index +1 ;
167 cdebug << "SetLinkedFromNodeIndex of " << name << " in _MapOfLinkedFromNodes : index "
168 << index << " of " << Name() << " FromNode " << hex
169 << (void *) _LinkedFromNodes[ index ]
170 << dec << " '" << _LinkedFromNodes[ index ]->Name() << "'"
171 << " _MapOfLinkedFromNodes " << _MapOfLinkedFromNodes[ name ] - 1
174 void DelLinkedFromNodeIndex( const char * name ) {
175 _MapOfLinkedFromNodes.erase( name ) ; } ;
177 int LinkedFromNodesSize() const { return _LinkedFromNodesSize ; } ;
179 const int LinkedFromInPortsNumber( int i ) const { return _LinkedFromInPortsNumber[ i ] ; } ;
181 StreamNode * LinkedFromNodes( int i ) const { return _LinkedFromNodes[ i ] ; } ;
183 int GetLinkedStreamNodeIndex( const char * name ) {
184 int index = _MapOfLinkedStreamNodes[ name ] -1 ;
186 cdebug << "GetLinkedStreamNodeIndex of " << name
187 << " in _MapOfLinkedStreamNodes : "
188 << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
189 << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
193 void SetLinkedStreamNodeIndex( const char * name , const int index ) {
194 _MapOfLinkedStreamNodes[ name ] = index +1 ;
195 cdebug << "SetLinkedStreamNodeIndex of " << name << " in _MapOfLinkedStreamNodes : "
196 << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
197 << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
198 << " _MapOfLinkedStreamNodes " << _MapOfLinkedStreamNodes[ name ] - 1
201 void DelLinkedStreamNodeIndex( const char * name ) {
202 _MapOfLinkedStreamNodes.erase( name ) ; } ;
204 int LinkedStreamNodesSize() const { return _LinkedStreamNodesSize ; } ;
206 const int LinkedInStreamPortsNumber( int i ) const { return _LinkedInStreamPortsNumber[ i ] ; } ;
208 StreamNode * LinkedStreamNodes( int i ) const { return _LinkedStreamNodes[ i ] ; } ;
210 void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
211 const bool IsHeadNode() const { return _HeadNode ; } ;
213 int Level() const { return _LevelNumber ; } ;
214 void Level( int LevelNumber ) {
215 _LevelNumber = LevelNumber ; } ;
217 void SortedIndex( int aSortedIndex ) {
218 _SortedIndex = aSortedIndex ; } ;
219 int SortedIndex() const {
220 return _SortedIndex ; } ;
222 void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ;
224 void GraphEditor( GraphEditor::DataFlow * aGraphEditor ) {
225 cdebug << "StreamNode::GraphEditor this " << this << " " << Name() << " : _GraphEditor = " << aGraphEditor << endl ;
226 _GraphEditor = aGraphEditor ; } ;
227 GraphEditor::DataFlow * GraphEditor() const {
228 cdebug << "StreamNode::GraphEditor this " << this << " " << Name() << " : " << _GraphEditor << endl ;
229 return _GraphEditor ; } ;
231 void GraphMacroLevel( int aGraphMacroLevel ) {
232 cdebug << "GraphMacroLevel " << Name() << " " << aGraphMacroLevel << endl ;
233 _GraphMacroLevel = aGraphMacroLevel ; } ;
234 int GraphMacroLevel() const {
235 return _GraphMacroLevel ; } ;
237 void MacroObject( SUPERV::Graph_var aGraphMacroNode ) {
238 if ( CORBA::is_nil( aGraphMacroNode ) ) {
239 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
240 << " MacroObject(nil object). Error" << endl ;
243 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
244 << " MacroObject " << _GraphMacroNode << endl ;
246 _GraphMacroNode = aGraphMacroNode ; } ;
247 SUPERV::Graph_var MacroObject() const {
248 if ( CORBA::is_nil( _GraphMacroNode ) ) {
249 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
250 << " returns nil object. Error" << endl ;
252 return _GraphMacroNode ; } ;
254 void GraphOfNode( GraphBase::Graph * aGraph ) {
255 _GraphOfNode = aGraph ; } ;
256 GraphBase::Graph * GraphOfNode() const {
257 return _GraphOfNode ; } ;
258 GraphBase::Graph * GraphOfNode() {
259 return _GraphOfNode ; } ;
261 int SubGraph() const { return _SubGraphNumber ; } ;
262 void SubGraph( int SubGraphNumber ) {
263 _SubGraphNumber = SubGraphNumber ; } ;
265 int SubStreamGraph() const { return _SubStreamGraphNumber ; } ;
266 void SubStreamGraph( int SubStreamGraphNumber ) {
267 _SubStreamGraphNumber = SubStreamGraphNumber ; } ;
269 void AddLinkedNode( StreamNode * ToNode ) ;
270 bool RemoveLinkedNode( StreamNode * ToNode ,
271 bool DoLinkedFromNode = true ) ;
272 void ReNameLinkedNode( const char* OldNodeName ,
273 const char* NewNodeName ) ;
274 void ReNameLinkedFromNode( const char* OldNodeName ,
275 const char* NewNodeName ) ;
277 void AddStreamLinkedNode( StreamNode * ToNode ) ;
278 bool RemoveStreamLinkedNode( StreamNode * ToNode ) ;
279 void ReNameStreamLinkedNode( const char* OldNodeName ,
280 const char* NewNodeName ) ;