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 // 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 ;
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 ;
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 ;
57 int _GraphMacroLevel ;
59 int _SubStreamGraphNumber ;
63 int * _Graph_prof_debug ;
64 ofstream * _Graph_fdebug ;
68 StreamNode( const char * NodeName ,
69 const SUPERV::KindOfNode DataFlowkind ,
70 int * Graph_prof_debug ,
71 ofstream * Graph_fdebug ) ;
73 StreamNode( int * Graph_prof_debug ,
74 ofstream * Graph_fdebug ) ;
76 virtual ~StreamNode() ;
80 char * Name() const { return my_strdup( _Name ) ; } ;
81 const char *const * NamePtr() const { return &_Name ; } ;
82 bool Name( const char * aName ) ;
84 SUPERV::KindOfNode Kind() const {
86 bool Kind( SUPERV::KindOfNode aKind) {
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 ) ; } ;
121 int GetLinkedNodeIndex( const char * name ) {
122 int index = _MapOfLinkedNodes[ name ] -1 ;
124 cdebug << "GetLinkedNodeIndex of " << name
125 << " in _MapOfLinkedNodes : "
126 << index << " Node " << hex << (void *) _LinkedNodes[ index ]
127 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
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
139 void DelLinkedNodeIndex( const char * name ) {
140 _MapOfLinkedNodes.erase( name ) ; } ;
142 int LinkedNodesSize() const { return _LinkedNodesSize ; } ;
144 const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
146 StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
148 int GetLinkedStreamNodeIndex( const char * name ) {
149 int index = _MapOfLinkedStreamNodes[ name ] -1 ;
151 cdebug << "GetLinkedStreamNodeIndex of " << name
152 << " in _MapOfLinkedStreamNodes : "
153 << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
154 << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
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
166 void DelLinkedStreamNodeIndex( const char * name ) {
167 _MapOfLinkedStreamNodes.erase( name ) ; } ;
169 int LinkedStreamNodesSize() const { return _LinkedStreamNodesSize ; } ;
171 const int LinkedInStreamPortsNumber( int i ) const { return _LinkedInStreamPortsNumber[ i ] ; } ;
173 StreamNode * LinkedStreamNodes( int i ) const { return _LinkedStreamNodes[ i ] ; } ;
175 void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
176 const bool IsHeadNode() const { return _HeadNode ; } ;
178 int Level() const { return _LevelNumber ; } ;
179 void Level( int LevelNumber ) {
180 _LevelNumber = LevelNumber ; } ;
182 void SortedIndex( int aSortedIndex ) {
183 _SortedIndex = aSortedIndex ; } ;
184 int SortedIndex() const {
185 return _SortedIndex ; } ;
187 void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ;
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 ; } ;
196 void GraphMacroLevel( int aGraphMacroLevel ) {
197 cdebug << "GraphMacroLevel " << Name() << " " << aGraphMacroLevel << endl ;
198 _GraphMacroLevel = aGraphMacroLevel ; } ;
199 int GraphMacroLevel() const {
200 return _GraphMacroLevel ; } ;
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 ;
208 cdebug << "MacroObject GraphMacroNode " << this << " " << Name()
209 << " MacroObject " << _GraphMacroNode << endl ;
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 ;
217 return _GraphMacroNode ; } ;
219 void GraphOfNode( GraphBase::Graph * aGraph ) {
220 _GraphOfNode = aGraph ; } ;
221 GraphBase::Graph * GraphOfNode() {
222 return _GraphOfNode ; } ;
224 int SubGraph() const { return _SubGraphNumber ; } ;
225 void SubGraph( int SubGraphNumber ) {
226 _SubGraphNumber = SubGraphNumber ; } ;
228 int SubStreamGraph() const { return _SubStreamGraphNumber ; } ;
229 void SubStreamGraph( int SubStreamGraphNumber ) {
230 _SubStreamGraphNumber = SubStreamGraphNumber ; } ;
232 void AddLinkedNode( StreamNode * aNode ) ;
233 bool RemoveLinkedNode( StreamNode * aNode ) ;
234 void ReNameLinkedNode( const char* OldNodeName ,
235 const char* NewNodeName ) ;
237 void AddStreamLinkedNode( StreamNode * aNode ) ;
238 bool RemoveStreamLinkedNode( StreamNode * aNode ) ;
239 void ReNameStreamLinkedNode( const char* OldNodeName ,
240 const char* NewNodeName ) ;