src/GraphEditor/DataFlowEditor_OutNode.hxx

Go to the documentation of this file.
00001 //  SUPERV GraphEditor : contains classes that permit edition of graphs
00002 //
00003 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
00005 // 
00006 //  This library is free software; you can redistribute it and/or 
00007 //  modify it under the terms of the GNU Lesser General Public 
00008 //  License as published by the Free Software Foundation; either 
00009 //  version 2.1 of the License. 
00010 // 
00011 //  This library is distributed in the hope that it will be useful, 
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00014 //  Lesser General Public License for more details. 
00015 // 
00016 //  You should have received a copy of the GNU Lesser General Public 
00017 //  License along with this library; if not, write to the Free Software 
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
00019 // 
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //
00023 //
00024 //  File   : DataFlowEditor_OutNode.hxx
00025 //  Module : SUPERV
00026 
00027 #ifndef _DATAFLOWEDITOR_OUTNODE_HXX
00028 #define _DATAFLOWEDITOR_OUTNODE_HXX
00029 
00030 #include "DataFlowBase_StreamGraph.hxx"
00031 
00032 #include "DataFlowEditor_InNode.hxx"
00033 
00034 namespace GraphEditor {
00035 
00036   class OutNode : public GraphBase::Base {
00037     
00038     private :
00039 
00040       GraphBase::StreamGraph * _StreamGraph ;
00041       GraphBase::Graph       * _Graph ;
00042 
00043       int  _Graph_prof_debug ;
00044 
00045       bool _Imported ;
00046 
00047       bool _Valid ;
00048 
00049       bool _Executable ;
00050 
00051       CORBA::ORB_ptr _Orb;
00052 
00053 //      bool Valid(bool kLoopSwitch = true ) ;
00054       bool Valid() ;
00055       bool Executable() ;
00056 
00057       bool LoadNodes( map< string , int > & aMapOfNodes ,
00058                       const GraphBase::ListOfSNodes &aNodes ) ;
00059       bool LoadLinks( map< string , int > & aMapOfNodes ,
00060                       const GraphBase::ListOfSLinks &aLinks ) ;
00061       bool LoadDatas( map< string , int > & aMapOfNodes ,
00062                       const GraphBase::ListOfSLinks &aDatas ) ;
00063 
00064 //      bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
00065       bool LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
00066                                               GraphBase::SLink aLink ,
00067                                               bool wdata ) const ;
00068 //      bool SaveXML(ostream &f ) ;QDomDocument & Graph 
00069       bool SaveXML( ostream & f , QDomDocument & Graph ,
00070                     bool aSuperGraph , QDomElement & supergraph ) ;
00071 
00072       bool LinkSavePY( ostream &f ,
00073                                              const char *aGraphName ,
00074                                              GraphBase::SLink aLink ,
00075                                              bool fromparam ,
00076                                              bool toparam ,
00077                                              bool wdata ) const;
00078       void DateModification() ;
00079 
00080       // asv 20.09.04 added from GraphExecutor::FiniteStateMachine class (removed from there)
00081 //      static map< string , GraphBase::Graph * > _MapOfGraphs ;
00082 //      static map< string , int >                _MapOfGraphNames ;
00083     
00084 //      GraphBase::Graph * MapGraph( const char * aGraphName ) ;
00085 //      bool MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) ;
00086 //      void EraseGraph( const char * aGraphName ) ;
00087 //      bool GraphName( const char * aGraphName ) ;
00088 //      string GraphInstanceName( const char * aGraphName ) ;
00089       // end added from FiniteStateMachine
00090 
00091 
00092     public:
00093 
00094       OutNode();
00095       OutNode( CORBA::ORB_ptr ORB,
00096                SALOME_NamingService* ptrNamingService ,
00097                const char *DataFlowName ,
00098                const char * DebugFileName ,
00099                const SUPERV::KindOfNode aKindOfNode );
00100       OutNode( CORBA::ORB_ptr ORB,
00101                SALOME_NamingService* ptrNamingService ,
00102                const SALOME_ModuleCatalog::Service& DataFlowService ,
00103                const char *DataFlowComponentName ,
00104                const char *DataFlowInterfaceName ,
00105                const char *DataFlowName ,
00106                const SUPERV::KindOfNode DataFlowkind ,
00107                const SUPERV::SDate DataFlowFirstCreation ,
00108                const SUPERV::SDate DataFlowLastModification ,
00109                const char * DataFlowEditorRelease ,
00110                const char * DataFlowAuthor ,
00111                const char * DataFlowComputer ,
00112                const char * DataFlowComment ,
00113                const char * DebugFileName ) ;
00114       virtual ~OutNode();
00115 
00116       bool Name( const char * aName ) ;
00117 
00118       void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
00119       GraphBase::StreamGraph * StreamGraph() {
00120                                return _StreamGraph ; } ;
00121       GraphBase::StreamGraph * StreamGraph() const {
00122                                return _StreamGraph ; } ;
00123       GraphBase::Graph * Graph() {
00124                          return _Graph ; } ;
00125       const GraphBase::Graph * Graph() const {
00126                                return _Graph ; } ;
00127 
00128       bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
00129       bool LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) ;
00130 //      bool LoadXml( const char* myFileName ) ;
00131       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
00132 
00133       bool SaveXml(const char* myFileName ) ;
00134 
00135       bool SavePy(const char* myFileName ) ;
00136       bool SavePY(ostream &f , bool importSuperV ) ;
00137 
00138 
00139 // get all DataFlow informations (for a .XML file) :
00140       GraphBase::ListOfSGraphs * GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) ;
00141 
00142 //    void DateModification() ;
00143 
00144       GraphEditor::InNode * AddNode(
00145                         const SALOME_ModuleCatalog::Service& NodeService ,
00146                         GraphBase::ListOfFuncName aFuncName ,
00147                         GraphBase::ListOfPythonFunctions aPythonFunction ,
00148                         const char* NodeComponentName ,
00149                         const char* NodeInterfaceName ,
00150                         const char* NodeName ,
00151                         const SUPERV::KindOfNode NodeKindOfNode ,
00152                         const SUPERV::SDate NodeFirstCreation ,
00153                         const SUPERV::SDate NodeLastModification ,
00154                         const char * NodeEditorRelease ,
00155                         const char * NodeAuthor ,
00156                         const char * NodeComputer ,
00157                         const char * NodeComment ,
00158                         const int NodeX ,
00159                         const int NodeY ) ;
00160       GraphEditor::InNode * GetNode( const char* NodeName ) {
00161                const GraphBase::Graph::ComputingNode * aNode = _Graph->GetGraphNode( NodeName ) ;
00162                if ( aNode ) {
00163                  return (GraphEditor::InNode * ) (aNode->GetInNode()) ;
00164                }
00165                else {
00166                  return (GraphEditor::InNode * ) NULL ;
00167                } } ;
00168       bool RemoveNode( const char* NodeName ) {
00169            DateModification() ;
00170            _Valid = false ;
00171            return _Graph->RemoveNode( NodeName ) ; } ;
00172       bool ReNameNode( const char* OldNodeName ,
00173                        const char* NewNodeName ) {
00174 //PAL9048 JR Debug : a node may not have the same name as the graph
00175            if ( strcmp( Graph()->Name() , NewNodeName ) ) {
00176              DateModification() ;
00177              _Valid = false ;
00178              return _Graph->ReNameNode( OldNodeName , NewNodeName ) ;
00179         }
00180            cdebug << "Editor::OutNode::ReNameNode ERROR "  << NewNodeName << " already exists"
00181                   << endl ;
00182            return false ; } ;
00183 
00184       void Coordinates( const int X , const int Y ) {
00185            return _Graph->Coordinates( X , Y ) ; } ;
00186       const int XCoordinate() {
00187            return _Graph->XCoordinate() ; } ;
00188       const int YCoordinate() {
00189            return _Graph->YCoordinate() ; } ;
00190       void Coordinates( const char* NodeName , const int X , const int Y ) ;
00191       const int XCoordinate( const char* NodeName ) ;
00192       const int YCoordinate( const char* NodeName ) ;
00193 
00194       const GraphBase::InPort *GetInPort( const char * InPortName ) {
00195             return _Graph->GetInPort( InPortName ) ; } ;
00196       const GraphBase::OutPort *GetOutPort( const char * OutPortName ) {
00197             return _Graph->GetOutPort( OutPortName ) ; } ;
00198       GraphBase::InPort *GetChangeInPort( const char * InPortName ) {
00199             return _Graph->GetChangeInPort( InPortName ) ; } ;
00200       GraphBase::OutPort *GetChangeOutPort( const char * OutPortName ) {
00201             return _Graph->GetChangeOutPort( OutPortName ) ; } ;
00202 
00203       bool HasInput(const char * ToServiceParameterName ) {
00204            return _Graph->HasInput( ToServiceParameterName ) ;
00205       }
00206 
00207       bool AddLink( const char* FromNodeName ,
00208                     const char* FromServiceParameterName ,
00209                  const char* ToNodeName ,
00210                     const char* ToServiceParameterName ) {
00211 //                    , const CORBA::Any aValue ) {
00212            DateModification() ;
00213            _Valid = false ;
00214            return _Graph->AddLink( FromNodeName , FromServiceParameterName ,
00215                                    ToNodeName , ToServiceParameterName ) ; } ;
00216 //                                   , aValue ) ; } ;
00217 
00218       bool RemoveLink( const char* FromNodeName ,
00219                        const char* FromServiceParameterName ,
00220                        const char* ToNodeName ,
00221                        const char* ToServiceParameterName ) {
00222            bool RetVal = _Graph->RemoveLink( FromNodeName ,
00223                                              FromServiceParameterName , 
00224                                              ToNodeName ,
00225                                              ToServiceParameterName ) ;
00226            if ( RetVal )
00227              DateModification() ;
00228            _Valid = false ;
00229            return RetVal ; } ;
00230 
00231       bool GetLink(const char* ToNodeName ,
00232                    const char* ToServiceParameterName ,
00233                    char** FromNodeName ,
00234                    char** FromServiceParameterName ) {
00235            return _Graph->GetLink( ToNodeName ,
00236                                    ToServiceParameterName ,
00237                                    FromNodeName ,
00238                           FromServiceParameterName ) ; } ;
00239 
00240       bool AddLinkCoord( const char* FromNodeName ,
00241                          const char* FromServiceParameterName ,
00242                          const char* ToNodeName ,
00243                          const char* ToServiceParameterName ,
00244                          const int nXY ,
00245                          const int* X ,
00246                          const int* Y ) ;
00247       bool AddLinkCoord( const char* FromNodeName ,
00248                          const char* FromServiceParameterName ,
00249                          const char* ToNodeName ,
00250                          const char* ToServiceParameterName ,
00251                          const int index ,
00252                          const int X ,
00253                          const int Y ) ;
00254       bool ChangeLinkCoord( const char* FromNodeName ,
00255                             const char* FromServiceParameterName ,
00256                             const char* ToNodeName ,
00257                             const char* ToServiceParameterName ,
00258                             const int index ,
00259                             const int X ,
00260                             const int Y ) ;
00261       bool RemoveLinkCoord( const char* FromNodeName ,
00262                             const char* FromServiceParameterName ,
00263                             const char* ToNodeName ,
00264                             const char* ToServiceParameterName ,
00265                             const int index ) ;
00266       int GetLinkCoordSize( const char* FromNodeName ,
00267                             const char* FromServiceParameterName ,
00268                             const char* ToNodeName ,
00269                             const char* ToServiceParameterName ) ;
00270       bool GetLinkCoord( const char* FromNodeName ,
00271                          const char* FromServiceParameterName ,
00272                          const char* ToNodeName ,
00273                          const char* ToServiceParameterName ,
00274                          int *X , int *Y ) ;
00275       bool GetLinkCoord( const char* FromNodeName ,
00276                          const char* FromServiceParameterName ,
00277                          const char* ToNodeName ,
00278                          const char* ToServiceParameterName ,
00279                          const int index , CORBA::Long &X , CORBA::Long &Y ) ;
00280 
00281 
00282 //      bool IsValid(bool kLoopSwitch = true ) {
00283       bool IsValid( ) {
00284            if ( !_Valid )
00285 //             Valid( kLoopSwitch ) ;
00286              Valid() ;
00287            return _Valid ; } ;
00288       bool IsNotValid() const {
00289            return !_Valid ; } ;
00290       bool UnValid() ;
00291 
00292       bool IsExecutable() {
00293            cdebug_in << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid
00294                      << " _Executable " << _Executable << endl;
00295            if ( !_Valid )
00296              Valid() ;
00297            if ( _Valid ) {
00298              if ( !_Executable )
00299                Executable() ;
00300         }
00301            else
00302              _Executable = false ;
00303            cdebug_out << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid
00304                       << " _Executable " << _Executable << endl ;
00305            return _Executable ; } ;
00306       bool IsNotExecutable() const {
00307            return !_Executable ; } ;
00308 
00309       // iterate through ALL links (OutPort-InPort pairs) and check if their types are 
00310       // compatible - IsCompatible(type1, type2).  
00311       // Returns true if all are compatible.   
00312       bool IsLinksCompatible();
00313 
00314       // Returns true if an out-port of type "OutPortType" can be bound with 
00315       // in-port of type "InPortType".  Called from IsLinksCompatible() and Link_Impl::IsValid().
00316       bool IsCompatible( const char* OutPortType, const char* InPortType ) const;
00317 
00318 //JR 30.03.2005      const CORBA::Any *GetInData( const char *ToNodeName ,
00319       const CORBA::Any GetInData( const char *ToNodeName ,
00320                                   const char *ToParameterName ) ;
00321 //JR 30.03.2005      const CORBA::Any *GetOutData( const char *FromNodeName ,
00322       const CORBA::Any GetOutData( const char *FromNodeName ,
00323                                    const char *FromParameterName ) ;
00324   } ;
00325 
00326 };
00327 
00328 ostream & operator << (ostream &,const GraphEditor::OutNode & G);
00329 ostream & operator << (ostream &,const SUPERV::SDate &);
00330 
00331 #endif
00332 
00333 
00334