1 // Copyright (C) 2006-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _COMMANDSPROC_HXX_
21 #define _COMMANDSPROC_HXX_
23 #include "HMIExport.hxx"
24 #include "commands.hxx"
42 class InputDataStreamPort;
43 class OutputDataStreamPort;
45 class ComponentInstance;
51 class SubjectInputPort;
52 class SubjectOutputPort;
53 class SubjectInputDataStreamPort;
54 class SubjectOutputDataStreamPort;
56 class SubjectControlLink;
57 class SubjectContainerBase;
58 class SubjectComponent;
96 class HMI_EXPORT ProcInvoc: public Invocator
100 static TypeOfElem getTypeOfNode(YACS::ENGINE::Node* node);
101 static TypeOfElem getTypeOfPort(YACS::ENGINE::DataPort* port);
102 static std::string getTypeName(TypeOfElem type);
104 static std::map<int, std::string> _typeNameMap;
108 class CommandAddNodeFromCatalog: public Command
111 CommandAddNodeFromCatalog(YACS::ENGINE::Catalog *catalog,
114 std::string position,
116 bool newCompoInst=true,
118 YACS::ENGINE::Node *getNode();
119 YACS::HMI::SubjectNode *getSubjectNode();
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;
132 YACS::ENGINE::Node *_node;
133 YACS::HMI::SubjectNode *_snode;
136 class CommandReparentNode: public Command
139 CommandReparentNode(std::string position,
140 std::string newParent);
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;
151 class CommandPutInComposedNode: public Command
154 CommandPutInComposedNode(std::string position,
155 std::string newParent,
157 bool toSaveRestoreLinks=true);
159 virtual bool localExecute();
160 virtual bool localReverse();
161 virtual std::string dump();
162 std::string _position;
163 std::string _newParent;
166 bool _toSaveRestoreLinks;
169 class CommandCopyNode: public Command
172 CommandCopyNode(YACS::ENGINE::Proc* fromproc,
173 std::string position,
174 std::string newParent,
176 YACS::ENGINE::Node *getNode();
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;
185 YACS::ENGINE::Node *_clone;
186 YACS::ENGINE::Proc *_fromproc;
189 class CommandRenameNode: public Command
192 CommandRenameNode(std::string position, std::string name);
194 virtual bool localExecute();
195 virtual bool localReverse();
196 virtual std::string dump();
197 std::string _position;
199 std::string _oldName;
203 class CommandRenameContainer: public Command
206 CommandRenameContainer(std::string oldName, std::string newName);
208 virtual bool localExecute();
209 virtual bool localReverse();
210 virtual std::string dump();
211 std::string _oldName;
212 std::string _newName;
215 class CommandRenameInDataPort: public Command
218 CommandRenameInDataPort(std::string position,
220 std::string newName, TypeOfElem portType);
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;
231 class CommandRenameOutDataPort: public Command
234 CommandRenameOutDataPort(std::string position,
236 std::string newName, TypeOfElem portType);
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;
247 class CommandAddDataTypeFromCatalog: public Command
250 CommandAddDataTypeFromCatalog(YACS::ENGINE::Catalog* catalog,
251 std::string typeName);
252 YACS::ENGINE::TypeCode *getTypeCode();
254 virtual bool localExecute();
255 virtual bool localReverse();
256 virtual std::string dump();
257 YACS::ENGINE::Catalog* _catalog;
258 std::string _typeName;
261 class CommandAddInputPortFromCatalog: public Command
264 CommandAddInputPortFromCatalog(YACS::ENGINE::Catalog *catalog,
268 YACS::ENGINE::InputPort *getInputPort();
269 SubjectInputPort* getSubjectInputPort();
271 virtual bool localExecute();
272 virtual bool localReverse();
273 virtual std::string dump();
274 YACS::ENGINE::Catalog* _catalog;
275 std::string _typePort;
278 YACS::ENGINE::InputPort *_inputPort;
279 SubjectInputPort* _sip;
282 class CommandAddOutputPortFromCatalog: public Command
285 CommandAddOutputPortFromCatalog(YACS::ENGINE::Catalog *catalog,
289 YACS::ENGINE::OutputPort *getOutputPort();
290 SubjectOutputPort* getSubjectOutputPort();
292 virtual bool localExecute();
293 virtual bool localReverse();
294 virtual std::string dump();
295 YACS::ENGINE::Catalog* _catalog;
296 std::string _typePort;
299 YACS::ENGINE::OutputPort *_outputPort;
300 SubjectOutputPort* _sop;
303 class CommandAddIDSPortFromCatalog: public Command
306 CommandAddIDSPortFromCatalog(YACS::ENGINE::Catalog *catalog,
310 YACS::ENGINE::InputDataStreamPort *getIDSPort();
311 SubjectInputDataStreamPort* getSubjectIDSPort();
313 virtual bool localExecute();
314 virtual bool localReverse();
315 virtual std::string dump();
316 YACS::ENGINE::Catalog* _catalog;
317 std::string _typePort;
320 YACS::ENGINE::InputDataStreamPort *_IDSPort;
321 SubjectInputDataStreamPort* _sip;
324 class CommandAddODSPortFromCatalog: public Command
327 CommandAddODSPortFromCatalog(YACS::ENGINE::Catalog *catalog,
331 YACS::ENGINE::OutputDataStreamPort *getODSPort();
332 SubjectOutputDataStreamPort* getSubjectODSPort();
334 virtual bool localExecute();
335 virtual bool localReverse();
336 virtual std::string dump();
337 YACS::ENGINE::Catalog* _catalog;
338 std::string _typePort;
341 YACS::ENGINE::OutputDataStreamPort *_ODSPort;
342 SubjectOutputDataStreamPort* _sop;
345 class CommandOrderInputPorts: public Command
348 CommandOrderInputPorts(std::string node,
351 int getRank() {return _rank; };
353 virtual bool localExecute();
354 virtual bool localReverse();
355 virtual std::string dump();
362 class CommandOrderOutputPorts: public Command
365 CommandOrderOutputPorts(std::string node,
368 int getRank() {return _rank; };
370 virtual bool localExecute();
371 virtual bool localReverse();
372 virtual std::string dump();
379 class CommandSetInPortValue: public Command
382 CommandSetInPortValue(std::string node,
386 virtual bool localExecute();
387 virtual bool localReverse();
388 virtual std::string dump();
392 std::string _oldValue;
395 class CommandSetOutPortValue: public Command
398 CommandSetOutPortValue(std::string node,
402 virtual bool localExecute();
403 virtual bool localReverse();
404 virtual std::string dump();
408 std::string _oldValue;
411 class CommandSetSwitchSelect: public Command
414 CommandSetSwitchSelect(std::string aSwitch,
417 virtual bool localExecute();
418 virtual bool localReverse();
419 virtual std::string dump();
422 std::string _oldValue;
425 class CommandSetSwitchCase: public Command
428 CommandSetSwitchCase(std::string aSwitch,
432 virtual bool localExecute();
433 virtual bool localReverse();
434 virtual std::string dump();
437 std::string _oldNode;
442 class CommandSetForLoopSteps: public Command
445 CommandSetForLoopSteps(std::string forLoop,
448 virtual bool localExecute();
449 virtual bool localReverse();
450 virtual std::string dump();
451 std::string _forLoop;
456 class CommandSetWhileCondition: public Command
459 CommandSetWhileCondition(std::string whileLoop,
462 virtual bool localExecute();
463 virtual bool localReverse();
464 virtual std::string dump();
465 std::string _whileLoop;
470 class CommandSetForEachBranch: public Command
473 CommandSetForEachBranch(std::string forEach,
476 virtual bool localExecute();
477 virtual bool localReverse();
478 virtual std::string dump();
479 std::string _forEach;
484 class CommandSetAlgo: public Command
487 CommandSetAlgo(std::string optimizer, std::string alglib, std::string symbol);
489 virtual bool localExecute();
490 virtual bool localReverse();
491 virtual std::string dump();
492 std::string _optimizer;
495 std::string _oldAlglib;
496 std::string _oldSymbol;
499 class CommandAddLink: public Command
502 CommandAddLink(std::string outNode, std::string outPort, TypeOfElem outPortType,
503 std::string inNode, std::string inPort, TypeOfElem inPortType, bool control=true);
505 virtual bool localExecute();
506 virtual bool localReverse();
507 virtual std::string dump();
508 std::string _outNode;
509 std::string _outPort;
510 TypeOfElem _outPortType;
513 TypeOfElem _inPortType;
515 bool _controlCreatedWithDF;
518 class CommandAddControlLink: public Command
521 CommandAddControlLink(std::string outNode, std::string inNode);
523 virtual bool localExecute();
524 virtual bool localReverse();
525 virtual std::string dump();
526 std::string _outNode;
530 class CommandAddContainerBase : public Command
533 CommandAddContainerBase(std::string name, std::string refContainer);
534 virtual ~CommandAddContainerBase();
535 SubjectContainerBase* getSubjectContainer() { return _subcont; }
537 virtual bool localExecute();
538 virtual bool localReverse();
539 virtual YACS::ENGINE::Container *createNewInstance() const = 0;
541 std::string _containerToClone;
542 SubjectContainerBase *_subcont;
545 class CommandAddContainer : public CommandAddContainerBase
548 CommandAddContainer(std::string name, std::string refContainer ="");
551 YACS::ENGINE::Container *createNewInstance() const;
554 class CommandAddHPContainer : public CommandAddContainerBase
557 CommandAddHPContainer(std::string name, std::string refContainer ="");
560 YACS::ENGINE::Container *createNewInstance() const;
563 class CommandSetContainerProperties: public Command
566 CommandSetContainerProperties(std::string container,
567 std::map<std::string,std::string> properties);
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;
577 class CommandSetNodeProperties: public Command
580 CommandSetNodeProperties(std::string position,
581 std::map<std::string,std::string> properties);
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;
591 class CommandSetComponentInstanceProperties: public Command
594 CommandSetComponentInstanceProperties(std::string compoinstance,
595 std::map<std::string,std::string> properties);
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;
606 class CommandSetDSPortProperties: public Command
609 CommandSetDSPortProperties(std::string node, std::string port, bool isInport,
610 std::map<std::string,std::string> properties);
612 virtual bool localExecute();
613 virtual bool localReverse();
614 virtual std::string dump();
615 std::string _nodeName;
616 std::string _portName;
618 std::map<std::string,std::string> _properties;
619 std::map<std::string,std::string> _oldProp;
622 class CommandSetLinkProperties: public Command
625 CommandSetLinkProperties(std::string startnode, std::string startport,
626 std::string endnode, std::string endport,
627 std::map<std::string,std::string> properties);
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;
640 class CommandSetFuncNodeFunctionName: public Command
643 CommandSetFuncNodeFunctionName(std::string node, std::string funcName);
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;
653 class CommandSetInlineNodeScript: public Command
656 CommandSetInlineNodeScript(std::string node, std::string script);
658 virtual bool localExecute();
659 virtual bool localReverse();
660 virtual std::string dump();
661 std::string _nodeName;
663 std::string _oldScript;
666 class CommandAddComponentInstance: public Command
669 CommandAddComponentInstance(std::string compoName,
670 std::string container,
671 std::string name ="");
672 SubjectComponent* getSubjectComponent() {return _subcompo; };
674 virtual bool localExecute();
675 virtual bool localReverse();
676 virtual std::string dump();
677 std::string _compoName;
678 std::string _container;
680 SubjectComponent *_subcompo;
683 class CommandSetExecutionMode: public Command
686 CommandSetExecutionMode(std::string nodeName, std::string mode);
688 virtual bool localExecute();
689 virtual bool localReverse();
690 virtual std::string dump();
692 std::string _nodeName;
693 std::string _oldmode;
696 class CommandSetContainer: public Command
699 CommandSetContainer(std::string nodeName, std::string container);
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;
709 class CommandAssociateComponentToContainer: public Command
712 CommandAssociateComponentToContainer(std::string instanceName,
713 std::string container);
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;
723 class CommandAssociateServiceToComponent: public Command
726 CommandAssociateServiceToComponent(std::string service,
727 std::string instanceName);
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;
738 class CommandAddComponentFromCatalog: public Command
741 CommandAddComponentFromCatalog(YACS::ENGINE::Catalog* catalog,
742 std::string position,
744 std::string service);
746 virtual bool localExecute();
747 virtual bool localReverse();
748 virtual std::string dump();
749 YACS::ENGINE::Catalog* _catalog;
750 std::string _position;
752 std::string _service;
753 std::string _nameInProc;
754 bool _createdInstance;
759 class CommandDestroy: public Command
762 CommandDestroy(TypeOfElem elemType,
763 std::string startnode, std::string startport, TypeOfElem startportType,
764 std::string endnode, std::string endport, TypeOfElem endportType);
766 virtual bool localExecute();
767 virtual bool localReverse();
768 virtual std::string dump();
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;
778 // std::string _position;
779 // Subject* _subject;
780 // std::string _name;