]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/GraphBase/DataFlowBase_StreamNode.hxx
Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / GraphBase / DataFlowBase_StreamNode.hxx
diff --git a/src/GraphBase/DataFlowBase_StreamNode.hxx b/src/GraphBase/DataFlowBase_StreamNode.hxx
new file mode 100644 (file)
index 0000000..3a7b5b2
--- /dev/null
@@ -0,0 +1,190 @@
+//  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
+//
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : DataFlowBase_StreamNode.hxx
+//  Author : Jean Rahuel
+//  Module : SUPERV
+//  $Header:
+
+#ifndef _DATAFLOWBASE_STREAMNODE_HXX
+#define _DATAFLOWBASE_STREAMNODE_HXX
+
+#include "DataFlowBase_PortsOfNode.hxx"
+
+namespace GraphBase {
+
+  class StreamNode : public PortsOfNode {
+
+    private:
+    
+      char                 * _Name ;
+      SUPERV::KindOfNode     _Kind ;
+
+// Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
+      map< string , int >   _MapOfLinkedNodes ;
+      int                   _LinkedNodesSize ;
+      vector<StreamNode * > _LinkedNodes ;
+      vector<int >          _LinkedInPortsNumber ;
+
+// Nodes with InStreamPort(s) linked to OutStreamport(s) of this node :
+// NodeName <--> index of that linked node in _LinkedNodes
+      map< string , int >   _MapOfLinkedStreamNodes ;
+      int                   _LinkedStreamNodesSize ;
+      vector<StreamNode * > _LinkedStreamNodes ;
+      vector<int >          _LinkedInStreamPortsNumber ;
+
+      bool                  _HeadNode ;
+      int                   _LevelNumber ;
+      int                   _SortedIndex ;
+
+      int                   _SubGraphNumber ;
+      int                   _SubStreamGraphNumber ;
+
+    protected:
+
+      int                  * _Graph_prof_debug ;
+      ofstream             * _Graph_fdebug ;
+
+      StreamNode() ;
+
+      StreamNode( const char * NodeName ) ;
+
+      StreamNode( int * Graph_prof_debug ,
+                  ofstream * Graph_fdebug ) ;
+
+      virtual ~StreamNode() ;
+
+    public:
+
+      char * Name() const { return my_strdup( _Name ) ; } ;
+      const char *const * NamePtr() const { return &_Name ; } ;
+      bool Name( const char * aName ) ;
+
+      SUPERV::KindOfNode Kind() const {
+            return _Kind; } ;
+      bool Kind( SUPERV::KindOfNode aKind) {
+        _Kind = aKind ;
+        return true ; } ;
+      const bool IsComputingNode() const {
+            return (Kind() == SUPERV::ComputingNode ) ; } ;
+      const bool IsFactoryNode() const {
+            return (Kind() == SUPERV::FactoryNode ) ; } ;
+      const bool IsOneOfGOTONodes() const {
+            return (Kind() == SUPERV::LoopNode ||
+                    Kind() == SUPERV::EndLoopNode ||
+                    Kind() == SUPERV::SwitchNode ||
+                    Kind() == SUPERV::EndSwitchNode ||
+                    Kind() == SUPERV::GOTONode ) ; } ;
+      const bool IsOneOfInLineNodes() const {
+            return (Kind() == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ;
+      const bool IsInLineNode() const {
+            return (Kind() == SUPERV::InLineNode ) ; } ;
+      const bool IsDataFlowNode() const {
+            return (Kind() == SUPERV::DataFlowGraph ) ; } ;
+      const bool IsDataStreamNode() const {
+            return (Kind() == SUPERV::DataStreamGraph ) ; } ;
+      const bool IsLoopNode() const {
+            return (Kind() == SUPERV::LoopNode ) ; } ;
+      const bool IsEndLoopNode() const {
+            return (Kind() == SUPERV::EndLoopNode ) ; } ;
+      const bool IsSwitchNode() const {
+            return (Kind() == SUPERV::SwitchNode ) ; } ;
+      const bool IsEndSwitchNode() const {
+            return (Kind() == SUPERV::EndSwitchNode ) ; } ;
+      const bool IsGOTONode() const {
+            return (Kind() == SUPERV::GOTONode ) ; } ;
+
+      int GetLinkedNodeIndex( const char * name ) {
+          int index = _MapOfLinkedNodes[ name ] -1 ;
+          if ( index >= 0 ) {
+            cdebug << "GetLinkedNodeIndex of " << name
+                   << " in _MapOfLinkedNodes : "
+                   << index << " Node " << hex << (void *) _LinkedNodes[ index ]
+                   << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
+                   << endl ;
+         }
+          return index ; } ;
+      void SetLinkedNodeIndex( const char * name , const int index ) {
+          _MapOfLinkedNodes[ name ] = index +1 ;
+          cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : "
+                 << index << " Node " << hex << (void *) _LinkedNodes[ index ]
+                 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
+                 << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1
+                 << endl ;
+          } ;
+      void DelLinkedNodeIndex( const char * name ) {
+           _MapOfLinkedNodes.erase( name ) ; } ;
+
+      int LinkedNodesSize() const { return _LinkedNodesSize ; } ;
+
+      const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
+
+      StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
+
+      int GetLinkedStreamNodeIndex( const char * name ) {
+          int index = _MapOfLinkedStreamNodes[ name ] -1 ;
+          if ( index >= 0 ) {
+            cdebug << "GetLinkedStreamNodeIndex of " << name
+                   << " in _MapOfLinkedStreamNodes : "
+                   << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
+                   << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
+                   << endl ;
+         }
+          return index ; } ;
+      void SetLinkedStreamNodeIndex( const char * name , const int index ) {
+          _MapOfLinkedStreamNodes[ name ] = index +1 ;
+          cdebug << "SetLinkedStreamNodeIndex of " << name << " in _MapOfLinkedStreamNodes : "
+                 << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ]
+                 << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'"
+                 << " _MapOfLinkedStreamNodes " << _MapOfLinkedStreamNodes[ name ] - 1
+                 << endl ;
+          } ;
+      void DelLinkedStreamNodeIndex( const char * name ) {
+           _MapOfLinkedStreamNodes.erase( name ) ; } ;
+
+      int LinkedStreamNodesSize() const { return _LinkedStreamNodesSize ; } ;
+
+      const int LinkedInStreamPortsNumber( int i ) const { return _LinkedInStreamPortsNumber[ i ] ; } ;
+
+      StreamNode * LinkedStreamNodes( int i ) const { return _LinkedStreamNodes[ i ] ; } ;
+
+      void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
+      const bool IsHeadNode() const { return _HeadNode ; } ;
+
+      int Level() { return _LevelNumber ; } ;
+      void Level( int LevelNumber ) {
+           _LevelNumber = LevelNumber ; } ;
+
+      void SortedIndex( int aSortedIndex ) {
+           _SortedIndex = aSortedIndex ; } ;
+      int SortedIndex() const {
+           return _SortedIndex ; } ;
+
+      void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ;
+
+      int SubGraph() { return _SubGraphNumber ; } ;
+      void SubGraph( int SubGraphNumber ) {
+           _SubGraphNumber = SubGraphNumber ; } ;
+
+      int SubStreamGraph() { return _SubStreamGraphNumber ; } ;
+      void SubStreamGraph( int SubStreamGraphNumber ) {
+           _SubStreamGraphNumber = SubStreamGraphNumber ; } ;
+
+      void AddLink( StreamNode * aNode ) ;
+      bool RemoveLink( StreamNode * aNode ) ;
+      void ReNameLink( const char* OldNodeName ,
+                       const char* NewNodeName ) ;
+
+      void AddStreamLink( StreamNode * aNode ) ;
+      bool RemoveStreamLink( StreamNode * aNode ) ;
+      void ReNameStreamLink( const char* OldNodeName ,
+                             const char* NewNodeName ) ;
+
+  };
+  
+};
+
+#endif