Salome HOME
Traces
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.hxx
index 351707ddef8fbc2376917364a52d05b49a1cea8f..cf560f07972fb939086d77e5b4b460f76cf77926 100644 (file)
@@ -33,7 +33,6 @@
 
 namespace GraphEditor {
 
-//  class OutNode : public GraphBase::Graph {
   class OutNode : public GraphBase::Base {
     
     private :
@@ -51,22 +50,23 @@ namespace GraphEditor {
 
       CORBA::ORB_ptr _Orb;
 
-      bool Valid() ;
+      bool Valid(bool kLoopSwitch = true ) ;
       bool Executable() ;
 
       bool LoadNodes( map< string , int > & aMapOfNodes ,
-                      const GraphBase::ListOfNodes &aNodes ) ;
+                      const GraphBase::ListOfSNodes &aNodes ) ;
       bool LoadLinks( map< string , int > & aMapOfNodes ,
-                      const GraphBase::ListOfLinks &aLinks ) ;
+                      const GraphBase::ListOfSLinks &aLinks ) ;
       bool LoadDatas( map< string , int > & aMapOfNodes ,
-                      const GraphBase::ListOfLinks &aDatas ) ;
+                      const GraphBase::ListOfSLinks &aDatas ) ;
 
 //      bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
       bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
                                               GraphBase::SLink aLink ,
                                               bool wdata ) const ;
 //      bool SaveXML(ostream &f ) ;QDomDocument & Graph 
-      bool SaveXML(QDomDocument & Graph ) ;
+      bool SaveXML( ostream & f , QDomDocument & Graph ,
+                    bool aSuperGraph , QDomElement & supergraph ) ;
 
       bool GraphEditor::OutNode::LinkSavePY( ostream &f ,
                                              const char *aGraphName ,
@@ -74,10 +74,22 @@ namespace GraphEditor {
                                              bool fromparam ,
                                              bool toparam ,
                                              bool wdata ) const;
-      bool SavePY(ostream &f ) ;
+      bool SavePY(ostream &f , bool importSuperV ) ;
 
       void DateModification() ;
 
+      // asv 20.09.04 added from GraphExecutor::FiniteStateMachine class (removed from there)
+//      static map< string , GraphBase::Graph * > _MapOfGraphs ;
+//      static map< string , int >                _MapOfGraphNames ;
+    
+//      GraphBase::Graph * MapGraph( const char * aGraphName ) ;
+//      bool MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) ;
+//      void EraseGraph( const char * aGraphName ) ;
+//      bool GraphName( const char * aGraphName ) ;
+//      string GraphInstanceName( const char * aGraphName ) ;
+      // end added from FiniteStateMachine
+
+
     public:
 
       OutNode();
@@ -102,6 +114,8 @@ namespace GraphEditor {
                const char * DebugFileName ) ;
       virtual ~OutNode();
 
+      bool Name( const char * aName ) ;
+
       void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
       GraphBase::StreamGraph * StreamGraph() {
                                return _StreamGraph ; } ;
@@ -113,7 +127,8 @@ namespace GraphEditor {
                                return _Graph ; } ;
 
       bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
-      bool LoadXml( const char* myFileName ) ;
+      bool LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) ;
+//      bool LoadXml( const char* myFileName ) ;
       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
 
       bool SaveXml(const char* myFileName ) ;
@@ -121,7 +136,7 @@ namespace GraphEditor {
       bool SavePy(const char* myFileName ) ;
 
 // get all DataFlow informations (for a .XML file) :
-      GraphBase::SGraph * GetDataFlow() ;
+      GraphBase::ListOfSGraphs * GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) ;
 
 //    void DateModification() ;
 
@@ -155,9 +170,15 @@ namespace GraphEditor {
            return _Graph->RemoveNode( NodeName ) ; } ;
       bool ReNameNode( const char* OldNodeName ,
                        const char* NewNodeName ) {
-           DateModification() ;
-           _Valid = false ;
-           return _Graph->ReNameNode( OldNodeName , NewNodeName ) ; } ;
+//PAL9048 JR Debug : a node may not have the same name as the graph
+           if ( strcmp( Graph()->Name() , NewNodeName ) ) {
+             DateModification() ;
+             _Valid = false ;
+             return _Graph->ReNameNode( OldNodeName , NewNodeName ) ;
+          }
+           cdebug << "Editor::OutNode::ReNameNode ERROR "  << NewNodeName << " already exists"
+                  << endl ;
+           return false ; } ;
 
       void Coordinates( const int X , const int Y ) {
            return _Graph->Coordinates( X , Y ) ; } ;
@@ -185,13 +206,13 @@ namespace GraphEditor {
       bool AddLink( const char* FromNodeName ,
                     const char* FromServiceParameterName ,
                    const char* ToNodeName ,
-                    const char* ToServiceParameterName ,
-                    const CORBA::Any aValue ) {
+                    const char* ToServiceParameterName ) {
+//                    , const CORBA::Any aValue ) {
            DateModification() ;
            _Valid = false ;
            return _Graph->AddLink( FromNodeName , FromServiceParameterName ,
-                                   ToNodeName , ToServiceParameterName ,
-                                   aValue ) ; } ;
+                                   ToNodeName , ToServiceParameterName ) ; } ;
+//                                   , aValue ) ; } ;
 
       bool RemoveLink( const char* FromNodeName ,
                        const char* FromServiceParameterName ,
@@ -256,21 +277,14 @@ namespace GraphEditor {
                          const char* ToServiceParameterName ,
                          const int index , long &X , long &Y ) ;
 
-      bool AddInputData( const char* ToNodeName1 ,
-                         const char* ToParameterName1 ,
-                         const char* ToNodeName2 ,
-                         const char* ToParameterName2 ) ;
 
-      bool IsValid() {
+      bool IsValid(bool kLoopSwitch = true ) {
            if ( !_Valid )
-             Valid() ;
+             Valid( kLoopSwitch ) ;
            return _Valid ; } ;
       bool IsNotValid() const {
            return !_Valid ; } ;
-      bool UnValid() {
-           bool RetVal = _Valid ;
-           _Valid = false ;
-           return RetVal ; } ;
+      bool UnValid() ;
 
       bool IsExecutable() {
            if ( !_Valid )
@@ -285,10 +299,21 @@ namespace GraphEditor {
       bool IsNotExecutable() const {
            return !_Executable ; } ;
 
-      const CORBA::Any *GetInData( const char *ToNodeName ,
-                                   const char *ToParameterName ) ;
-      const CORBA::Any *GetOutData( const char *FromNodeName ,
-                                    const char *FromParameterName ) ;
+      // iterate through ALL links (OutPort-InPort pairs) and check if their types are 
+      // compatible - IsCompatible(type1, type2).  
+      // Returns true if all are compatible.   
+      bool IsLinksCompatible();
+
+      // Returns true if an out-port of type "OutPortType" can be bound with 
+      // in-port of type "InPortType".  Called from IsLinksCompatible() and Link_Impl::IsValid().
+      bool IsCompatible( const char* OutPortType, const char* InPortType ) const;
+
+//JR 30.03.2005      const CORBA::Any *GetInData( const char *ToNodeName ,
+      const CORBA::Any GetInData( const char *ToNodeName ,
+                                  const char *ToParameterName ) ;
+//JR 30.03.2005      const CORBA::Any *GetOutData( const char *FromNodeName ,
+      const CORBA::Any GetOutData( const char *FromNodeName ,
+                                   const char *FromParameterName ) ;
   } ;
 
 };