1 // SUPERV GraphEditor : contains classes that permit edition of graphs
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowEditor_OutNode.hxx
27 #ifndef _DATAFLOWEDITOR_OUTNODE_HXX
28 #define _DATAFLOWEDITOR_OUTNODE_HXX
30 #include "DataFlowBase_StreamGraph.hxx"
32 #include "DataFlowEditor_InNode.hxx"
34 namespace GraphEditor {
36 class OutNode : public GraphBase::Base {
40 GraphBase::StreamGraph * _StreamGraph ;
41 GraphBase::Graph * _Graph ;
43 int _Graph_prof_debug ;
53 // bool Valid(bool kLoopSwitch = true ) ;
57 bool LoadNodes( map< string , int > & aMapOfNodes ,
58 const GraphBase::ListOfSNodes &aNodes ) ;
59 bool LoadLinks( map< string , int > & aMapOfNodes ,
60 const GraphBase::ListOfSLinks &aLinks ) ;
61 bool LoadDatas( map< string , int > & aMapOfNodes ,
62 const GraphBase::ListOfSLinks &aDatas ) ;
64 // bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
65 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
66 GraphBase::SLink aLink ,
68 // bool SaveXML(ostream &f ) ;QDomDocument & Graph
69 bool SaveXML( ostream & f , QDomDocument & Graph ,
70 bool aSuperGraph , QDomElement & supergraph ) ;
72 bool GraphEditor::OutNode::LinkSavePY( ostream &f ,
73 const char *aGraphName ,
74 GraphBase::SLink aLink ,
78 bool SavePY(ostream &f , bool importSuperV ) ;
80 void DateModification() ;
82 // asv 20.09.04 added from GraphExecutor::FiniteStateMachine class (removed from there)
83 // static map< string , GraphBase::Graph * > _MapOfGraphs ;
84 // static map< string , int > _MapOfGraphNames ;
86 // GraphBase::Graph * MapGraph( const char * aGraphName ) ;
87 // bool MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) ;
88 // void EraseGraph( const char * aGraphName ) ;
89 // bool GraphName( const char * aGraphName ) ;
90 // string GraphInstanceName( const char * aGraphName ) ;
91 // end added from FiniteStateMachine
97 OutNode( CORBA::ORB_ptr ORB,
98 SALOME_NamingService* ptrNamingService ,
99 const char *DataFlowName ,
100 const char * DebugFileName ,
101 const SUPERV::KindOfNode aKindOfNode );
102 OutNode( CORBA::ORB_ptr ORB,
103 SALOME_NamingService* ptrNamingService ,
104 const SALOME_ModuleCatalog::Service& DataFlowService ,
105 const char *DataFlowComponentName ,
106 const char *DataFlowInterfaceName ,
107 const char *DataFlowName ,
108 const SUPERV::KindOfNode DataFlowkind ,
109 const SUPERV::SDate DataFlowFirstCreation ,
110 const SUPERV::SDate DataFlowLastModification ,
111 const char * DataFlowEditorRelease ,
112 const char * DataFlowAuthor ,
113 const char * DataFlowComputer ,
114 const char * DataFlowComment ,
115 const char * DebugFileName ) ;
118 bool Name( const char * aName ) ;
120 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
121 GraphBase::StreamGraph * StreamGraph() {
122 return _StreamGraph ; } ;
123 GraphBase::StreamGraph * StreamGraph() const {
124 return _StreamGraph ; } ;
125 GraphBase::Graph * Graph() {
127 const GraphBase::Graph * Graph() const {
130 bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
131 bool LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) ;
132 // bool LoadXml( const char* myFileName ) ;
133 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
135 bool SaveXml(const char* myFileName ) ;
137 bool SavePy(const char* myFileName ) ;
139 // get all DataFlow informations (for a .XML file) :
140 GraphBase::ListOfSGraphs * GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) ;
142 // void DateModification() ;
144 GraphEditor::InNode * AddNode(
145 const SALOME_ModuleCatalog::Service& NodeService ,
146 GraphBase::ListOfFuncName aFuncName ,
147 GraphBase::ListOfPythonFunctions aPythonFunction ,
148 const char* NodeComponentName ,
149 const char* NodeInterfaceName ,
150 const char* NodeName ,
151 const SUPERV::KindOfNode NodeKindOfNode ,
152 const SUPERV::SDate NodeFirstCreation ,
153 const SUPERV::SDate NodeLastModification ,
154 const char * NodeEditorRelease ,
155 const char * NodeAuthor ,
156 const char * NodeComputer ,
157 const char * NodeComment ,
160 GraphEditor::InNode * GetNode( const char* NodeName ) {
161 const GraphBase::Graph::ComputingNode * aNode = _Graph->GetGraphNode( NodeName ) ;
163 return (GraphEditor::InNode * ) (aNode->GetInNode()) ;
166 return (GraphEditor::InNode * ) NULL ;
168 bool RemoveNode( const char* NodeName ) {
171 return _Graph->RemoveNode( NodeName ) ; } ;
172 bool ReNameNode( const char* OldNodeName ,
173 const char* NewNodeName ) {
174 //PAL9048 JR Debug : a node may not have the same name as the graph
175 if ( strcmp( Graph()->Name() , NewNodeName ) ) {
178 return _Graph->ReNameNode( OldNodeName , NewNodeName ) ;
180 cdebug << "Editor::OutNode::ReNameNode ERROR " << NewNodeName << " already exists"
184 void Coordinates( const int X , const int Y ) {
185 return _Graph->Coordinates( X , Y ) ; } ;
186 const int XCoordinate() {
187 return _Graph->XCoordinate() ; } ;
188 const int YCoordinate() {
189 return _Graph->YCoordinate() ; } ;
190 void Coordinates( const char* NodeName , const int X , const int Y ) ;
191 const int XCoordinate( const char* NodeName ) ;
192 const int YCoordinate( const char* NodeName ) ;
194 const GraphBase::InPort *GetInPort( const char * InPortName ) {
195 return _Graph->GetInPort( InPortName ) ; } ;
196 const GraphBase::OutPort *GetOutPort( const char * OutPortName ) {
197 return _Graph->GetOutPort( OutPortName ) ; } ;
198 GraphBase::InPort *GetChangeInPort( const char * InPortName ) {
199 return _Graph->GetChangeInPort( InPortName ) ; } ;
200 GraphBase::OutPort *GetChangeOutPort( const char * OutPortName ) {
201 return _Graph->GetChangeOutPort( OutPortName ) ; } ;
203 bool HasInput(const char * ToServiceParameterName ) {
204 return _Graph->HasInput( ToServiceParameterName ) ;
207 bool AddLink( const char* FromNodeName ,
208 const char* FromServiceParameterName ,
209 const char* ToNodeName ,
210 const char* ToServiceParameterName ) {
211 // , const CORBA::Any aValue ) {
214 return _Graph->AddLink( FromNodeName , FromServiceParameterName ,
215 ToNodeName , ToServiceParameterName ) ; } ;
218 bool RemoveLink( const char* FromNodeName ,
219 const char* FromServiceParameterName ,
220 const char* ToNodeName ,
221 const char* ToServiceParameterName ) {
222 bool RetVal = _Graph->RemoveLink( FromNodeName ,
223 FromServiceParameterName ,
225 ToServiceParameterName ) ;
231 bool GetLink(const char* ToNodeName ,
232 const char* ToServiceParameterName ,
233 char** FromNodeName ,
234 char** FromServiceParameterName ) {
235 return _Graph->GetLink( ToNodeName ,
236 ToServiceParameterName ,
238 FromServiceParameterName ) ; } ;
240 bool AddLinkCoord( const char* FromNodeName ,
241 const char* FromServiceParameterName ,
242 const char* ToNodeName ,
243 const char* ToServiceParameterName ,
247 bool AddLinkCoord( const char* FromNodeName ,
248 const char* FromServiceParameterName ,
249 const char* ToNodeName ,
250 const char* ToServiceParameterName ,
254 bool ChangeLinkCoord( const char* FromNodeName ,
255 const char* FromServiceParameterName ,
256 const char* ToNodeName ,
257 const char* ToServiceParameterName ,
261 bool RemoveLinkCoord( const char* FromNodeName ,
262 const char* FromServiceParameterName ,
263 const char* ToNodeName ,
264 const char* ToServiceParameterName ,
266 int GetLinkCoordSize( const char* FromNodeName ,
267 const char* FromServiceParameterName ,
268 const char* ToNodeName ,
269 const char* ToServiceParameterName ) ;
270 bool GetLinkCoord( const char* FromNodeName ,
271 const char* FromServiceParameterName ,
272 const char* ToNodeName ,
273 const char* ToServiceParameterName ,
275 bool GetLinkCoord( const char* FromNodeName ,
276 const char* FromServiceParameterName ,
277 const char* ToNodeName ,
278 const char* ToServiceParameterName ,
279 const int index , long &X , long &Y ) ;
282 // bool IsValid(bool kLoopSwitch = true ) {
285 // Valid( kLoopSwitch ) ;
288 bool IsNotValid() const {
292 bool IsExecutable() {
293 cdebug_in << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid
294 << " _Executable " << _Executable << endl;
302 _Executable = false ;
303 cdebug_out << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid
304 << " _Executable " << _Executable << endl ;
305 return _Executable ; } ;
306 bool IsNotExecutable() const {
307 return !_Executable ; } ;
309 // iterate through ALL links (OutPort-InPort pairs) and check if their types are
310 // compatible - IsCompatible(type1, type2).
311 // Returns true if all are compatible.
312 bool IsLinksCompatible();
314 // Returns true if an out-port of type "OutPortType" can be bound with
315 // in-port of type "InPortType". Called from IsLinksCompatible() and Link_Impl::IsValid().
316 bool IsCompatible( const char* OutPortType, const char* InPortType ) const;
318 //JR 30.03.2005 const CORBA::Any *GetInData( const char *ToNodeName ,
319 const CORBA::Any GetInData( const char *ToNodeName ,
320 const char *ToParameterName ) ;
321 //JR 30.03.2005 const CORBA::Any *GetOutData( const char *FromNodeName ,
322 const CORBA::Any GetOutData( const char *FromNodeName ,
323 const char *FromParameterName ) ;
328 ostream & operator << (ostream &,const GraphEditor::OutNode & G);
329 ostream & operator << (ostream &,const SUPERV::SDate &);