-//=============================================================================
-// File : DataFlowBase_ComputingNode.hxx
-// Created : 2002
-// Author : Jean Rahuel, CEA
-// Project : SALOME
-// $Header:
-//=============================================================================
+// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : DataFlowBase_ComputingNode.hxx
+// Author : Jean Rahuel, CEA
+// Module : SUPERV
+// $Header:
-#ifndef _DATAFLOWBASE_NODE_HXX
-#define _DATAFLOWBASE_NODE_HXX
+#ifndef _DATAFLOWBASE_COMPUTINGNODE_HXX
+#define _DATAFLOWBASE_COMPUTINGNODE_HXX
-#include "DataFlowBase_PortsOfNode.hxx"
+#include "SALOME_NamingService.hxx"
+
+#include "DataFlowBase_StreamNode.hxx"
+
+class CNode_Impl ;
namespace GraphBase {
+ class Graph ;
+
class InLineNode ;
- class ComputingNode : public PortsOfNode {
+ class LoopNode ;
+ class EndOfLoopNode ;
+ class EndOfSwitchNode ;
+
+ class ComputingNode : public StreamNode {
private:
CORBA::ORB_ptr _ORB ;
SALOME_NamingService * _NamingService ;
- int * _Graph_prof_debug ;
- ostream * _Graph_fdebug ;
- SUPERV::CNode_var _Node ;
+//->StreamNode int * _Graph_prof_debug ;
+//->StreamNode ofstream * _Graph_fdebug ;
+ SUPERV::CNode_var _Node_var ;
+ CNode_Impl * _Node_Impl ;
void * _InNode ; // From GraphExecutor:: or GraphEditor::
bool _ObjInterface ;
pthread_t _ThreadNo ;
- char * _Name ;
- SUPERV::KindOfNode _Kind ;
+//->StreamNode char * _Name ;
+//->StreamNode SUPERV::KindOfNode _Kind ;
SUPERV::SDate _FirstCreation ;
SUPERV::SDate _LastModification ;
char * _EditorRelease ;
char * _Author ;
char * _Comment ;
- bool _HeadNode ;
- int _LevelNumber ;
- int _SubGraphNumber ;
+//->StreamNode bool _HeadNode ;
+//->StreamNode int _LevelNumber ;
+//->StreamNode int _SubGraphNumber ;
bool _GeneratedName ;
+//->StreamNode int _DataStreamInPortsNumber ;
+//->StreamNode int _DataStreamOutPortsNumber ;
+
int _ConnectedInPortsNumber ;
int _DecrConnectedInPortsNumber ;
// For generated NodeNames with ServiceName : number of Nodes using
// the same ServiceName. It is not the same Service if it belongs to
// a different Interface and/or a different Component ...
- map< string , int > _MapOfServiceNames ;
+//->StreamNode map< string , int > _MapOfServiceNames ;
// Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
- map< string , int > _MapOfLinkedNodes ;
- int _LinkedNodesSize ;
- vector<ComputingNode * > _LinkedNodes ;
- vector<int > _LinkedInPortsNumber ;
+//->StreamNode map< string , int > _MapOfLinkedNodes ;
+//->StreamNode int _LinkedNodesSize ;
+//->StreamNode vector<ComputingNode * > _LinkedNodes ;
+//->StreamNode vector<int > _LinkedInPortsNumber ;
protected:
ComputingNode( CORBA::ORB_ptr ORB ,
SALOME_NamingService* ptrNamingService ,
const char * DataFlowName ,
- int * Graph_prof_debug = NULL ,
- ostream * Graph_fdebug = NULL ) ;
+ const SUPERV::KindOfNode DataFlowkind ,
+ int * Graph_prof_debug ,
+ ofstream * Graph_fdebug ) ;
ComputingNode( CORBA::ORB_ptr ORB ,
SALOME_NamingService* ptrNamingService ,
const SALOME_ModuleCatalog::Service& NodeService ,
const long X ,
const long Y ,
int * Graph_prof_debug = NULL ,
- ostream * Graph_fdebug = NULL ) ;
+ ofstream * Graph_fdebug = NULL ) ;
virtual ~ComputingNode() ;
SALOME_NamingService * NamingService() const {
return _NamingService ; } ;
- SUPERV::CNode_var ObjRef() const { return _Node ; } ;
- void SetObjRef(SUPERV::CNode_var aNode) {
- _Node = aNode ; } ;
+ SUPERV::CNode_var ObjRef() const {
+// char * _NodeName ;
+// cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name()
+// << " " << endl ;
+// SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ;
+// if ( CORBA::is_nil( _NodeObjRef ) ) {
+// _NodeName = "NilRef" ;
+// }
+// else {
+// try {
+// _NodeName = _NodeObjRef->Name() ;
+// }
+// catch ( ... ) {
+// _NodeName = "Catch Error" ;
+// }
+// }
+// cdebug << _NodeName << " " << Name() << endl ;
+ return _Node_var ; } ;
+ void SetObjRef( SUPERV::CNode_var aNode_var ) {
+// char * _NodeName ;
+// if ( CORBA::is_nil( _Node ) ) {
+// _NodeName = "NilRef" ;
+// }
+// else {
+// _NodeName = _Node->Name() ;
+// }
+// cdebug << "ComputingNode::SetObjRef( " << _Node << " "
+// << _NodeName << " ) " << Name() << " --> " ;
+ _Node_var = aNode_var ;
+// cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ;
+ } ;
+
+ CNode_Impl * ObjImpl() const { return _Node_Impl ; } ;
+ void SetObjImpl( CNode_Impl * aNode_Impl ) {
+ _Node_Impl = aNode_Impl ; } ;
+
void InNode( void * anInNode ) {
// cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
_InNode = anInNode ; } ;
pthread_t ThreadNo() { return _ThreadNo ; } ;
void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
- char * Name() const { return my_strdup( _Name ) ; } ;
- const char *const * NamePtr() const { return &_Name ; } ;
- SUPERV::KindOfNode Kind() const {
- return _Kind; } ;
+//->StreamNode char * Name() const { return my_strdup( _Name ) ; } ;
+//->StreamNode const char *const * NamePtr() const { return &_Name ; } ;
// const SALOME_ModuleCatalog::Service * Service() const ;
SUPERV::SDate FirstCreation() const ;
SUPERV::SDate LastModification() const ;
- char* Author() const { return my_strdup( _Author ) ; } ;
- char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
- char * Comment() const { return my_strdup( _Comment ) ; } ;
+//JR 17.02.2005 Memory Leak char* Author() const { return my_strdup( _Author ) ; } ;
+ char* Author() const { return _Author ; } ;
+//JR 17.02.2005 Memory Leak char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
+ char* EditorRelease() const { return _EditorRelease ; } ;
+//JR 17.02.2005 Memory Leak char * Comment() const { return my_strdup( _Comment ) ; } ;
+ char * Comment() const { return _Comment ; } ;
int XCoordinate() const { return _X ; } ;
int YCoordinate() const { return _Y ; } ;
- bool Name( const char * aName ) ;
- bool Kind( SUPERV::KindOfNode aKind) ;
+//->StreamNode bool Name( const char * aName ) ;
// void Service( const SALOME_ModuleCatalog::Service aService ) ;
void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
void LastModification( const SUPERV::SDate aLastModification ) ;
GraphBase::SNode * GetInfo() ;
- 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::DataFlowNode ) ; } ;
- 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 ) ; } ;
- void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
- const bool IsHeadNode() const { return _HeadNode ; } ;
+// void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
+// const bool IsHeadNode() const { return _HeadNode ; } ;
bool RemovePorts( const char* aNodeName ) ;
+ void SetMacroPorts( GraphBase::Graph * aGraph ) ;
+ void UpdateMacroPorts( GraphBase::Graph * aGraph ) ;
+ void SetMacroDatas( GraphBase::Graph * aGraph , GraphBase::Graph * aGraphOfMacroGraph ) ;
+
+ void DelInPort( const char * InputParameterName ) ;
+ void DelOutPort( const char * OutputParameterName ) ;
+
InPort * AddInPort( const char * InputParameterName ,
- const char * InputParameterType ) ;
+ const char * InputParameterType ,
+ const SUPERV::KindOfPort aKindOfPort ,
+ int index = -1 ) ;
OutPort * AddOutPort( const char * OutputParameterName ,
- const char * OutputParameterType ) ;
-
- void AddLink( ComputingNode * aNode ) ;
- void RemoveLink( ComputingNode * aNode ) ;
- void ReNameLink( const char* OldNodeName ,
- const char* NewNodeName ) ;
-
- int GetServiceNameNumber( const char * name ) {
- int num = _MapOfServiceNames[ name ] ;
- if ( num == 0 ) {
- _MapOfServiceNames[ name ] = 1 ;
- }
- else {
- _MapOfServiceNames[ name ] = num + 1 ;
- }
- return _MapOfServiceNames[ name ] ; } ;
+ const char * OutputParameterType ,
+ const SUPERV::KindOfPort aKindOfPort ,
+ int index = -1 ) ;
+
+ void DelInDataStreamPort( const char * InputParameterName ) ;
+ void DelOutDataStreamPort( const char * OutputParameterName ) ;
+
+ InDataStreamPort * AddInDataStreamPort( const char * InputParameterName ,
+ const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
+ const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
+ const SUPERV::KindOfPort aKindOfPort ,
+ int index = -1 ) ;
+ OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName ,
+ const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
+ const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
+ const SUPERV::KindOfPort aKindOfPort ,
+ int index = -1 ) ;
+
+// ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ;
+
+ void AddLinkedNode( GraphBase::ComputingNode * ToNode ) {
+ GraphBase::StreamNode::AddLinkedNode( ToNode ) ;
+ cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
+ << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
+ << " + 1 Service " << ServiceName() << endl ;
+ ToNode->IncrConnectedInPortsNumber() ; } ;
+
+ bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ,
+ bool DoLinkedFromNode = true ) {
+ bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode , DoLinkedFromNode ) ;
+ if ( RetVal ) {
+ cdebug << "ComputingNode::RemoveLinkedNode to " << ToNode->Name() << " from "
+ << Name() << " ConnectedInPortsNumber "
+ << ToNode->ConnectedInPortsNumber() - 1 << endl ;
+ ToNode->DecrConnectedInPortsNumber() ;
+ }
+ return RetVal ; } ;
+
+ void ReNameLinkedNode( const char* OldNodeName ,
+ const char* NewNodeName ) {
+ GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ;
void IncrConnectedInPortsNumber() {
- cdebug << "IncrConnectedInPortsNumber " << Name() << " -> "
+ cdebug << "ComputingNode::IncrConnectedInPortsNumber " << Name() << " -> "
<< _ConnectedInPortsNumber+1 << endl ;
_ConnectedInPortsNumber++ ; } ;
void DecrConnectedInPortsNumber() {
}
return false ; } ;
- 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 ; } ;
- ComputingNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
- const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
-
- int Level() { return _LevelNumber ; } ;
- void Level( int LevelNumber ) {
- _LevelNumber = LevelNumber ; } ;
- int SubGraph() { return _SubGraphNumber ; } ;
- void SubGraph( int SubGraphNumber ) {
- _SubGraphNumber = SubGraphNumber ; } ;
+ bool CheckLoop(GraphBase::LoopNode * aLoopNode ,
+ GraphBase::EndOfLoopNode * anEndLoopNode ) const ;
+ bool CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
+ GraphBase::EndOfLoopNode * anEndLoopNode ) const ;
+ bool InitBranchOfSwitchDone( bool AllInit , GraphBase::EndOfSwitchNode * anEndSwitchNode ) ;
+ bool CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwitchNode ) ;
// const GraphBase::ListOfParameters * GetListOfParameters() const ;
+ const long CpuUsed() ;
+
bool SaveXML( QDomDocument & Graph , QDomElement & info ,
int X , int Y ) const {
ListOfFuncName aFuncNames ;
const GraphBase::ListOfPythonFunctions PythonFunctions ,
int X , int Y ) const ;
- void NodeInfo(ostrstream & s) const ;
+ void NodeInfo(ostream & s) const ;
void ListLinks(ostream &f ) const ;