Salome HOME
Copyrights update 2015.
[modules/yacs.git] / src / hmi / commandsProc.hxx
1 // Copyright (C) 2006-2015  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 SubjectContainerBase;
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 CommandAddContainerBase : public Command
531     {
532     public:
533       CommandAddContainerBase(std::string name, std::string refContainer);
534       virtual ~CommandAddContainerBase();
535       SubjectContainerBase* getSubjectContainer() { return _subcont; }
536     protected:
537       virtual bool localExecute();
538       virtual bool localReverse();
539       virtual YACS::ENGINE::Container *createNewInstance() const = 0;
540       std::string _name;
541       std::string _containerToClone;
542       SubjectContainerBase *_subcont;
543     };
544
545     class CommandAddContainer : public CommandAddContainerBase
546     {
547     public:
548       CommandAddContainer(std::string name, std::string refContainer ="");
549     protected:
550       std::string dump();
551       YACS::ENGINE::Container *createNewInstance() const;
552     };
553
554     class CommandAddHPContainer : public CommandAddContainerBase
555     {
556     public:
557       CommandAddHPContainer(std::string name, std::string refContainer ="");
558     protected:
559       std::string dump();
560       YACS::ENGINE::Container *createNewInstance() const;
561     };
562
563     class CommandSetContainerProperties: public Command
564     {
565     public:
566       CommandSetContainerProperties(std::string container,
567                                     std::map<std::string,std::string> properties);
568     protected:
569       virtual bool localExecute();
570       virtual bool localReverse();
571       virtual std::string dump();
572       std::string _container;
573       std::map<std::string,std::string> _properties;
574       std::map<std::string,std::string> _oldProp;
575     };
576
577     class CommandSetNodeProperties: public Command
578     {
579     public:
580       CommandSetNodeProperties(std::string position,
581                                     std::map<std::string,std::string> properties);
582     protected:
583       virtual bool localExecute();
584       virtual bool localReverse();
585       virtual std::string dump();
586       std::string _position;
587       std::map<std::string,std::string> _properties;
588       std::map<std::string,std::string> _oldProp;
589     };
590
591     class CommandSetComponentInstanceProperties: public Command
592     {
593     public:
594       CommandSetComponentInstanceProperties(std::string compoinstance,
595                                             std::map<std::string,std::string> properties);
596     protected:
597       virtual bool localExecute();
598       virtual bool localReverse();
599       virtual std::string dump();
600       std::string _compoinstance;
601       std::map<std::string,std::string> _properties;
602       std::map<std::string,std::string> _oldProp;
603       bool _oldAnon;
604     };
605
606     class CommandSetDSPortProperties: public Command
607     {
608     public:
609       CommandSetDSPortProperties(std::string node, std::string port, bool isInport,
610                                  std::map<std::string,std::string> properties);
611     protected:
612       virtual bool localExecute();
613       virtual bool localReverse();
614       virtual std::string dump();
615       std::string _nodeName;
616       std::string _portName;
617       bool _isInport;
618       std::map<std::string,std::string> _properties;
619       std::map<std::string,std::string> _oldProp;
620     };
621
622     class CommandSetLinkProperties: public Command
623     {
624     public:
625       CommandSetLinkProperties(std::string startnode, std::string startport, 
626                                std::string endnode, std::string endport,
627                                std::map<std::string,std::string> properties);
628     protected:
629       virtual bool localExecute();
630       virtual bool localReverse();
631       virtual std::string dump();
632       std::string _startNodeName;
633       std::string _startPortName;
634       std::string _endNodeName;
635       std::string _endPortName;
636       std::map<std::string,std::string> _properties;
637       std::map<std::string,std::string> _oldProp;
638     };
639
640     class CommandSetFuncNodeFunctionName: public Command
641     {
642     public:
643       CommandSetFuncNodeFunctionName(std::string node, std::string funcName);
644     protected:
645       virtual bool localExecute();
646       virtual bool localReverse();
647       virtual std::string dump();
648       std::string _nodeName;
649       std::string _funcName;
650       std::string _oldName;
651     };
652
653     class CommandSetInlineNodeScript: public Command
654     {
655     public:
656       CommandSetInlineNodeScript(std::string node, std::string script);
657     protected:
658       virtual bool localExecute();
659       virtual bool localReverse();
660       virtual std::string dump();
661       std::string _nodeName;
662       std::string _script;
663       std::string _oldScript;
664     };
665
666     class CommandAddComponentInstance: public Command
667     {
668     public:
669       CommandAddComponentInstance(std::string compoName,
670                                   std::string container,
671                                   std::string name ="");
672       SubjectComponent* getSubjectComponent() {return _subcompo; };
673     protected:
674       virtual bool localExecute();
675       virtual bool localReverse();
676       virtual std::string dump();
677       std::string _compoName;
678       std::string _container;
679       std::string _name;
680       SubjectComponent *_subcompo;
681     };
682
683     class CommandSetExecutionMode: public Command
684     {
685     public:
686       CommandSetExecutionMode(std::string nodeName, std::string mode);
687     protected:
688       virtual bool localExecute();
689       virtual bool localReverse();
690       virtual std::string dump();
691       std::string _mode;
692       std::string _nodeName;
693       std::string _oldmode;
694     };
695
696     class CommandSetContainer: public Command
697     {
698     public:
699       CommandSetContainer(std::string nodeName, std::string container);
700     protected:
701       virtual bool localExecute();
702       virtual bool localReverse();
703       virtual std::string dump();
704       std::string _container;
705       std::string _nodeName;
706       std::string _oldcont;
707     };
708
709     class CommandAssociateComponentToContainer: public Command
710     {
711     public:
712       CommandAssociateComponentToContainer(std::string instanceName,
713                                            std::string container);
714     protected:
715       virtual bool localExecute();
716       virtual bool localReverse();
717       virtual std::string dump();
718       std::string _container;
719       std::string _instanceName;
720       std::string _oldcont;
721     };
722
723     class CommandAssociateServiceToComponent: public Command
724     {
725     public:
726       CommandAssociateServiceToComponent(std::string service,
727                                          std::string instanceName);
728     protected:
729       virtual bool localExecute();
730       virtual bool localReverse();
731       virtual std::string dump();
732       std::string _service;
733       std::string _instanceName;
734       std::string _oldInstance;
735       std::string _oldcont;
736     };
737
738     class CommandAddComponentFromCatalog: public Command
739     {
740     public:
741       CommandAddComponentFromCatalog(YACS::ENGINE::Catalog* catalog,
742                                      std::string position,
743                                      std::string compo,
744                                      std::string service);
745     protected:
746       virtual bool localExecute();
747       virtual bool localReverse();
748       virtual std::string dump();
749       YACS::ENGINE::Catalog* _catalog;
750       std::string _position;
751       std::string _compo;
752       std::string _service;
753       std::string _nameInProc;
754       bool _createdInstance;
755     };
756
757
758     class Subject;
759     class CommandDestroy: public Command
760     {
761     public:
762       CommandDestroy(TypeOfElem elemType,
763                      std::string startnode, std::string startport, TypeOfElem startportType,
764                      std::string endnode, std::string endport, TypeOfElem endportType);
765     protected:
766       virtual bool localExecute();
767       virtual bool localReverse();
768       virtual std::string dump();
769     protected:
770       TypeOfElem _elemType;
771       std::string _startnode;
772       std::string _startport; 
773       TypeOfElem _startportType;
774       std::string _endnode;
775       std::string _endport;
776       TypeOfElem _endportType;
777
778 //       std::string _position;
779 //       Subject* _subject;
780 //       std::string _name;
781     };
782
783   }
784 }
785 #endif