]> SALOME platform Git repositories - modules/yacs.git/blob - src/hmi/commandsProc.hxx
Salome HOME
Update copyrights 2014.
[modules/yacs.git] / src / hmi / commandsProc.hxx
1 // Copyright (C) 2006-2014  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, or (at your option) any later version.
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
20 #ifndef _COMMANDSPROC_HXX_
21 #define _COMMANDSPROC_HXX_
22
23 #include "HMIExport.hxx"
24 #include "commands.hxx"
25
26 #include <list>
27 #include <stack>
28 #include <string>
29 #include <map>
30
31 namespace YACS
32 {
33   namespace ENGINE
34   {
35     class Proc;
36     class Node;
37     class TypeCode;
38     class Catalog;
39     class DataPort;
40     class InputPort;
41     class OutputPort;
42     class InputDataStreamPort;
43     class OutputDataStreamPort;
44     class Container;
45     class ComponentInstance;
46   }
47
48   namespace HMI
49   {
50     class SubjectNode;
51     class SubjectInputPort;
52     class SubjectOutputPort;
53     class SubjectInputDataStreamPort;
54     class SubjectOutputDataStreamPort;
55     class SubjectLink;
56     class SubjectControlLink;
57     class SubjectContainer;
58     class SubjectComponent;
59
60     typedef enum
61       {
62         SALOMEPROC,
63         BLOC,
64         FOREACHLOOP,
65         OPTIMIZERLOOP,
66         FORLOOP,
67         WHILELOOP,
68         SWITCH,
69         PYTHONNODE,
70         PYFUNCNODE,
71         CORBANODE,
72         SALOMENODE,
73         CPPNODE,
74         SALOMEPYTHONNODE,
75         XMLNODE,
76         SPLITTERNODE,
77         DFTODSFORLOOPNODE,
78         DSTODFFORLOOPNODE,
79         PRESETNODE,
80         OUTNODE,
81         STUDYINNODE,
82         STUDYOUTNODE,
83         INPUTPORT,
84         OUTPUTPORT,
85         INPUTDATASTREAMPORT,
86         OUTPUTDATASTREAMPORT,
87         DATALINK,
88         CONTROLLINK,
89         CONTAINER,
90         COMPONENT,
91         REFERENCE,
92         DATATYPE,
93         UNKNOWN
94       } TypeOfElem;
95    
96     class HMI_EXPORT ProcInvoc: public Invocator
97     {
98     public:
99       ProcInvoc();
100       static TypeOfElem getTypeOfNode(YACS::ENGINE::Node* node);
101       static TypeOfElem getTypeOfPort(YACS::ENGINE::DataPort* port);
102       static std::string getTypeName(TypeOfElem type);
103     protected:
104       static std::map<int, std::string> _typeNameMap;
105     };
106     
107
108     class CommandAddNodeFromCatalog: public Command
109     {
110     public:
111       CommandAddNodeFromCatalog(YACS::ENGINE::Catalog *catalog,
112                                 std::string compo,
113                                 std::string type,
114                                 std::string position,
115                                 std::string name,
116                                 bool newCompoInst=true,
117                                 int swCase =0);
118       YACS::ENGINE::Node *getNode();
119       YACS::HMI::SubjectNode *getSubjectNode();
120     protected:
121       virtual bool localExecute();
122       virtual bool localReverse();
123       virtual std::string dump();
124       YACS::ENGINE::Catalog* _catalog;
125       TypeOfElem  _typeNode;
126       std::string _compoName;
127       std::string _typeName;
128       std::string _position;
129       std::string _name;
130       bool _newCompoInst;
131       int _swCase;
132       YACS::ENGINE::Node *_node;
133       YACS::HMI::SubjectNode *_snode;
134     };
135
136     class CommandReparentNode: public Command
137     {
138     public:
139       CommandReparentNode(std::string position,
140                           std::string newParent);
141     protected:
142       virtual bool localExecute();
143       virtual bool localReverse();
144       virtual std::string dump();
145       std::string _position;
146       std::string _newParent;
147       std::string _oldParent;
148       std::string _newpos;
149     };
150
151     class CommandPutInComposedNode: public Command
152     {
153     public:
154       CommandPutInComposedNode(std::string position,
155                                std::string newParent,
156                                std::string type,
157                                bool toSaveRestoreLinks=true);
158     protected:
159       virtual bool localExecute();
160       virtual bool localReverse();
161       virtual std::string dump();
162       std::string _position;
163       std::string _newParent;
164       std::string _type;
165       std::string _newpos;
166       bool _toSaveRestoreLinks;
167     };
168
169     class CommandCopyNode: public Command
170     {
171     public:
172       CommandCopyNode(YACS::ENGINE::Proc* fromproc,
173                       std::string position,
174                       std::string newParent,
175                       int acase=0);
176       YACS::ENGINE::Node *getNode();
177     protected:
178       virtual bool localExecute();
179       virtual bool localReverse();
180       virtual std::string dump();
181       std::string _position;
182       std::string _newParent;
183       std::string _newName;
184       int         _case;
185       YACS::ENGINE::Node *_clone;
186       YACS::ENGINE::Proc *_fromproc;
187     };
188
189     class CommandRenameNode: public Command
190     {
191     public:
192       CommandRenameNode(std::string position, std::string name);
193     protected:
194       virtual bool localExecute();
195       virtual bool localReverse();
196       virtual std::string dump();
197       std::string _position;
198       std::string _name;
199       std::string _oldName;
200       std::string _newpos;
201     };
202
203     class CommandRenameContainer: public Command
204     {
205     public:
206       CommandRenameContainer(std::string oldName, std::string newName);
207     protected:
208       virtual bool localExecute();
209       virtual bool localReverse();
210       virtual std::string dump();
211       std::string _oldName;
212       std::string _newName;
213     };
214
215     class CommandRenameInDataPort: public Command
216     {
217     public:
218       CommandRenameInDataPort(std::string position,
219                               std::string oldName,
220                               std::string newName, TypeOfElem portType);
221     protected:
222       virtual bool localExecute();
223       virtual bool localReverse();
224       virtual std::string dump();
225       std::string _position;
226       std::string _oldName;
227       std::string _newName;
228       TypeOfElem _portType;
229     };
230
231     class CommandRenameOutDataPort: public Command
232     {
233     public:
234       CommandRenameOutDataPort(std::string position,
235                                std::string oldName,
236                                std::string newName, TypeOfElem portType);
237     protected:
238       virtual bool localExecute();
239       virtual bool localReverse();
240       virtual std::string dump();
241       std::string _position;
242       std::string _oldName;
243       std::string _newName;
244       TypeOfElem _portType;
245     };
246
247     class CommandAddDataTypeFromCatalog: public Command
248     {
249     public:
250       CommandAddDataTypeFromCatalog(YACS::ENGINE::Catalog* catalog,
251                                     std::string typeName);
252       YACS::ENGINE::TypeCode *getTypeCode();
253     protected:
254       virtual bool localExecute();
255       virtual bool localReverse();
256       virtual std::string dump();
257       YACS::ENGINE::Catalog* _catalog;
258       std::string _typeName;
259     };
260
261     class CommandAddInputPortFromCatalog: public Command
262     {
263     public:
264       CommandAddInputPortFromCatalog(YACS::ENGINE::Catalog *catalog,
265                                      std::string type,
266                                      std::string node,
267                                      std::string name);
268       YACS::ENGINE::InputPort *getInputPort();
269       SubjectInputPort* getSubjectInputPort();
270     protected:
271       virtual bool localExecute();
272       virtual bool localReverse();
273       virtual std::string dump();
274       YACS::ENGINE::Catalog* _catalog;
275       std::string _typePort;
276       std::string _node;
277       std::string _name;
278       YACS::ENGINE::InputPort *_inputPort;
279       SubjectInputPort* _sip;
280     };
281
282     class CommandAddOutputPortFromCatalog: public Command
283     {
284     public:
285       CommandAddOutputPortFromCatalog(YACS::ENGINE::Catalog *catalog,
286                                       std::string type,
287                                       std::string node,
288                                       std::string name);
289       YACS::ENGINE::OutputPort *getOutputPort();
290       SubjectOutputPort* getSubjectOutputPort();
291     protected:
292       virtual bool localExecute();
293       virtual bool localReverse();
294       virtual std::string dump();
295       YACS::ENGINE::Catalog* _catalog;
296       std::string _typePort;
297       std::string _node;
298       std::string _name;
299       YACS::ENGINE::OutputPort *_outputPort;
300       SubjectOutputPort* _sop;
301     };
302
303     class CommandAddIDSPortFromCatalog: public Command
304     {
305     public:
306       CommandAddIDSPortFromCatalog(YACS::ENGINE::Catalog *catalog,
307                                    std::string type,
308                                    std::string node,
309                                    std::string name);
310       YACS::ENGINE::InputDataStreamPort *getIDSPort();
311       SubjectInputDataStreamPort* getSubjectIDSPort();
312     protected:
313       virtual bool localExecute();
314       virtual bool localReverse();
315       virtual std::string dump();
316       YACS::ENGINE::Catalog* _catalog;
317       std::string _typePort;
318       std::string _node;
319       std::string _name;
320       YACS::ENGINE::InputDataStreamPort *_IDSPort;
321       SubjectInputDataStreamPort* _sip;
322     };
323
324     class CommandAddODSPortFromCatalog: public Command
325     {
326     public:
327       CommandAddODSPortFromCatalog(YACS::ENGINE::Catalog *catalog,
328                                    std::string type,
329                                    std::string node,
330                                    std::string name);
331       YACS::ENGINE::OutputDataStreamPort *getODSPort();
332       SubjectOutputDataStreamPort* getSubjectODSPort();
333     protected:
334       virtual bool localExecute();
335       virtual bool localReverse();
336       virtual std::string dump();
337       YACS::ENGINE::Catalog* _catalog;
338       std::string _typePort;
339       std::string _node;
340       std::string _name;
341       YACS::ENGINE::OutputDataStreamPort *_ODSPort;
342       SubjectOutputDataStreamPort* _sop;
343     };
344
345     class CommandOrderInputPorts: public Command
346     {
347     public:
348       CommandOrderInputPorts(std::string node,
349                              std::string port,
350                              int isUp);
351       int getRank() {return _rank; };
352     protected:
353       virtual bool localExecute();
354       virtual bool localReverse();
355       virtual std::string dump();
356       std::string _node;
357       std::string _port;
358       int _isUp;
359       int _rank;
360     };
361
362     class CommandOrderOutputPorts: public Command
363     {
364     public:
365       CommandOrderOutputPorts(std::string node,
366                               std::string port,
367                               int isUp);
368       int getRank() {return _rank; };
369     protected:
370       virtual bool localExecute();
371       virtual bool localReverse();
372       virtual std::string dump();
373       std::string _node;
374       std::string _port;
375       int _isUp;
376       int _rank;
377     };
378
379     class CommandSetInPortValue: public Command
380     {
381     public:
382       CommandSetInPortValue(std::string node,
383                             std::string port,
384                             std::string value);
385     protected:
386       virtual bool localExecute();
387       virtual bool localReverse();
388       virtual std::string dump();
389       std::string _node;
390       std::string _port;
391       std::string _value;
392       std::string _oldValue;
393     };
394
395     class CommandSetOutPortValue: public Command
396     {
397     public:
398       CommandSetOutPortValue(std::string node,
399                              std::string port,
400                              std::string value);
401     protected:
402       virtual bool localExecute();
403       virtual bool localReverse();
404       virtual std::string dump();
405       std::string _node;
406       std::string _port;
407       std::string _value;
408       std::string _oldValue;
409     };
410
411     class CommandSetSwitchSelect: public Command
412     {
413     public:
414       CommandSetSwitchSelect(std::string aSwitch,
415                              std::string value);
416     protected:
417       virtual bool localExecute();
418       virtual bool localReverse();
419       virtual std::string dump();
420       std::string _switch;
421       std::string _value;
422       std::string _oldValue;
423     };
424
425     class CommandSetSwitchCase: public Command
426     {
427     public:
428       CommandSetSwitchCase(std::string aSwitch,
429                            std::string node,
430                            std::string value);
431     protected:
432       virtual bool localExecute();
433       virtual bool localReverse();
434       virtual std::string dump();
435       std::string _switch;
436       std::string _node;
437       std::string _oldNode;
438       std::string _value;
439       int _oldValue;
440     };
441
442     class CommandSetForLoopSteps: public Command
443     {
444     public:
445       CommandSetForLoopSteps(std::string forLoop,
446                              std::string value);
447     protected:
448       virtual bool localExecute();
449       virtual bool localReverse();
450       virtual std::string dump();
451       std::string _forLoop;
452       std::string _value;
453       int _oldValue;
454     };
455
456     class CommandSetWhileCondition: public Command
457     {
458     public:
459       CommandSetWhileCondition(std::string whileLoop,
460                                std::string value);
461     protected:
462       virtual bool localExecute();
463       virtual bool localReverse();
464       virtual std::string dump();
465       std::string _whileLoop;
466       std::string _value;
467       bool _oldValue;
468     };
469
470     class CommandSetForEachBranch: public Command
471     {
472     public:
473       CommandSetForEachBranch(std::string forEach,
474                               std::string value);
475     protected:
476       virtual bool localExecute();
477       virtual bool localReverse();
478       virtual std::string dump();
479       std::string _forEach;
480       std::string _value;
481       int _oldValue;
482     };
483
484     class CommandSetAlgo: public Command
485     {
486     public:
487       CommandSetAlgo(std::string optimizer, std::string alglib, std::string symbol);
488     protected:
489       virtual bool localExecute();
490       virtual bool localReverse();
491       virtual std::string dump();
492       std::string _optimizer;
493       std::string _alglib;
494       std::string _symbol;
495       std::string _oldAlglib;
496       std::string _oldSymbol;
497     };
498
499     class CommandAddLink: public Command
500     {
501     public:
502       CommandAddLink(std::string outNode, std::string outPort, TypeOfElem outPortType,
503                      std::string inNode, std::string inPort, TypeOfElem inPortType, bool control=true);
504     protected:
505       virtual bool localExecute();
506       virtual bool localReverse();
507       virtual std::string dump();
508       std::string _outNode;
509       std::string _outPort;
510       TypeOfElem _outPortType;
511       std::string _inNode;
512       std::string _inPort;
513       TypeOfElem _inPortType;
514       bool _control;
515       bool _controlCreatedWithDF;
516     };
517
518     class CommandAddControlLink: public Command
519     {
520     public:
521       CommandAddControlLink(std::string outNode, std::string inNode);
522     protected:
523       virtual bool localExecute();
524       virtual bool localReverse();
525       virtual std::string dump();
526       std::string _outNode;
527       std::string _inNode;
528     };
529
530     class CommandAddContainer: public Command
531     {
532     public:
533       CommandAddContainer(std::string name,
534                           std::string refContainer ="");
535       SubjectContainer* getSubjectContainer() { return _subcont; };
536     protected:
537       virtual bool localExecute();
538       virtual bool localReverse();
539       virtual std::string dump();
540       std::string _name;
541       std::string _containerToClone;
542       SubjectContainer *_subcont;
543     };
544
545     class CommandSetContainerProperties: public Command
546     {
547     public:
548       CommandSetContainerProperties(std::string container,
549                                     std::map<std::string,std::string> properties);
550     protected:
551       virtual bool localExecute();
552       virtual bool localReverse();
553       virtual std::string dump();
554       std::string _container;
555       std::map<std::string,std::string> _properties;
556       std::map<std::string,std::string> _oldProp;
557     };
558
559     class CommandSetNodeProperties: public Command
560     {
561     public:
562       CommandSetNodeProperties(std::string position,
563                                     std::map<std::string,std::string> properties);
564     protected:
565       virtual bool localExecute();
566       virtual bool localReverse();
567       virtual std::string dump();
568       std::string _position;
569       std::map<std::string,std::string> _properties;
570       std::map<std::string,std::string> _oldProp;
571     };
572
573     class CommandSetComponentInstanceProperties: public Command
574     {
575     public:
576       CommandSetComponentInstanceProperties(std::string compoinstance,
577                                             std::map<std::string,std::string> properties);
578     protected:
579       virtual bool localExecute();
580       virtual bool localReverse();
581       virtual std::string dump();
582       std::string _compoinstance;
583       std::map<std::string,std::string> _properties;
584       std::map<std::string,std::string> _oldProp;
585       bool _oldAnon;
586     };
587
588     class CommandSetDSPortProperties: public Command
589     {
590     public:
591       CommandSetDSPortProperties(std::string node, std::string port, bool isInport,
592                                  std::map<std::string,std::string> properties);
593     protected:
594       virtual bool localExecute();
595       virtual bool localReverse();
596       virtual std::string dump();
597       std::string _nodeName;
598       std::string _portName;
599       bool _isInport;
600       std::map<std::string,std::string> _properties;
601       std::map<std::string,std::string> _oldProp;
602     };
603
604     class CommandSetLinkProperties: public Command
605     {
606     public:
607       CommandSetLinkProperties(std::string startnode, std::string startport, 
608                                std::string endnode, std::string endport,
609                                std::map<std::string,std::string> properties);
610     protected:
611       virtual bool localExecute();
612       virtual bool localReverse();
613       virtual std::string dump();
614       std::string _startNodeName;
615       std::string _startPortName;
616       std::string _endNodeName;
617       std::string _endPortName;
618       std::map<std::string,std::string> _properties;
619       std::map<std::string,std::string> _oldProp;
620     };
621
622     class CommandSetFuncNodeFunctionName: public Command
623     {
624     public:
625       CommandSetFuncNodeFunctionName(std::string node, std::string funcName);
626     protected:
627       virtual bool localExecute();
628       virtual bool localReverse();
629       virtual std::string dump();
630       std::string _nodeName;
631       std::string _funcName;
632       std::string _oldName;
633     };
634
635     class CommandSetInlineNodeScript: public Command
636     {
637     public:
638       CommandSetInlineNodeScript(std::string node, std::string script);
639     protected:
640       virtual bool localExecute();
641       virtual bool localReverse();
642       virtual std::string dump();
643       std::string _nodeName;
644       std::string _script;
645       std::string _oldScript;
646     };
647
648     class CommandAddComponentInstance: public Command
649     {
650     public:
651       CommandAddComponentInstance(std::string compoName,
652                                   std::string container,
653                                   std::string name ="");
654       SubjectComponent* getSubjectComponent() {return _subcompo; };
655     protected:
656       virtual bool localExecute();
657       virtual bool localReverse();
658       virtual std::string dump();
659       std::string _compoName;
660       std::string _container;
661       std::string _name;
662       SubjectComponent *_subcompo;
663     };
664
665     class CommandSetExecutionMode: public Command
666     {
667     public:
668       CommandSetExecutionMode(std::string nodeName, std::string mode);
669     protected:
670       virtual bool localExecute();
671       virtual bool localReverse();
672       virtual std::string dump();
673       std::string _mode;
674       std::string _nodeName;
675       std::string _oldmode;
676     };
677
678     class CommandSetContainer: public Command
679     {
680     public:
681       CommandSetContainer(std::string nodeName, std::string container);
682     protected:
683       virtual bool localExecute();
684       virtual bool localReverse();
685       virtual std::string dump();
686       std::string _container;
687       std::string _nodeName;
688       std::string _oldcont;
689     };
690
691     class CommandAssociateComponentToContainer: public Command
692     {
693     public:
694       CommandAssociateComponentToContainer(std::string instanceName,
695                                            std::string container);
696     protected:
697       virtual bool localExecute();
698       virtual bool localReverse();
699       virtual std::string dump();
700       std::string _container;
701       std::string _instanceName;
702       std::string _oldcont;
703     };
704
705     class CommandAssociateServiceToComponent: public Command
706     {
707     public:
708       CommandAssociateServiceToComponent(std::string service,
709                                          std::string instanceName);
710     protected:
711       virtual bool localExecute();
712       virtual bool localReverse();
713       virtual std::string dump();
714       std::string _service;
715       std::string _instanceName;
716       std::string _oldInstance;
717       std::string _oldcont;
718     };
719
720     class CommandAddComponentFromCatalog: public Command
721     {
722     public:
723       CommandAddComponentFromCatalog(YACS::ENGINE::Catalog* catalog,
724                                      std::string position,
725                                      std::string compo,
726                                      std::string service);
727     protected:
728       virtual bool localExecute();
729       virtual bool localReverse();
730       virtual std::string dump();
731       YACS::ENGINE::Catalog* _catalog;
732       std::string _position;
733       std::string _compo;
734       std::string _service;
735       std::string _nameInProc;
736       bool _createdInstance;
737     };
738
739
740     class Subject;
741     class CommandDestroy: public Command
742     {
743     public:
744       CommandDestroy(TypeOfElem elemType,
745                      std::string startnode, std::string startport, TypeOfElem startportType,
746                      std::string endnode, std::string endport, TypeOfElem endportType);
747     protected:
748       virtual bool localExecute();
749       virtual bool localReverse();
750       virtual std::string dump();
751     protected:
752       TypeOfElem _elemType;
753       std::string _startnode;
754       std::string _startport; 
755       TypeOfElem _startportType;
756       std::string _endnode;
757       std::string _endport;
758       TypeOfElem _endportType;
759
760 //       std::string _position;
761 //       Subject* _subject;
762 //       std::string _name;
763     };
764
765   }
766 }
767 #endif