Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / hmi / commandsProc.hxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef _COMMANDSPROC_HXX_
20 #define _COMMANDSPROC_HXX_
21
22 #include "commands.hxx"
23
24 #include <list>
25 #include <stack>
26 #include <string>
27 #include <map>
28
29 namespace YACS
30 {
31   namespace ENGINE
32   {
33     class Proc;
34     class Node;
35     class TypeCode;
36     class Catalog;
37     class DataPort;
38     class InputPort;
39     class OutputPort;
40     class InputDataStreamPort;
41     class OutputDataStreamPort;
42     class Container;
43     class ComponentInstance;
44   }
45
46   namespace HMI
47   {
48
49     typedef enum
50       {
51         SALOMEPROC,
52         BLOC,
53         FOREACHLOOP,
54         OPTIMIZERLOOP,
55         FORLOOP,
56         WHILELOOP,
57         SWITCH,
58         PYTHONNODE,
59         PYFUNCNODE,
60         CORBANODE,
61         SALOMENODE,
62         CPPNODE,
63         SALOMEPYTHONNODE,
64         XMLNODE,
65         SPLITTERNODE,
66         DFTODSFORLOOPNODE,
67         DSTODFFORLOOPNODE,
68         PRESETNODE,
69         OUTNODE,
70         STUDYINNODE,
71         STUDYOUTNODE,
72         INPUTPORT,
73         OUTPUTPORT,
74         INPUTDATASTREAMPORT,
75         OUTPUTDATASTREAMPORT,
76         DATALINK,
77         CONTROLLINK,
78         CONTAINER,
79         COMPONENT,
80         REFERENCE,
81         DATATYPE,
82         UNKNOWN
83       } TypeOfElem;
84    
85     class ProcInvoc: public Invocator
86     {
87     public:
88       ProcInvoc();
89       static TypeOfElem getTypeOfNode(YACS::ENGINE::Node* node);
90       static TypeOfElem getTypeOfPort(YACS::ENGINE::DataPort* port);
91       static std::string getTypeName(TypeOfElem type);
92     protected:
93       static std::map<int, std::string> _typeNameMap;
94     };
95     
96
97     class CommandAddNodeFromCatalog: public Command
98     {
99     public:
100       CommandAddNodeFromCatalog(YACS::ENGINE::Catalog *catalog,
101                                 std::string compo,
102                                 std::string type,
103                                 std::string position,
104                                 std::string name,
105                                 int swCase =0);
106       YACS::ENGINE::Node *getNode();
107     protected:
108       virtual bool localExecute();
109       virtual bool localReverse();
110       YACS::ENGINE::Catalog* _catalog;
111       YACS::ENGINE::Node *_nodeToClone;
112       TypeOfElem  _typeNode;
113       std::string _compoName;
114       std::string _typeName;
115       std::string _position;
116       std::string _name;
117       int _swCase;
118       YACS::ENGINE::Node *_node;
119     };
120
121     class CommandReparentNode: public Command
122     {
123     public:
124       CommandReparentNode(std::string position,
125                           std::string newParent);
126     protected:
127       virtual bool localExecute();
128       virtual bool localReverse();
129       std::string _position;
130       std::string _newParent;
131     };
132
133     class CommandCopyNode: public Command
134     {
135     public:
136       CommandCopyNode(std::string position,
137                       std::string newParent);
138       YACS::ENGINE::Node *getNode();
139     protected:
140       virtual bool localExecute();
141       virtual bool localReverse();
142       std::string _position;
143       std::string _newParent;
144       YACS::ENGINE::Node *_clone;
145     };
146
147     class CommandRenameNode: public Command
148     {
149     public:
150       CommandRenameNode(std::string position, std::string name);
151     protected:
152       virtual bool localExecute();
153       virtual bool localReverse();
154       std::string _position;
155       std::string _name;
156     };
157
158     class CommandRenameContainer: public Command
159     {
160     public:
161       CommandRenameContainer(std::string oldName, std::string newName);
162     protected:
163       virtual bool localExecute();
164       virtual bool localReverse();
165       std::string _oldName;
166       std::string _newName;
167     };
168
169     class CommandRenameInDataPort: public Command
170     {
171     public:
172       CommandRenameInDataPort(std::string position,
173                               std::string oldName,
174                               std::string newName);
175     protected:
176       virtual bool localExecute();
177       virtual bool localReverse();
178       std::string _position;
179       std::string _oldName;
180       std::string _newName;
181     };
182
183     class CommandRenameOutDataPort: public Command
184     {
185     public:
186       CommandRenameOutDataPort(std::string position,
187                                std::string oldName,
188                                std::string newName);
189     protected:
190       virtual bool localExecute();
191       virtual bool localReverse();
192       std::string _position;
193       std::string _oldName;
194       std::string _newName;
195     };
196
197     class CommandAddDataTypeFromCatalog: public Command
198     {
199     public:
200       CommandAddDataTypeFromCatalog(YACS::ENGINE::Catalog* catalog,
201                                     std::string typeName);
202       YACS::ENGINE::TypeCode *getTypeCode();
203     protected:
204       virtual bool localExecute();
205       virtual bool localReverse();
206       YACS::ENGINE::Catalog* _catalog;
207       std::string _typeName;
208     };
209
210     class CommandAddInputPortFromCatalog: public Command
211     {
212     public:
213       CommandAddInputPortFromCatalog(YACS::ENGINE::Catalog *catalog,
214                                      std::string type,
215                                      std::string node,
216                                      std::string name);
217       YACS::ENGINE::InputPort *getInputPort();
218     protected:
219       virtual bool localExecute();
220       virtual bool localReverse();
221       YACS::ENGINE::Catalog* _catalog;
222       std::string _typePort;
223       std::string _node;
224       std::string _name;
225       YACS::ENGINE::InputPort *_inputPort;
226     };
227
228     class CommandAddOutputPortFromCatalog: public Command
229     {
230     public:
231       CommandAddOutputPortFromCatalog(YACS::ENGINE::Catalog *catalog,
232                                       std::string type,
233                                       std::string node,
234                                       std::string name);
235       YACS::ENGINE::OutputPort *getOutputPort();
236     protected:
237       virtual bool localExecute();
238       virtual bool localReverse();
239       YACS::ENGINE::Catalog* _catalog;
240       std::string _typePort;
241       std::string _node;
242       std::string _name;
243       YACS::ENGINE::OutputPort *_outputPort;
244     };
245
246     class CommandAddIDSPortFromCatalog: public Command
247     {
248     public:
249       CommandAddIDSPortFromCatalog(YACS::ENGINE::Catalog *catalog,
250                                    std::string type,
251                                    std::string node,
252                                    std::string name);
253       YACS::ENGINE::InputDataStreamPort *getIDSPort();
254     protected:
255       virtual bool localExecute();
256       virtual bool localReverse();
257       YACS::ENGINE::Catalog* _catalog;
258       std::string _typePort;
259       std::string _node;
260       std::string _name;
261       YACS::ENGINE::InputDataStreamPort *_IDSPort;
262     };
263
264     class CommandAddODSPortFromCatalog: public Command
265     {
266     public:
267       CommandAddODSPortFromCatalog(YACS::ENGINE::Catalog *catalog,
268                                    std::string type,
269                                    std::string node,
270                                    std::string name);
271       YACS::ENGINE::OutputDataStreamPort *getODSPort();
272     protected:
273       virtual bool localExecute();
274       virtual bool localReverse();
275       YACS::ENGINE::Catalog* _catalog;
276       std::string _typePort;
277       std::string _node;
278       std::string _name;
279       YACS::ENGINE::OutputDataStreamPort *_ODSPort;
280     };
281
282     class CommandOrderInputPorts: public Command
283     {
284     public:
285       CommandOrderInputPorts(std::string node,
286                              std::string port,
287                              int isUp);
288       int getRank() {return _rank; };
289     protected:
290       virtual bool localExecute();
291       virtual bool localReverse();
292       std::string _node;
293       std::string _port;
294       int _isUp;
295       int _rank;
296     };
297
298     class CommandOrderOutputPorts: public Command
299     {
300     public:
301       CommandOrderOutputPorts(std::string node,
302                               std::string port,
303                               int isUp);
304       int getRank() {return _rank; };
305     protected:
306       virtual bool localExecute();
307       virtual bool localReverse();
308       std::string _node;
309       std::string _port;
310       int _isUp;
311       int _rank;
312     };
313
314     class CommandSetInPortValue: public Command
315     {
316     public:
317       CommandSetInPortValue(std::string node,
318                             std::string port,
319                             std::string value);
320     protected:
321       virtual bool localExecute();
322       virtual bool localReverse();
323       std::string _node;
324       std::string _port;
325       std::string _value;
326     };
327
328     class CommandSetOutPortValue: public Command
329     {
330     public:
331       CommandSetOutPortValue(std::string node,
332                              std::string port,
333                              std::string value);
334     protected:
335       virtual bool localExecute();
336       virtual bool localReverse();
337       std::string _node;
338       std::string _port;
339       std::string _value;
340     };
341
342     class CommandSetSwitchSelect: public Command
343     {
344     public:
345       CommandSetSwitchSelect(std::string aSwitch,
346                              std::string value);
347     protected:
348       virtual bool localExecute();
349       virtual bool localReverse();
350       std::string _switch;
351       std::string _value;
352     };
353
354     class CommandSetSwitchCase: public Command
355     {
356     public:
357       CommandSetSwitchCase(std::string aSwitch,
358                            std::string node,
359                            std::string value);
360     protected:
361       virtual bool localExecute();
362       virtual bool localReverse();
363       std::string _switch;
364       std::string _node;
365       std::string _value;
366     };
367
368     class CommandSetForLoopSteps: public Command
369     {
370     public:
371       CommandSetForLoopSteps(std::string forLoop,
372                              std::string value);
373     protected:
374       virtual bool localExecute();
375       virtual bool localReverse();
376       std::string _forLoop;
377       std::string _value;
378     };
379
380     class CommandSetWhileCondition: public Command
381     {
382     public:
383       CommandSetWhileCondition(std::string whileLoop,
384                                std::string value);
385     protected:
386       virtual bool localExecute();
387       virtual bool localReverse();
388       std::string _whileLoop;
389       std::string _value;
390     };
391
392     class CommandSetForEachBranch: public Command
393     {
394     public:
395       CommandSetForEachBranch(std::string forEach,
396                               std::string value);
397     protected:
398       virtual bool localExecute();
399       virtual bool localReverse();
400       std::string _forEach;
401       std::string _value;
402     };
403
404     class CommandAddLink: public Command
405     {
406     public:
407       CommandAddLink(std::string outNode, std::string outPort,
408                      std::string inNode, std::string inPort,bool control=true);
409     protected:
410       virtual bool localExecute();
411       virtual bool localReverse();
412       std::string _outNode;
413       std::string _outPort;
414       std::string _inNode;
415       std::string _inPort;
416       bool _control;
417     };
418
419     class CommandAddControlLink: public Command
420     {
421     public:
422       CommandAddControlLink(std::string outNode, std::string inNode);
423     protected:
424       virtual bool localExecute();
425       virtual bool localReverse();
426       std::string _outNode;
427       std::string _inNode;
428     };
429
430     class CommandAddContainer: public Command
431     {
432     public:
433       CommandAddContainer(std::string name,
434                           std::string refContainer ="");
435       virtual YACS::ENGINE::Container* getContainer();
436     protected:
437       virtual bool localExecute();
438       virtual bool localReverse();
439       std::string _name;
440       std::string _containerToClone;
441       YACS::ENGINE::Container* _container;
442     };
443
444     class CommandSetContainerProperties: public Command
445     {
446     public:
447       CommandSetContainerProperties(std::string container,
448                                     std::map<std::string,std::string> properties);
449     protected:
450       virtual bool localExecute();
451       virtual bool localReverse();
452       std::string _container;
453       std::map<std::string,std::string> _properties;
454     };
455
456     class CommandSetDSPortProperties: public Command
457     {
458     public:
459       CommandSetDSPortProperties(std::string node, std::string port, bool isInport,
460                                  std::map<std::string,std::string> properties);
461     protected:
462       virtual bool localExecute();
463       virtual bool localReverse();
464       std::string _nodeName;
465       std::string _portName;
466       bool _isInport;
467       std::map<std::string,std::string> _properties;
468     };
469
470     class CommandSetFuncNodeFunctionName: public Command
471     {
472     public:
473       CommandSetFuncNodeFunctionName(std::string node, std::string funcName);
474     protected:
475       virtual bool localExecute();
476       virtual bool localReverse();
477       std::string _nodeName;
478       std::string _funcName;
479     };
480
481     class CommandSetInlineNodeScript: public Command
482     {
483     public:
484       CommandSetInlineNodeScript(std::string node, std::string script);
485     protected:
486       virtual bool localExecute();
487       virtual bool localReverse();
488       std::string _nodeName;
489       std::string _script;
490     };
491
492     class CommandAddComponentInstance: public Command
493     {
494     public:
495       CommandAddComponentInstance(std::string compoName);
496       virtual YACS::ENGINE::ComponentInstance* getComponentInstance();
497     protected:
498       virtual bool localExecute();
499       virtual bool localReverse();
500       std::string _compoName;
501       YACS::ENGINE::ComponentInstance *_compoInst;
502     };
503
504     class CommandAssociateComponentToContainer: public Command
505     {
506     public:
507       CommandAssociateComponentToContainer(std::pair<std::string,int> key,
508                                            std::string container);
509     protected:
510       virtual bool localExecute();
511       virtual bool localReverse();
512       std::pair<std::string,int>  _key;
513       std::string _container;
514     };
515
516     class CommandAssociateServiceToComponent: public Command
517     {
518     public:
519       CommandAssociateServiceToComponent(std::string service,
520                                          std::pair<std::string,int> key);
521     protected:
522       virtual bool localExecute();
523       virtual bool localReverse();
524       std::string _service;
525       std::pair<std::string,int>  _key;
526     };
527
528     class Subject;
529     class CommandDestroy: public Command
530     {
531     public:
532       CommandDestroy(std::string position, Subject* subject);
533     protected:
534       virtual bool localExecute();
535       virtual bool localReverse();
536     protected:
537       std::string _position;
538       Subject* _subject;
539     };
540
541   }
542 }
543 #endif