Version: 9.16.0
commandsProc.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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#include <Python.h>
21#include "commandsProc.hxx"
22
23#include "Node.hxx"
24#include "ComposedNode.hxx"
25#include "Bloc.hxx"
26#include "Proc.hxx"
27#include "ElementaryNode.hxx"
28#include "InlineNode.hxx"
29#include "ServiceNode.hxx"
30#include "PythonNode.hxx"
31#include "CORBANode.hxx"
32#include "CppNode.hxx"
33#include "XMLNode.hxx"
34#include "SalomePythonNode.hxx"
35#include "XMLNode.hxx"
36#include "ForLoop.hxx"
37#include "ForEachLoop.hxx"
38#include "WhileLoop.hxx"
39#include "Switch.hxx"
40#include "OptimizerLoop.hxx"
41#include "PresetNode.hxx"
42#include "OutNode.hxx"
43#include "StudyNodes.hxx"
44#include "Exception.hxx"
45#include "DataPort.hxx"
48#include "StudyPorts.hxx"
49#include "PresetPorts.hxx"
51#include "SalomeContainer.hxx"
52#include "SalomeHPContainer.hxx"
53#include "SalomeComponent.hxx"
54#include "TypeCode.hxx"
55#include "RuntimeSALOME.hxx"
56#include "TypeConversions.hxx"
57
58#include "guiContext.hxx"
59
60#include <iostream>
61#include <sstream>
62#include <string>
63
64//#define _DEVDEBUG_
65#include "YacsTrace.hxx"
66
67using namespace std;
68
69using namespace YACS;
70using namespace YACS::ENGINE;
71using namespace YACS::HMI;
72
73
74static std::map<int, std::string> createErrorMsgMap()
75{
76 std::map<int, std::string> m;
77 m[1] = "\nUse the [Ctrl] Drag_N_Drop method if you want to create a input/output link without the associated control link";
78 return m;
79}
80
81std::map<int, std::string> ErrorMsg = createErrorMsgMap();
82
84{
85 DEBTRACE("errorNumber= "<<ex.errNumber);
86 if(ex.errNumber > 0 && ErrorMsg.count(ex.errNumber) != 0)
87 {
88 DEBTRACE(ErrorMsg[ex.errNumber]);
89 GuiContext::getCurrent()->_lastErrorMessage = ex.what() + ErrorMsg[ex.errNumber];
90 }
91 else
92 GuiContext::getCurrent()->_lastErrorMessage = ex.what();
93}
94
95std::map<int, std::string> ProcInvoc::_typeNameMap;
96
97// ----------------------------------------------------------------------------
98
99ProcInvoc::ProcInvoc()
100 : Invocator()
101{
102 _typeNameMap.clear();
103 _typeNameMap[SALOMEPROC] = "SALOMEPROC";
104 _typeNameMap[BLOC] = "BLOC";
105 _typeNameMap[FOREACHLOOP] = "FOREACHLOOP";
106 _typeNameMap[OPTIMIZERLOOP] = "OPTIMIZERLOOP";
107 _typeNameMap[FORLOOP] = "FORLOOP";
108 _typeNameMap[WHILELOOP] = "WHILELOOP";
109 _typeNameMap[SWITCH] = "SWITCH";
110 _typeNameMap[PYTHONNODE] = "PYTHONNODE";
111 _typeNameMap[PYFUNCNODE] = "PYFUNCNODE";
112 _typeNameMap[CORBANODE] = "CORBANODE";
113 _typeNameMap[SALOMENODE] = "SALOMENODE";
114 _typeNameMap[CPPNODE] = "CPPNODE";
115 _typeNameMap[SALOMEPYTHONNODE] = "SALOMEPYTHONNODE";
116 _typeNameMap[XMLNODE] = "XMLNODE";
117 _typeNameMap[SPLITTERNODE] = "SPLITTERNODE";
118 _typeNameMap[DFTODSFORLOOPNODE] = "DFTODSFORLOOPNODE";
119 _typeNameMap[DSTODFFORLOOPNODE] = "DSTODFFORLOOPNODE";
120 _typeNameMap[PRESETNODE] = "PRESETNODE";
121 _typeNameMap[OUTNODE] = "OUTNODE";
122 _typeNameMap[STUDYINNODE] = "STUDYINNODE";
123 _typeNameMap[STUDYOUTNODE] = "STUDYOUTNODE";
124 _typeNameMap[INPUTPORT] = "INPUTPORT";
125 _typeNameMap[OUTPUTPORT] = "OUTPUTPORT";
126 _typeNameMap[INPUTDATASTREAMPORT] = "INPUTDATASTREAMPORT";
127 _typeNameMap[OUTPUTDATASTREAMPORT] = "OUTPUTDATASTREAMPORT";
128 _typeNameMap[DATALINK] = "DATALINK";
129 _typeNameMap[CONTROLLINK] = "CONTROLLINK";
130 _typeNameMap[CONTAINER] = "CONTAINER";
131 _typeNameMap[COMPONENT] = "COMPONENT";
132 _typeNameMap[REFERENCE] = "REFERENCE";
133 _typeNameMap[DATATYPE] = "DATATYPE";
134}
135
137{
138 TypeOfElem nodeType = UNKNOWN;
139 if (dynamic_cast<YACS::ENGINE::Bloc*>(node)) nodeType = BLOC;
140 else if (dynamic_cast<YACS::ENGINE::PythonNode*>(node)) nodeType = PYTHONNODE;
141 else if (dynamic_cast<YACS::ENGINE::PyFuncNode*>(node)) nodeType = PYFUNCNODE;
142 else if (dynamic_cast<YACS::ENGINE::CORBANode*>(node)) nodeType = CORBANODE;
143 else if (dynamic_cast<YACS::ENGINE::CppNode*>(node)) nodeType = CPPNODE;
144 else if (dynamic_cast<YACS::ENGINE::SalomeNode*>(node)) nodeType = SALOMENODE;
145 else if (dynamic_cast<YACS::ENGINE::SalomePythonNode*>(node)) nodeType = SALOMEPYTHONNODE;
146 else if (dynamic_cast<YACS::ENGINE::XmlNode*>(node)) nodeType = XMLNODE;
147 else if (dynamic_cast<YACS::ENGINE::SplitterNode*>(node)) nodeType = SPLITTERNODE;
148 else if (dynamic_cast<YACS::ENGINE::ForLoop*>(node)) nodeType = FORLOOP;
149 else if (dynamic_cast<YACS::ENGINE::WhileLoop*>(node)) nodeType = WHILELOOP;
150 else if (dynamic_cast<YACS::ENGINE::Switch*>(node)) nodeType = SWITCH;
151 else if (dynamic_cast<YACS::ENGINE::ForEachLoopGen*>(node)) nodeType = FOREACHLOOP;
152 else if (dynamic_cast<YACS::ENGINE::OptimizerLoop*>(node)) nodeType = OPTIMIZERLOOP;
153 else if (dynamic_cast<YACS::ENGINE::PresetNode*>(node)) nodeType = PRESETNODE;
154 else if (dynamic_cast<YACS::ENGINE::OutNode*>(node)) nodeType = OUTNODE;
155 else if (dynamic_cast<YACS::ENGINE::StudyInNode*>(node)) nodeType = STUDYINNODE;
156 else if (dynamic_cast<YACS::ENGINE::StudyOutNode*>(node)) nodeType = STUDYOUTNODE;
157 return nodeType;
158}
159
161{
162 TypeOfElem portType = UNKNOWN;
163 if (dynamic_cast<YACS::ENGINE::InputPort*>(port)) portType = INPUTPORT;
164 else if (dynamic_cast<YACS::ENGINE::OutputPort*>(port)) portType = OUTPUTPORT;
165 else if (dynamic_cast<YACS::ENGINE::InputDataStreamPort*>(port)) portType = INPUTDATASTREAMPORT;
166 else if (dynamic_cast<YACS::ENGINE::OutputDataStreamPort*>(port)) portType = OUTPUTDATASTREAMPORT;
167 return portType;
168}
169
171{
172 if (_typeNameMap.count(type))
173 return _typeNameMap[type];
174 else
175 return "UNKNOWN";
176}
177
178// ----------------------------------------------------------------------------
179
181 std::string compo,
182 std::string type,
183 std::string position,
184 std::string name,
185 bool newCompoInst,
186 int swCase)
187 : Command(), _catalog(catalog), _compoName(compo), _typeName(type),
188 _position(position), _name(name), _newCompoInst(newCompoInst), _swCase(swCase)
189{
190 DEBTRACE("CommandAddNodeFromCatalog " << compo << " " << type << " " << position << " " << name);
191 _node=0;
192 _snode=0;
193}
194
196{
197 string ret ="CommandAddNodeFromCatalog " + _compoName + " " + _typeName + " " + _position + " " + _name;
198 return ret;
199}
200
202{
203 return _node;
204}
205
207{
208 return _snode;
209}
210
212{
213 DEBTRACE("CommandAddNodeFromCatalog::localExecute");
214
215 Node *son = 0;
216 Node *nodeToClone = 0;
217 try
218 {
219 if (_compoName.empty())
220 {
221 if (_catalog->_nodeMap.count(_typeName))
222 nodeToClone = _catalog->_nodeMap[_typeName];
223 else if (_catalog->_composednodeMap.count(_typeName))
224 nodeToClone = _catalog->_composednodeMap[_typeName];
225 }
226 else
228 {
230 if (compodef->_serviceMap.count(_typeName))
231 nodeToClone = compodef->_serviceMap[_typeName];
232 }
233 if (nodeToClone)
234 _typeNode = ProcInvoc::getTypeOfNode(nodeToClone);
235
238 Node* node = proc;
239 ServiceNode *service = 0;
240
241 if (!_position.empty()) node = proc->getChildByName(_position);
242 ComposedNode* father =dynamic_cast<ComposedNode*> (node);
243 if (father && nodeToClone)
244 {
245 son = nodeToClone->clone(0);
246 son->setName(_name);
247 service = dynamic_cast<ServiceNode*>(son);
248 }
249
250 // Node creation eventually reusing old component instance
251 ComponentInstance *compo = 0;
252 if (service)
253 compo = service->getComponent();
254
255 if(compo)
256 {
257 std::string compoName=compo->getCompoName();
258 DEBTRACE(compoName);
259 std::string compoInstName=compo->getInstanceName();
260 DEBTRACE(compoInstName);
261 if(!_newCompoInst)
262 {
264 DEBTRACE(lastcompo);
265 if(lastcompo)
266 {
267 DEBTRACE(lastcompo->getInstanceName());
268 service->setComponent(lastcompo); // use the last component instance of the same type and not a new instance
269 }
270 else
272 }
273 else
275 }
276
277 if (son)
278 {
279 TypeOfElem fatherType = ProcInvoc::getTypeOfNode(father);
280 switch (fatherType)
281 {
282 case BLOC:
283 (dynamic_cast<YACS::ENGINE::Bloc*>(father))->edAddChild(son);
284 break;
285 case FORLOOP:
286 (dynamic_cast<YACS::ENGINE::ForLoop*>(father))->edSetNode(son);
287 break;
288 case WHILELOOP:
289 (dynamic_cast<YACS::ENGINE::WhileLoop*>(father))->edSetNode(son);
290 break;
291 case SWITCH:
292 (dynamic_cast<YACS::ENGINE::Switch*>(father))->edSetNode(_swCase,son);
293 break;
294 case FOREACHLOOP:
295 (dynamic_cast<YACS::ENGINE::ForEachLoopGen*>(father))->edSetNode(son);
296 break;
297 case OPTIMIZERLOOP:
298 (dynamic_cast<YACS::ENGINE::OptimizerLoop*>(father))->edSetNode(son);
299 break;
300 default:
301 YASSERT(0);
302 }
303 }
304 _node = son;
305 if (!_node)
306 throw YACS::Exception("node from catalog is not correct: check if catalog is up to date!");
307
311 _snode->loadLinks();
312 }
313 catch (Exception& ex)
314 {
315 DEBTRACE("CommandAddNode::localExecute() : " << ex.what());
317 if (son) delete son;
318 _node = 0;
319 }
320 return (_node != 0);
321}
322
324{
325 DEBTRACE("CommandAddNodeFromCatalog::localReverse");
326 try
327 {
329 string nodeName;
330 if (_position.empty())
331 nodeName= _name;
332 else
333 nodeName = _position + "." + _name;
334 DEBTRACE(nodeName);
335 _node = proc->getChildByName(nodeName);
336 YASSERT(_node);
337 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(_node));
339
340 Subject *father=_snode->getParent();
341 DEBTRACE(father);
342 DEBTRACE(father->getName());
344 _snode= 0;
345 _node = 0;
346 if (father)
347 {
348 DEBTRACE("REMOVE");
349 father->select(true);
350 father->update(REMOVE,0,0);
351 }
352 return true;
353 }
354 catch (Exception& ex)
355 {
356 DEBTRACE("CommandAddNodeFromCatalog::localReverse(): " << ex.what());
358 return false;
359 }
360}
361
362// ----------------------------------------------------------------------------
363
365 std::string newParent)
366 : Command(), _position(position), _newParent(newParent)
367{
368 DEBTRACE("CommandReparentNode::CommandReparentNode " << _position << " " << _newParent);
369 _oldParent = "";
370}
371
373{
374 string ret ="CommandReparentNode " + _position + " " + _newParent;
375 return ret;
376}
377
379{
380 DEBTRACE("CommandReparentNode::localExecute");
382 Node* node = 0;
383 try
384 {
385 if (_position == proc->getName())
386 throw YACS::Exception("Reparent the proc (main bloc) is impossible");
387 node = proc->getChildByName(_position);
388 ComposedNode *oldFather = node->getFather();
389 ComposedNode *newFather = proc;
390 Node *newF = 0;
391 if (_newParent != proc->getName())
392 {
393 newF = proc->getChildByName(_newParent);
394 newFather = dynamic_cast<ComposedNode*>(newF);
395 }
396 if (!newFather)
397 throw YACS::Exception("new parent must be a composed node");
398 if (oldFather == newFather)
399 throw YACS::Exception("no need to reparent to the same parent");
400 if (ComposedNode *cnode = dynamic_cast<ComposedNode*>(node))
401 if (cnode->isInMyDescendance(newFather))
402 throw YACS::Exception("reparent a node to one of it's children is impossible");
403 if (Loop *loop = dynamic_cast<Loop*>(newFather))
404 if (!loop->edGetDirectDescendants().empty())
405 throw YACS::Exception("Already a node in a new parent of Loop type");
406 if (DynParaLoop * dpl = dynamic_cast<DynParaLoop*>(newFather))
407 if (dpl->getExecNode() != NULL)
408 throw YACS::Exception("Already an execution node in the new parent of type dynamic loop");
409 Node *nodeSameName = 0;
410 try
411 {
412 nodeSameName = newFather->getChildByName(node->getName());
413 }
414 catch (Exception& e)
415 {
416 }
417 if (nodeSameName)
418 throw YACS::Exception("there is already a child of same name in the new parent");
422 SubjectComposedNode* sop = dynamic_cast<SubjectComposedNode*>(subo);
423 SubjectComposedNode* snp = dynamic_cast<SubjectComposedNode*>(subn);
424 //save existing links
425 snode->saveLinks();
426 snode->removeExternalLinks();
428 sop->houseKeepingAfterCutPaste(true, snode);
429 oldFather->edRemoveChild(node);
430 newFather->edAddChild(node);
431 snp->houseKeepingAfterCutPaste(false, snode);
432 //restore links
433 snode->restoreLinks();
434 if (oldFather == proc) _oldParent = proc->getName();
435 else _oldParent = proc->getChildName(oldFather);
436 _newpos = proc->getChildName(node);
437 sop->update(CUT, ProcInvoc::getTypeOfNode(node), snode);
438 snp->update(PASTE, ProcInvoc::getTypeOfNode(node), snode);
439 snode->recursiveUpdate(RENAME, 0, snode);
440 snode->_parent = snp;
441 }
442 catch (Exception& ex)
443 {
444 DEBTRACE("CommandReparentNode::localExecute() : " << ex.what());
446 node = 0;
447 }
448 catch (...)
449 {
450 GuiContext::getCurrent()->_lastErrorMessage = "Unknown exception";
451 node = 0;
452 }
453 return (node != 0);
454}
455
457{
458 DEBTRACE("CommandReparentNode::localReverse " << _newpos << " " << _oldParent);
460 Node* node = 0;
461 try
462 {
463 node = proc->getChildByName(_newpos);
464 ComposedNode *father = node->getFather();
465 ComposedNode *oldFather = proc;
466 Node *oldF = 0;
467 if (_oldParent != proc->getName())
468 {
469 oldF = proc->getChildByName(_oldParent);
470 oldFather = dynamic_cast<ComposedNode*>(oldF);
471 }
475 SubjectComposedNode* snp = dynamic_cast<SubjectComposedNode*>(subn);
476 SubjectComposedNode* sop = dynamic_cast<SubjectComposedNode*>(subo);
477 //save existing links
478 snode->saveLinks();
479 snode->removeExternalLinks();
481 snp->houseKeepingAfterCutPaste(true, snode);
482 father->edRemoveChild(node);
483 oldFather->edAddChild(node);
484 sop->houseKeepingAfterCutPaste(false, snode);
485 //restore links
486 snode->restoreLinks();
487 snp->update(CUT, ProcInvoc::getTypeOfNode(node), snode);
488 sop->update(PASTE, ProcInvoc::getTypeOfNode(node), snode);
489 snode->recursiveUpdate(RENAME, 0, snode);
490 snode->_parent = sop;
491 }
492 catch (Exception& ex)
493 {
494 DEBTRACE("CommandReparentNode::localReverse() : " << ex.what());
496 node = 0;
497 }
498 catch (...)
499 {
500 GuiContext::getCurrent()->_lastErrorMessage = "Unknown exception";
501 node = 0;
502 }
503 return (node != 0);
504}
505
506// ----------------------------------------------------------------------------
508 std::string newParent,
509 std::string type,
510 bool toSaveRestoreLinks)
511 : Command(), _position(position), _newParent(newParent), _type(type), _toSaveRestoreLinks(toSaveRestoreLinks)
512{
513 DEBTRACE("CommandPutInComposedNode::CommandPutInComposedNode " << _position << " " << _newParent);
514 _newpos ="";
515}
516
518{
519 string save = _toSaveRestoreLinks ? "true" : "false";
520 string ret ="CommandPutInComposedNode " + _position + " " + _newParent + " " + _type + " " + save;
521 return ret;
522}
523
524
526{
527 DEBTRACE("CommandPutInComposedNode::localExecute");
529 Node* node = 0;
530 try
531 {
532 if (_position == proc->getName())
533 throw YACS::Exception("You cannot put the proc (main bloc) in a " + _type);
534 node = proc->getChildByName(_position);
535 ComposedNode *oldFather = node->getFather();
538 SubjectComposedNode* sop = dynamic_cast<SubjectComposedNode*>(subo);
540 snode->saveLinks(); //save existing links
541 //remove external links
542 snode->removeExternalLinks();
544 //remove subject node from subject old father
545 sop->houseKeepingAfterCutPaste(true, snode);
546 //remove node from old father
547 oldFather->edRemoveChild(node);
548 //refresh node views
549 sop->update(CUT, ProcInvoc::getTypeOfNode(node), snode);
550
551 // try to find a node with the given name:
552 // success: use it as target composed node
553 // fail: create such a node and use it
554 std::list<Node*> children = proc->getChildren();
555 Node* composednode = 0;
556 SubjectNode *scomposednode = 0;
557 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
558 {
559 if ( _newParent == (*it)->getName() )
560 {
561 //get an existing ComposedNode with name _newParent
562 composednode = (*it);
563 break;
564 }
565 }
566 // target node was found
567 if ( composednode )
568 {
569 scomposednode = GuiContext::getCurrent()->_mapOfSubjectNode[composednode];
570 }
571 // creation of target node
572 else
573 {
574 //create a ComposedNode (type _type) with name _newParent
576 Node* nodeToClone = catalog->_composednodeMap[_type];
577 composednode = nodeToClone->cloneWithoutCompAndContDeepCpy(0);
578 composednode->setName(_newParent);
579 //add the new composednode as child of oldfather
580 oldFather->edAddChild(composednode);
581 //create the subject composednode
582 scomposednode = sop->addSubjectNode(composednode,"",catalog,"",_type);
583 }
584
585 //add the old node as child of new composednode
586 (dynamic_cast<YACS::ENGINE::ComposedNode*>(composednode))->edAddChild(node);
587 _newpos = proc->getChildName(node);
588 //add the subject node to subject composednode
589 (dynamic_cast<SubjectComposedNode*>(scomposednode))->houseKeepingAfterCutPaste(false, snode);
590 snode->setParent(scomposednode);
592 snode->restoreLinks(); //restore links
593 //refresh all views
594 scomposednode->update(PASTE, ProcInvoc::getTypeOfNode(node), snode);
595 snode->recursiveUpdate(RENAME, 0, snode);
596 snode->select(true);
597 }
598 catch (Exception& ex)
599 {
600 DEBTRACE("CommandPutInComposedNode::localExecute() : " << ex.what());
602 node = 0;
603 }
604 catch (...)
605 {
606 GuiContext::getCurrent()->_lastErrorMessage = "Unknown exception";
607 node = 0;
608 }
609 return (node != 0);
610}
611
613{
614 DEBTRACE("CommandPutInComposedNode::localReverse");
616 Node* node = 0;
617 try
618 {
619 YASSERT(_newpos != proc->getName())
620 node = proc->getChildByName(_newpos);
621 ComposedNode *oldFather = node->getFather();
624 SubjectComposedNode* sop = dynamic_cast<SubjectComposedNode*>(subo);
625 //save existing links
626 snode->saveLinks();
627 //remove external links
628 snode->removeExternalLinks();
630 //remove subject node from subject old father
631 sop->houseKeepingAfterCutPaste(true, snode);
632 //remove node from old father
633 oldFather->edRemoveChild(node);
634 //refresh node views, temporary paste in proc to keep widgets associated to node
635 sop->update(CUT, ProcInvoc::getTypeOfNode(node), snode);
637
638 //remove composed node oldFather
639 ComposedNode *oldGrandFather = oldFather->getFather();
640 Subject *subog = GuiContext::getCurrent()->_mapOfSubjectNode[oldGrandFather];
641 SubjectComposedNode* sogp = dynamic_cast<SubjectComposedNode*>(subog);
642 Subject::erase(sop);
643
644 //add the old node as child of new composednode
645 oldGrandFather->edAddChild(node);
646 _newpos = proc->getChildName(node);
647 //add the subject node to subject composednode
648 sogp->houseKeepingAfterCutPaste(false, snode);
649 snode->setParent(sogp);
650 //restore links
651 snode->restoreLinks();
652 //refresh all views
654 sogp->update(PASTE, ProcInvoc::getTypeOfNode(node), snode);
655 snode->recursiveUpdate(RENAME, 0, snode);
656 snode->select(true);
657 }
658 catch (Exception& ex)
659 {
660 DEBTRACE("CommandPutInComposedNode::localReverse() : " << ex.what());
662 node = 0;
663 }
664 return (node != 0);
665}
666// ----------------------------------------------------------------------------
667
669 std::string position,
670 std::string newParent,
671 int swCase)
672 : Command(), _fromproc(fromproc), _position(position), _newParent(newParent), _newName(""), _clone(0), _case(swCase)
673{
674 DEBTRACE("CommandCopyNode::CommandCopyNode " << _position << " " << _newParent);
675}
676
678{
679 string ret ="CommandCopyNode " + _position + " " + _newParent;
680 return ret;
681}
682
684{
685 return _clone;
686}
687
689{
690 DEBTRACE("CommandCopyNode::localExecute");
692 Node* node = 0;
693 try
694 {
695 if (_position == _fromproc->getName())
696 throw YACS::Exception("Copy the proc (main bloc) is impossible");
698 ComposedNode *oldFather = node->getFather();
699 ComposedNode *newFather = proc;
700 Node *newF = 0;
701 if (_newParent != proc->getName())
702 {
703 newF = proc->getChildByName(_newParent);
704 newFather = dynamic_cast<ComposedNode*>(newF);
705 }
706 if (!newFather)
707 throw YACS::Exception("new parent must be a composed node");
708 if (Loop *loop = dynamic_cast<Loop*>(newFather))
709 if (!loop->edGetDirectDescendants().empty())
710 throw YACS::Exception("Already a node in a new parent of Loop type");
711 //_clone = node->cloneWithoutCompAndContDeepCpy(newFather);
713 if (!_clone)
714 throw YACS::Exception("Node cannot be cloned");
715 int nodeSuffix = -1;
716 bool sameName = true;
717 stringstream s;
718 do
719 {
720 s.str("");
721 s << node->getName();
722 if (nodeSuffix >= 0) // --- first try <0 means without suffix
723 s << nodeSuffix;
724 DEBTRACE(s.str());
725 try
726 {
727 Node *nodeSameName = newFather->getChildByName(s.str());
728 }
729 catch (Exception& e)
730 {
731 sameName = false;
732 }
733 nodeSuffix++;
734 }
735 while(sameName);
736 _clone->setName(s.str());
738
739 if (YACS::ENGINE::Switch* theswitch = dynamic_cast<YACS::ENGINE::Switch*>(newFather))
740 {
741 DEBTRACE("father is a switch " << newFather->getName());
742 int theCase=_case;
743 if(theswitch->edGetNode(_case))
744 {
745 //the case is already used. Try another one
746 theCase=theswitch->getMaxCase()+1;
747 }
748 theswitch->edSetNode(theCase,_clone);
749 }
750 else
751 newFather->edAddChild(_clone);
752
755
757 SubjectComposedNode *snp = dynamic_cast<SubjectComposedNode*>(sub);
758 SubjectNode *son = snp->addSubjectNode(_clone);
759 son->loadChildren();
760 son->loadLinks();
761 }
762 catch (Exception& ex)
763 {
764 DEBTRACE("CommandCopyNode::localExecute() : " << ex.what());
766 _clone = 0;
767 }
768 return (_clone != 0);
769}
770
772{
773 DEBTRACE("CommandCopyNode::localReverse " << _position << " " << _newParent);
774 try
775 {
777 string nodeName = _newParent + "." + _newName;
778 if (_newParent == proc->getName())
779 nodeName = _newName;
780 DEBTRACE(nodeName);
781 _clone = proc->getChildByName(nodeName);
782
783 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(_clone));
785 Subject *father = snode->getParent();
786 Subject::erase(snode);
787 _clone = 0;
788 if (father)
789 {
790 DEBTRACE("REMOVE");
791 father->select(true);
792 father->update(REMOVE,0,0);
793 }
794 return true;
795 }
796 catch (Exception& ex)
797 {
798 DEBTRACE("CommandCopyNode::localReverse(): " << ex.what());
800 return false;
801 }
802 return true;
803}
804
805// ----------------------------------------------------------------------------
806
807CommandRenameNode::CommandRenameNode(std::string position, std::string name)
808 : Command(), _position(position), _name(name)
809{
810 DEBTRACE("CommandRenameNode::CommandRenameNode " << _position << " " << _name);
811 _oldName ="";
812 _newpos="";
813}
814
816{
817 string ret ="CommandRenameNode " + _position + " " + _name;
818 return ret;
819}
820
822{
823 DEBTRACE("CommandRenameNode::localExecute");
825 Node* node = proc;
826 try
827 {
828 if (_position != proc->getName()) node = proc->getChildByName(_position);
829 _oldName = node->getName();
830 node->setName(_name);
831 if (node == proc)
832 _newpos = _name;
833 else
834 _newpos = proc->getChildName(node);
836 if (snode)
837 snode->recursiveUpdate(RENAME, 0, snode);
838 }
839 catch (Exception& ex)
840 {
841 DEBTRACE("CommandRenameNode::localExecute() : " << ex.what());
843 node = 0;
844 }
845 return (node != 0);
846}
847
849{
850 DEBTRACE("CommandRenameNode::localReverse");
852 Node* node = proc;
853 try
854 {
855 if (_newpos != proc->getName()) node = proc->getChildByName(_newpos);
856 YASSERT(node->getName() == _name);
857 node->setName(_oldName);
859 if (snode)
860 snode->recursiveUpdate(RENAME, 0, snode);
861 }
862 catch (Exception& ex)
863 {
864 DEBTRACE("CommandRenameNode::localReverse() : " << ex.what());
866 node = 0;
867 }
868 return (node != 0);
869}
870
871// ----------------------------------------------------------------------------
872
873CommandRenameContainer::CommandRenameContainer(std::string oldName, std::string newName)
874 : Command(), _oldName(oldName), _newName(newName)
875{
876 DEBTRACE("CommandRenameContainer::CommandRenameContainer " << _oldName << " " << _newName);
877}
878
880{
881 string ret ="CommandRenameContainer " +_oldName + " " + _newName;
882 return ret;
883}
884
886{
887 DEBTRACE("CommandRenameContainer::localExecute");
889 Container *container = 0;
890 try
891 {
892 YASSERT(proc->containerMap.count(_oldName));
893 container = proc->containerMap[_oldName];
894 if (proc->containerMap.count(_newName))
895 {
896 GuiContext::getCurrent()->_lastErrorMessage = "Container name already existing";
897 return 0;
898 }
899 proc->containerMap.erase(_oldName);
900 container->setName(_newName);
901 proc->containerMap[_newName] = container;
902 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
903 SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[container]);
904 scont-> update(RENAME, 0, scont);
906 }
907 catch (Exception& ex)
908 {
909 DEBTRACE("CommandRenameContainer::localExecute() : " << ex.what());
911 container = 0;
912 }
913 return (container != 0);
914}
915
917{
918 DEBTRACE("CommandRenameContainer::localReverse");
920 Container *container = 0;
921 try
922 {
923 YASSERT(proc->containerMap.count(_newName));
924 container = proc->containerMap[_newName];
925 proc->containerMap.erase(_newName);
926 container->setName(_oldName);
927 proc->containerMap[_oldName] = container;
928 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
929 SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[container]);
930 scont-> update(RENAME, 0, scont);
932 }
933 catch (Exception& ex)
934 {
935 DEBTRACE("CommandRenameContainer::localReverse() : " << ex.what());
937 container = 0;
938 }
939 return (container != 0);
940}
941
942// ----------------------------------------------------------------------------
943
945 std::string oldName,
946 std::string newName, TypeOfElem portType)
947 : Command(), _position(position), _oldName(oldName), _newName(newName), _portType(portType)
948{
949 DEBTRACE("CommandRenameInDataPort::CommandRenameInDataPort "
950 << _position << " " << _oldName<< " " << _newName);
951}
952
954{
955 string ret ="CommandRenameInDataPort " + _position + " " + _oldName + " " + _newName;
956 return ret;
957}
958
960{
961 DEBTRACE("CommandRenameInDataPort::localExecute");
963 Node* node = proc;
964 try
965 {
966 if (_position != proc->getName()) node = proc->getChildByName(_position);
967 InPort * port = 0;
968
969 try
970 {
972 port = node->getInputPort(_newName);
973 else
974 port = node->getInputDataStreamPort(_newName);
975 }
976 catch (Exception& e) {} // --- raised when no existing port with _newName
977 if (port)
978 throw Exception("there is already a port with the new name");
979
981 port = node->getInputPort(_oldName);
982 else
983 port = node->getInputDataStreamPort(_oldName);
984 port->setName(_newName);
985 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
987 sport->update(RENAME, 0, sport);
988 }
989 catch (Exception& ex)
990 {
991 DEBTRACE("CommandRenameInDataPort::localExecute() : " << ex.what());
993 node = 0;
994 }
995 return (node != 0);
996}
997
999{
1000 DEBTRACE("CommandRenameInDataPort::localReverse");
1001 Proc* proc = GuiContext::getCurrent()->getProc();
1002 Node* node = proc;
1003 try
1004 {
1005 if (_position != proc->getName()) node = proc->getChildByName(_position);
1006 InPort * port = 0;
1007
1008 try
1009 {
1010 if(_portType==INPUTPORT)
1011 port = node->getInputPort(_oldName);
1012 else
1013 port = node->getInputDataStreamPort(_oldName);
1014 }
1015 catch (Exception& e) {} // --- raised when no existing port with _newName
1016 if (port)
1017 throw Exception("there is already a port with the old name");
1018
1019 if(_portType==INPUTPORT)
1020 port = node->getInputPort(_newName);
1021 else
1022 port = node->getInputDataStreamPort(_newName);
1023 port->setName(_oldName);
1024 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
1026 sport->update(RENAME, 0, sport);
1027 }
1028 catch (Exception& ex)
1029 {
1030 DEBTRACE("CommandRenameInDataPort::localReverse() : " << ex.what());
1031 setErrorMsg(ex);
1032 node = 0;
1033 }
1034 return (node != 0);
1035}
1036
1037// ----------------------------------------------------------------------------
1038
1040 std::string oldName,
1041 std::string newName, TypeOfElem portType)
1042 : Command(), _position(position), _oldName(oldName), _newName(newName), _portType(portType)
1043{
1044 DEBTRACE("CommandRenameOutDataPort::CommandRenameOutDataPort "
1045 << _position << " " << _oldName<< " " << _newName);
1046}
1047
1049{
1050 string ret ="CommandRenameOutDataPort " + _position + " " + _oldName + " " + _newName;
1051 return ret;
1052}
1053
1055{
1056 DEBTRACE("CommandRenameOutDataPort::localExecute");
1057 Proc* proc = GuiContext::getCurrent()->getProc();
1058 Node* node = proc;
1059 try
1060 {
1061 if (_position != proc->getName()) node = proc->getChildByName(_position);
1062 OutPort * port = 0;
1063 try
1064 {
1066 port = node->getOutputPort(_newName);
1067 else
1068 port = node->getOutputDataStreamPort(_newName);
1069 }
1070 catch (Exception& e) {} // --- raised when no existing port with _newName
1071 if (port)
1072 throw Exception("there is already a port with the new name");
1073
1075 port = node->getOutputPort(_oldName);
1076 else
1077 port = node->getOutputDataStreamPort(_oldName);
1078 port->setName(_newName);
1079 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
1081 sport->update(RENAME, 0, sport);
1082 }
1083 catch (Exception& ex)
1084 {
1085 DEBTRACE("CommandRenameOutDataPort::localExecute() : " << ex.what());
1086 setErrorMsg(ex);
1087 node = 0;
1088 }
1089 return (node != 0);
1090}
1091
1093{
1094 DEBTRACE("CommandRenameOutDataPort::localReverse");
1095 Proc* proc = GuiContext::getCurrent()->getProc();
1096 Node* node = proc;
1097 try
1098 {
1099 if (_position != proc->getName()) node = proc->getChildByName(_position);
1100 OutPort * port = 0;
1101 try
1102 {
1104 port = node->getOutputPort(_oldName);
1105 else
1106 port = node->getOutputDataStreamPort(_oldName);
1107 }
1108 catch (Exception& e) {} // --- raised when no existing port with _newName
1109 if (port)
1110 throw Exception("there is already a port with the old name");
1111
1113 port = node->getOutputPort(_newName);
1114 else
1115 port = node->getOutputDataStreamPort(_newName);
1116 port->setName(_oldName);
1117 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(port));
1119 sport->update(RENAME, 0, sport);
1120 }
1121 catch (Exception& ex)
1122 {
1123 DEBTRACE("CommandRenameOutDataPort::localReverse() : " << ex.what());
1124 setErrorMsg(ex);
1125 node = 0;
1126 }
1127 return (node != 0);
1128}
1129
1130// ----------------------------------------------------------------------------
1131
1133 std::string typeName)
1134 : Command(), _catalog(catalog), _typeName(typeName)
1135{
1136 DEBTRACE("CommandAddDataTypeFromCatalog::CommandAddDataTypeFromCatalog: " << typeName);
1137}
1138
1140{
1141 string ret ="CommandAddDataTypeFromCatalog " + _typeName;
1142 return ret;
1143}
1144
1146{
1147
1148 if (GuiContext::getCurrent()->getProc()->typeMap.count(_typeName))
1150 else return 0;
1151}
1152
1154{
1155 DEBTRACE("CommandAddDataTypeFromCatalog::localExecute");
1156 Proc* proc = GuiContext::getCurrent()->getProc();
1157 if (proc->typeMap.count(_typeName))
1158 {
1159 DEBTRACE("typecode already existing in proc: " << _typeName);
1160 GuiContext::getCurrent()->_lastErrorMessage = "typeCode already existing in proc: " + _typeName;
1161 return false;
1162 }
1163 else
1164 if (_catalog->_typeMap.count(_typeName))
1165 {
1166 DEBTRACE("typecode found in catalog, cloned: " << _typeName);
1167 proc->typeMap[_typeName] = _catalog->_typeMap[_typeName]->clone();
1168 proc->typeMap[_typeName]->incrRef();
1171 return (son!=0);
1172 }
1173 GuiContext::getCurrent()->_lastErrorMessage = "typecode not found in catalog: " + _typeName;
1174 return false;
1175}
1176
1178{
1179 DEBTRACE("CommandAddDataTypeFromCatalog::localReverse");
1180 try
1181 {
1184 return true;
1185 }
1186 catch (Exception& ex)
1187 {
1188 DEBTRACE("CommandAddDataTypeFromCatalog::localReverse(): " << ex.what());
1189 setErrorMsg(ex);
1190 return 0;
1191 }
1192}
1193
1194
1195// ----------------------------------------------------------------------------
1196
1198 std::string type,
1199 std::string node,
1200 std::string name)
1201 : Command(), _catalog(catalog), _typePort(type), _node(node), _name(name)
1202{
1203 _inputPort = 0;
1204 _sip = 0;
1205}
1206
1208{
1209 string ret ="CommandAddInputPortFromCatalog " + _typePort + " " + _node + " " + _name;
1210 return ret;
1211}
1212
1214{
1215 return _inputPort;
1216}
1217
1219{
1220 return _sip;
1221}
1222
1224{
1225 DEBTRACE("CommandAddInputPortFromCatalog::localExecute");
1226 InputPort *son = 0;
1227 try
1228 {
1229 Proc* proc = GuiContext::getCurrent()->getProc();
1230 Node* node = proc->getChildByName(_node);
1231 ElementaryNode* father = dynamic_cast<ElementaryNode*>(node);
1232 if (father)
1233 {
1234 //try proc types and then catalog if not in proc
1235 if(proc->typeMap.count(_typePort))
1236 son = father->edAddInputPort(_name, proc->typeMap[_typePort]);
1237 else if (_catalog->_typeMap.count(_typePort))
1239 else
1240 {
1241 DEBTRACE(_typePort << " not found in catalog " << _catalog);
1242 GuiContext::getCurrent()->_lastErrorMessage = _typePort + " not found in catalog";
1243 }
1244 }
1245 _inputPort = son;
1246 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1248 _sip = snode->addSubjectInputPort(son, _name);
1249 snode->update(SYNCHRO,0,0); // when output port tab in node edition is visible
1250 }
1251 catch (Exception& ex)
1252 {
1253 DEBTRACE("CommandAddInputPortFromCatalog::localExecute() : " << ex.what());
1254 setErrorMsg(ex);
1255 if (son) delete son;
1256 _inputPort = 0;
1257 }
1258 return (_inputPort != 0);
1259}
1260
1262{
1263 DEBTRACE("CommandAddInputPortFromCatalog::localReverse");
1264 try
1265 {
1266 Proc* proc = GuiContext::getCurrent()->getProc();
1267 Node *node = proc->getChildByName(_node);
1268 ElementaryNode* enode = dynamic_cast<ElementaryNode*>(node);
1269 YASSERT(enode);
1270 _inputPort = enode->getInputPort(_name);
1272 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(_inputPort));
1274 YASSERT(_sip);
1275
1276 Subject *father=_sip->getParent();
1278 _sip = 0;
1279 _inputPort = 0;
1280 if (father)
1281 {
1282 DEBTRACE("REMOVE");
1283 father->select(true);
1284 father->update(REMOVE,0,0);
1285 }
1286 return true;
1287 }
1288 catch (Exception& ex)
1289 {
1290 DEBTRACE("CommandAddInputPortFromCatalog::localReverse(): " << ex.what());
1291 setErrorMsg(ex);
1292 return false;
1293 }
1294}
1295
1296// ----------------------------------------------------------------------------
1297
1299 std::string type,
1300 std::string node,
1301 std::string name)
1302 : Command(), _catalog(catalog), _typePort(type), _node(node), _name(name)
1303{
1304 _outputPort = 0;
1305 _sop = 0;
1306}
1307
1309{
1310 string ret ="CommandAddOutputPortFromCatalog " + _typePort + " " + _node + " " + _name;
1311 return ret;
1312}
1313
1315{
1316 return _outputPort;
1317}
1318
1320{
1321 return _sop;
1322}
1323
1325{
1326 DEBTRACE("CommandAddOutputPortFromCatalog::localExecute");
1327 OutputPort *son = 0;
1328 try
1329 {
1330 Proc* proc = GuiContext::getCurrent()->getProc();
1331 Node* node = proc->getChildByName(_node);
1332 ElementaryNode* father =dynamic_cast<ElementaryNode*> (node);
1333 if (father)
1334 {
1335 //try proc types and then catalog if not in proc
1336 if(proc->typeMap.count(_typePort))
1337 son = father->edAddOutputPort(_name, proc->typeMap[_typePort]);
1338 else if (_catalog->_typeMap.count(_typePort))
1340 else
1341 {
1342 DEBTRACE(_typePort << " not found in catalog");
1343 GuiContext::getCurrent()->_lastErrorMessage = _typePort + " not found in catalog";
1344 }
1345 }
1346 _outputPort = son;
1347 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1349 _sop = snode->addSubjectOutputPort(son, _name);
1350 snode->update(SYNCHRO,0,0); // when input port tab in node edition is visible
1351 }
1352 catch (Exception& ex)
1353 {
1354 DEBTRACE("CommandAddOutputPortFromCatalog::localExecute() : " << ex.what());
1355 setErrorMsg(ex);
1356 if (son) delete son;
1357 _outputPort = 0;
1358 }
1359 return (_outputPort != 0);
1360}
1361
1363{
1364 DEBTRACE("CommandAddOutputPortFromCatalog::localReverse");
1365 try
1366 {
1367 Proc* proc = GuiContext::getCurrent()->getProc();
1368 Node *node = proc->getChildByName(_node);
1369 ElementaryNode* enode = dynamic_cast<ElementaryNode*>(node);
1370 YASSERT(enode);
1373 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(_outputPort));
1375 YASSERT(_sop);
1376
1377 Subject *father=_sop->getParent();
1379 _sop = 0;
1380 _outputPort = 0;
1381 if (father)
1382 {
1383 DEBTRACE("REMOVE");
1384 father->select(true);
1385 father->update(REMOVE,0,0);
1386 }
1387 return true;
1388 }
1389 catch (Exception& ex)
1390 {
1391 DEBTRACE("CommandAddOutputPortFromCatalog::localReverse(): " << ex.what());
1392 setErrorMsg(ex);
1393 return false;
1394 }
1395}
1396
1397// ----------------------------------------------------------------------------
1398
1400 std::string type,
1401 std::string node,
1402 std::string name)
1403 : Command(), _catalog(catalog), _typePort(type), _node(node), _name(name)
1404{
1405 _IDSPort = 0;
1406 _sip = 0;
1407}
1408
1410{
1411 string ret ="CommandAddIDSPortFromCatalog " + _typePort + " " + _node + " " + _name;
1412 return ret;
1413}
1414
1416{
1417 DEBTRACE("CommandAddIDSPortFromCatalog");
1418 return _IDSPort;
1419}
1420
1422{
1423 return _sip;
1424}
1425
1427{
1428 DEBTRACE("CommandAddIDSPortFromCatalog::localExecute");
1429 InputDataStreamPort *son = 0;
1430 try
1431 {
1432 Proc* proc = GuiContext::getCurrent()->getProc();
1433 Node* node = proc->getChildByName(_node);
1434 ElementaryNode* father =dynamic_cast<ElementaryNode*> (node);
1435 if (father)
1436 {
1437 if (_catalog->_typeMap.count(_typePort))
1439 else
1440 {
1441 DEBTRACE(_typePort << " not found in catalog");
1442 GuiContext::getCurrent()->_lastErrorMessage = _typePort + " not found in catalog";
1443 }
1444 }
1445 _IDSPort = son;
1446 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1448 _sip = snode->addSubjectIDSPort(son, _name);
1449 }
1450 catch (Exception& ex)
1451 {
1452 DEBTRACE("CommandAddIDSPortFromCatalog::localExecute() : " << ex.what());
1453 setErrorMsg(ex);
1454 if (son) delete son;
1455 _IDSPort = 0;
1456 }
1457 return (_IDSPort != 0);
1458}
1459
1461{
1462 DEBTRACE("CommandAddIDSPortFromCatalog::localReverse");
1463 try
1464 {
1465 Proc* proc = GuiContext::getCurrent()->getProc();
1466 Node *node = proc->getChildByName(_node);
1467 ElementaryNode* enode = dynamic_cast<ElementaryNode*>(node);
1468 YASSERT(enode);
1471 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(_IDSPort));
1473 YASSERT(_sip);
1474
1475 Subject *father=_sip->getParent();
1477 _IDSPort =0;
1478 _sip = 0;
1479 if (father)
1480 {
1481 DEBTRACE("REMOVE");
1482 father->select(true);
1483 father->update(REMOVE,0,0);
1484 }
1485 return true;
1486 }
1487 catch (Exception& ex)
1488 {
1489 DEBTRACE("CommandAddIDSPortFromCatalog::localReverse(): " << ex.what());
1490 setErrorMsg(ex);
1491 return false;
1492 }
1493}
1494
1495// ----------------------------------------------------------------------------
1496
1498 std::string type,
1499 std::string node,
1500 std::string name)
1501 : Command(), _catalog(catalog), _typePort(type), _node(node), _name(name)
1502{
1503 DEBTRACE("CommandAddODSPortFromCatalog");
1504 _ODSPort = 0;
1505 _sop = 0;
1506}
1507
1509{
1510 string ret ="CommandAddODSPortFromCatalog " + _typePort + " " + _node + " " + _name;
1511 return ret;
1512}
1513
1515{
1516 return _ODSPort;
1517}
1518
1520{
1521 return _sop;
1522}
1523
1525{
1526 DEBTRACE("CommandAddODSPortFromCatalog::localExecute");
1527 OutputDataStreamPort *son = 0;
1528 try
1529 {
1530 Proc* proc = GuiContext::getCurrent()->getProc();
1531 Node* node = proc->getChildByName(_node);
1532 ElementaryNode* father =dynamic_cast<ElementaryNode*> (node);
1533 if (father)
1534 {
1535 if (_catalog->_typeMap.count(_typePort))
1537 else
1538 {
1539 DEBTRACE(_typePort << " not found in catalog");
1540 GuiContext::getCurrent()->_lastErrorMessage = _typePort + " not found in catalog";
1541 }
1542 }
1543 _ODSPort = son;
1544 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1546 _sop = snode->addSubjectODSPort(son, _name);
1547 }
1548 catch (Exception& ex)
1549 {
1550 DEBTRACE("CommandAddODSPortFromCatalog::localExecute() : " << ex.what());
1551 setErrorMsg(ex);
1552 if (son) delete son;
1553 _ODSPort = 0;
1554 }
1555 return (_ODSPort != 0);
1556}
1557
1559{
1560 DEBTRACE("CommandAddODSPortFromCatalog::localReverse");
1561 try
1562 {
1563 Proc* proc = GuiContext::getCurrent()->getProc();
1564 Node *node = proc->getChildByName(_node);
1565 ElementaryNode* enode = dynamic_cast<ElementaryNode*>(node);
1566 YASSERT(enode);
1569 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(_ODSPort));
1571 YASSERT(_sop);
1572
1573 Subject *father=_sop->getParent();
1575 _sop = 0;
1576 _ODSPort = 0;
1577 if (father)
1578 {
1579 DEBTRACE("REMOVE");
1580 father->select(true);
1581 father->update(REMOVE,0,0);
1582 }
1583 return true;
1584 }
1585 catch (Exception& ex)
1586 {
1587 DEBTRACE("CommandAddODSPortFromCatalog::localReverse(): " << ex.what());
1588 setErrorMsg(ex);
1589 return false;
1590 }
1591}
1592
1593// ----------------------------------------------------------------------------
1594
1599 std::string port,
1600 int isUp)
1601 : Command(), _node(node), _port(port), _isUp(isUp), _rank(-1)
1602{
1603 DEBTRACE("CommandOrderInputPorts");
1604}
1605
1607{
1608 ostringstream s;
1609 s << _isUp;
1610 string ret ="CommandOrderInputPorts " + _node + " " + _port + " " + s.str();
1611 return ret;
1612}
1613
1615{
1616 DEBTRACE("CommandOrderInputPorts::localExecute " << _node << " " << _port << " " << _isUp);
1617 ElementaryNode* father = 0;
1618 try
1619 {
1620 Proc* proc = GuiContext::getCurrent()->getProc();
1621 Node* node = proc->getChildByName(_node);
1622 father = dynamic_cast<ElementaryNode*> (node);
1623 if (!father) return false;
1624 InputPort *portToMove = father->getInputPort(_port);
1625 DEBTRACE(portToMove->getName());
1626
1627 list<InputPort*> plist = father->getSetOfInputPort();
1628 list<InputPort*>::iterator pos = find(plist.begin(), plist.end(), portToMove);
1629
1630 int isUp = _isUp;
1631 if (isUp)
1632 {
1633 if(pos == plist.begin())
1634 pos=plist.end(); // --- cycle
1635 else
1636 do { pos--; isUp--; } while (isUp);
1637 }
1638 else
1639 {
1640 pos++;
1641 if (pos == plist.end())
1642 pos = plist.begin(); // --- cycle
1643 else
1644 pos++; // --- insert before the 2nd next port
1645 }
1646
1647 InputPort *portBefore = 0;
1648 if (pos != plist.end())
1649 portBefore = (*pos);
1650
1651 plist.remove(portToMove);
1652 if (portBefore)
1653 {
1654 DEBTRACE(portBefore->getName());
1655 pos = find(plist.begin(), plist.end(), portBefore);
1656 _rank = 0;
1657 for (list<InputPort*>::iterator it = plist.begin(); it != pos; ++it)
1658 _rank++;
1659 plist.insert(pos, portToMove);
1660 }
1661 else
1662 {
1663 _rank = plist.size();
1664 plist.push_back(portToMove);
1665 }
1666 father->edOrderInputPorts(plist);
1667 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1670 snode->update(ORDER, true, sport);
1671 snode->update(SYNCHRO, true, sport); // --- synchronise edition and scene
1672 }
1673 catch (Exception& ex)
1674 {
1675 DEBTRACE("CommandOrderInputPorts::localExecute() : " << ex.what());
1676 setErrorMsg(ex);
1677 father = 0;
1678 }
1679 return (father != 0);
1680}
1681
1683{
1684 DEBTRACE("CommandOrderInputPorts::localReverse " << _node << " " << _port << " " << _isUp);
1685 ElementaryNode* father = 0;
1686 try
1687 {
1688 int isUpRev = -_isUp;
1689 if (isUpRev == 0) isUpRev =1;
1690 Proc* proc = GuiContext::getCurrent()->getProc();
1691 Node* node = proc->getChildByName(_node);
1692 father = dynamic_cast<ElementaryNode*> (node);
1693 if (!father) return false;
1694 InputPort *portToMove = father->getInputPort(_port);
1695 DEBTRACE(portToMove->getName());
1696
1697 list<InputPort*> plist = father->getSetOfInputPort();
1698 list<InputPort*>::iterator pos = find(plist.begin(), plist.end(), portToMove);
1699
1700 if (isUpRev>0)
1701 {
1702 if(pos == plist.begin())
1703 pos=plist.end(); // --- cycle
1704 else
1705 do { pos--; isUpRev--; } while (isUpRev);
1706 }
1707 else
1708 {
1709 pos++;
1710 if (pos == plist.end())
1711 pos = plist.begin(); // --- cycle
1712 else
1713 do { pos++; isUpRev++; } while (isUpRev<0);// --- insert before the 2nd next port
1714 }
1715
1716 InputPort *portBefore = 0;
1717 if (pos != plist.end())
1718 portBefore = (*pos);
1719
1720 plist.remove(portToMove);
1721 if (portBefore)
1722 {
1723 DEBTRACE(portBefore->getName());
1724 pos = find(plist.begin(), plist.end(), portBefore);
1725 _rank = 0;
1726 for (list<InputPort*>::iterator it = plist.begin(); it != pos; ++it)
1727 _rank++;
1728 plist.insert(pos, portToMove);
1729 }
1730 else
1731 {
1732 _rank = plist.size();
1733 plist.push_back(portToMove);
1734 }
1735 father->edOrderInputPorts(plist);
1736 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1739 snode->update(ORDER, true, sport);
1740 snode->update(SYNCHRO, true, sport); // --- synchronise edition and scene
1741 }
1742 catch (Exception& ex)
1743 {
1744 DEBTRACE("CommandOrderInputPorts::localExecute() : " << ex.what());
1745 setErrorMsg(ex);
1746 father = 0;
1747 }
1748 return (father != 0);
1749}
1750
1751// ----------------------------------------------------------------------------
1752
1757 std::string port,
1758 int isUp)
1759 : Command(), _node(node), _port(port), _isUp(isUp), _rank(-1)
1760{
1761 DEBTRACE("CommandOrderOutputPorts");
1762}
1763
1765{
1766 ostringstream s;
1767 s << _isUp;
1768 string ret ="CommandOrderOutputPorts " + _node + " " + _port + " " + s.str();
1769 return ret;
1770}
1771
1773{
1774 DEBTRACE("CommandOrderOutputPorts::localExecute " << _node << " " << _port << " " << _isUp);
1775 ElementaryNode* father = 0;
1776 try
1777 {
1778 Proc* proc = GuiContext::getCurrent()->getProc();
1779 Node* node = proc->getChildByName(_node);
1780 father = dynamic_cast<ElementaryNode*> (node);
1781 if (!father) return false;
1782 OutputPort *portToMove = father->getOutputPort(_port);
1783 DEBTRACE(portToMove->getName());
1784
1785 list<OutputPort*> plist = father->getSetOfOutputPort();
1786 list<OutputPort*>::iterator pos = find(plist.begin(), plist.end(), portToMove);
1787
1788 int isUp = _isUp;
1789 if (isUp)
1790 {
1791 if(pos == plist.begin())
1792 pos=plist.end(); // --- cycle
1793 else
1794 do { pos--; isUp--; } while (isUp);
1795 }
1796 else
1797 {
1798 pos++;
1799 if (pos == plist.end())
1800 pos = plist.begin(); // --- cycle
1801 else
1802 pos++; // --- insert before the 2nd next port
1803 }
1804
1805 OutputPort *portBefore = 0;
1806 if (pos != plist.end())
1807 portBefore = (*pos);
1808
1809 plist.remove(portToMove);
1810 if (portBefore)
1811 {
1812 DEBTRACE(portBefore->getName());
1813 pos = find(plist.begin(), plist.end(), portBefore);
1814 _rank = 0;
1815 for (list<OutputPort*>::iterator it = plist.begin(); it != pos; ++it)
1816 _rank++;
1817 plist.insert(pos, portToMove);
1818 }
1819 else
1820 {
1821 _rank = plist.size();
1822 plist.push_back(portToMove);
1823 }
1824 father->edOrderOutputPorts(plist);
1825 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1828 snode->update(ORDER, false, sport);
1829 snode->update(SYNCHRO, false, sport); // --- synchronise edition and scene
1830 }
1831 catch (Exception& ex)
1832 {
1833 DEBTRACE("CommandOrderOutputPorts::localExecute() : " << ex.what());
1834 setErrorMsg(ex);
1835 father = 0;
1836 }
1837 return (father != 0);
1838}
1839
1841{
1842 DEBTRACE("CommandOrderOutputPorts::localReverse " << _node << " " << _port << " " << _isUp);
1843 ElementaryNode* father = 0;
1844 try
1845 {
1846 int isUpRev = -_isUp;
1847 if (isUpRev == 0) isUpRev =1;
1848 Proc* proc = GuiContext::getCurrent()->getProc();
1849 Node* node = proc->getChildByName(_node);
1850 father = dynamic_cast<ElementaryNode*> (node);
1851 if (!father) return false;
1852 OutputPort *portToMove = father->getOutputPort(_port);
1853 DEBTRACE(portToMove->getName());
1854
1855 list<OutputPort*> plist = father->getSetOfOutputPort();
1856 list<OutputPort*>::iterator pos = find(plist.begin(), plist.end(), portToMove);
1857
1858 if (isUpRev>0)
1859 {
1860 if(pos == plist.begin())
1861 pos=plist.end(); // --- cycle
1862 else
1863 do { pos--; isUpRev--; } while (isUpRev);
1864 }
1865 else
1866 {
1867 pos++;
1868 if (pos == plist.end())
1869 pos = plist.begin(); // --- cycle
1870 else
1871 do { pos++; isUpRev++; } while (isUpRev<0);// --- insert before the 2nd next port
1872 }
1873
1874 OutputPort *portBefore = 0;
1875 if (pos != plist.end())
1876 portBefore = (*pos);
1877
1878 plist.remove(portToMove);
1879 if (portBefore)
1880 {
1881 DEBTRACE(portBefore->getName());
1882 pos = find(plist.begin(), plist.end(), portBefore);
1883 _rank = 0;
1884 for (list<OutputPort*>::iterator it = plist.begin(); it != pos; ++it)
1885 _rank++;
1886 plist.insert(pos, portToMove);
1887 }
1888 else
1889 {
1890 _rank = plist.size();
1891 plist.push_back(portToMove);
1892 }
1893 father->edOrderOutputPorts(plist);
1894 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1897 snode->update(ORDER, false, sport);
1898 snode->update(SYNCHRO, false, sport); // --- synchronise edition and scene
1899 }
1900 catch (Exception& ex)
1901 {
1902 DEBTRACE("CommandOrderOutputPorts::localExecute() : " << ex.what());
1903 setErrorMsg(ex);
1904 father = 0;
1905 }
1906 return (father != 0);
1907}
1908
1909// ----------------------------------------------------------------------------
1910
1912 std::string startnode, std::string startport, TypeOfElem startportType,
1913 std::string endnode, std::string endport, TypeOfElem endportType)
1914 : Command(), _elemType(elemType), _startnode(startnode), _startport(startport),
1915 _endnode(endnode), _endport(endport), _startportType(startportType), _endportType(endportType)
1916{
1917 DEBTRACE("CommandDestroy::CommandDestroy");
1918 _normalReverse = false;
1919}
1920
1922{
1923 string ret ="CommandDestroy " + ProcInvoc::getTypeName(_elemType);
1924 ret += " " + _startnode + " " + _startport;
1925 ret += " " + _endnode + " " + _endport;
1926 return ret;
1927}
1928
1930{
1931 DEBTRACE("CommandDestroy::localExecute");
1932 try
1933 {
1934 Proc* proc = GuiContext::getCurrent()->getProc();
1935 Subject *subject = 0;
1936 Subject *father = 0;
1937 switch (_elemType)
1938 {
1939 case SALOMEPROC:
1940 case BLOC:
1941 case FOREACHLOOP:
1942 case OPTIMIZERLOOP:
1943 case FORLOOP:
1944 case WHILELOOP:
1945 case SWITCH:
1946 case PYTHONNODE:
1947 case PYFUNCNODE:
1948 case CORBANODE:
1949 case SALOMENODE:
1950 case CPPNODE:
1951 case SALOMEPYTHONNODE:
1952 case XMLNODE:
1953 case SPLITTERNODE:
1954 case DFTODSFORLOOPNODE:
1955 case DSTODFFORLOOPNODE:
1956 case PRESETNODE:
1957 case OUTNODE:
1958 case STUDYINNODE:
1959 case STUDYOUTNODE:
1960 {
1961 Node* node = proc;
1962 if (!_startnode.empty()) node = proc->getChildByName(_startnode);
1963 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
1964 subject = GuiContext::getCurrent()->_mapOfSubjectNode[node];
1965 father = subject->getParent();
1966 }
1967 break;
1968 case INPUTPORT:
1969 {
1970 Node* node = proc->getChildByName(_startnode);
1971 InPort* inp = node->getInputPort(_startport);
1972 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(inp));
1974 father = subject->getParent();
1975 }
1976 break;
1978 {
1979 Node* node = proc->getChildByName(_startnode);
1981 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(inp));
1983 father = subject->getParent();
1984 }
1985 break;
1986 case OUTPUTPORT:
1987 {
1988 Node* node = proc->getChildByName(_startnode);
1989 OutPort* outp = node->getOutputPort(_startport);
1990 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
1992 father = subject->getParent();
1993 }
1994 break;
1996 {
1997 Node* node = proc->getChildByName(_startnode);
1999 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
2001 father = subject->getParent();
2002 }
2003 break;
2004 case DATALINK:
2005 {
2006 Node* outn = proc->getChildByName(_startnode);
2007 Node* inn = proc->getChildByName(_endnode);
2008
2009 OutPort* outp;
2010 InPort* inp;
2011
2013 outp = outn->getOutputPort(_startport);
2014 else
2015 outp = outn->getOutputDataStreamPort(_startport);
2016
2017 if(_endportType == INPUTPORT)
2018 inp = inn->getInputPort(_endport);
2019 else
2020 inp = inn->getInputDataStreamPort(_endport);
2021
2022 pair<OutPort*,InPort*> keymap = pair<OutPort*,InPort*>(outp,inp);
2023 YASSERT(GuiContext::getCurrent()->_mapOfSubjectLink.count(keymap));
2024 subject = GuiContext::getCurrent()->_mapOfSubjectLink[keymap];
2025 father = subject->getParent();
2026 }
2027 break;
2028 case CONTROLLINK:
2029 {
2030 Node* outn = proc->getChildByName(_startnode);
2031 Node* inn = proc->getChildByName(_endnode);
2032 pair<Node*,Node*> keymap = pair<Node*,Node*>(outn,inn);
2033 YASSERT(GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keymap));
2035 father = subject->getParent();
2036 }
2037 break;
2038 case CONTAINER:
2039 {
2040 Container *container = proc->containerMap[_startnode];
2041 subject = GuiContext::getCurrent()->_mapOfSubjectContainer[container];
2042 break;
2043 }
2044 case COMPONENT:
2045 case REFERENCE:
2046 case DATATYPE:
2047 case UNKNOWN:
2048 throw Exception("Command Destroy not implemented for that type");
2049 break;
2050 }
2051 YASSERT(subject);
2052 Subject::erase(subject);
2053 if (father)
2054 {
2055 father->select(true);
2056 father->update(REMOVE, 0, 0);
2057 }
2058 subject = 0;
2059 return true;
2060 }
2061 catch (Exception& ex)
2062 {
2063 DEBTRACE("CommandDestroy::localExecute() : " << ex.what());
2064 setErrorMsg(ex);
2065 return false;
2066 }
2067}
2068
2070{
2071 DEBTRACE("CommandDestroy::localReverse");
2073 return true;
2074}
2075
2076// ----------------------------------------------------------------------------
2077
2079 std::string port,
2080 std::string value)
2081 : Command(), _node(node), _port(port), _value(value)
2082{
2083 DEBTRACE("CommandSetInPortValue::CommandSetInPortValue " << node << " " << port << " " << value);
2084 _oldValue = "";
2085}
2086
2088{
2089 string ret ="CommandSetInPortValue " + _node + " " + _port + " " + _value;
2090 return ret;
2091}
2092
2094{
2095 DEBTRACE("CommandSetInPortValue::localExecute");
2096 InputPort* inp ;
2097 InputPresetPort *inpp = 0;
2098 InputStudyPort *insp = 0;
2099 DataNode *dnode = 0;
2100 SubjectDataPort *sinp = 0;
2101 try
2102 {
2103 Proc* proc = GuiContext::getCurrent()->getProc();
2104 Node* node = proc->getChildByName(_node);
2105 inp = node->getInputPort(_port);
2106 inpp = dynamic_cast<InputPresetPort*>(inp);
2107 insp = dynamic_cast<InputStudyPort*>(inp);
2108 dnode = dynamic_cast<DataNode*>(node);
2109 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(inp));
2111 }
2112 catch (Exception& ex)
2113 {
2114 DEBTRACE("CommandSetInPortValue::localExecute() : " << ex.what());
2115 setErrorMsg(ex);
2116 return false;
2117 }
2118
2119 if(insp && dnode)
2120 {
2121 //It's a study port
2122 _oldValue = insp->getAsString();
2123 DEBTRACE("old value="<< _oldValue);
2124 dnode->setData(insp, _value );
2125 sinp->update(SETVALUE, 0, sinp);
2126 return true;
2127 }
2128
2129 PyObject *result;
2130 PyGILState_STATE gstate = PyGILState_Ensure();
2131 try
2132 {
2133 _oldValue = inp->getAsString();
2134 if (_oldValue == "None") _oldValue = "";
2135 DEBTRACE("old value="<< _oldValue);
2136 std::string strval;
2137 if (inp->edGetType()->kind() == YACS::ENGINE::String || inp->edGetType()->isA(Runtime::_tc_file))
2138 strval = "\"" + _value + "\"";
2139 else
2140 strval = _value;
2141 result = YACS::ENGINE::getSALOMERuntime()->convertStringToPyObject(strval.c_str());
2142 inp->edInit("Python", result);
2143 Py_DECREF(result);
2144
2145 PyGILState_Release(gstate);
2146 sinp->update(SETVALUE, 0, sinp);
2147 return true;
2148 }
2149 catch (Exception& ex)
2150 {
2151 DEBTRACE("CommandSetInPortValue::localExecute() : " << ex.what());
2152 //Py_DECREF(result);
2153 PyGILState_Release(gstate);
2154 setErrorMsg(ex);
2155 return false;
2156 }
2157}
2158
2160{
2161 DEBTRACE("CommandSetInPortValue::localReverse");
2162 InputPort* inp ;
2163 InputPresetPort *inpp = 0;
2164 InputStudyPort *insp = 0;
2165 DataNode *dnode = 0;
2166 SubjectDataPort *sinp = 0;
2167 try
2168 {
2169 Proc* proc = GuiContext::getCurrent()->getProc();
2170 Node* node = proc->getChildByName(_node);
2171 inp = node->getInputPort(_port);
2172 inpp = dynamic_cast<InputPresetPort*>(inp);
2173 insp = dynamic_cast<InputStudyPort*>(inp);
2174 dnode = dynamic_cast<DataNode*>(node);
2175 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(inp));
2177 }
2178 catch (Exception& ex)
2179 {
2180 DEBTRACE("CommandSetInPortValue::localExecute() : " << ex.what());
2181 setErrorMsg(ex);
2182 return false;
2183 }
2184
2185 if(insp && dnode)
2186 {
2187 //It's a study port
2188 _value = insp->getAsString();
2189 DEBTRACE("value="<< _value);
2190 DEBTRACE("old value="<< _oldValue);
2191 dnode->setData(insp, _oldValue );
2192 sinp->update(SETVALUE, 0, sinp);
2193 return true;
2194 }
2195
2196 PyObject *result = Py_None;
2197 PyGILState_STATE gstate = PyGILState_Ensure();
2198 try
2199 {
2200 _value = inp->getAsString();
2201 DEBTRACE("value="<< _value);
2202 DEBTRACE("old value="<< _oldValue);
2203 if (!_oldValue.empty())
2204 {
2205 std::string strval;
2206 if (inp->edGetType()->kind() == YACS::ENGINE::String || inp->edGetType()->isA(Runtime::_tc_file))
2207 strval = "\"" + _oldValue + "\"";
2208 else
2209 strval = _oldValue;
2210 result = YACS::ENGINE::getSALOMERuntime()->convertStringToPyObject(strval.c_str());
2211 }
2212 inp->edInit("Python", result);
2213 Py_DECREF(result);
2214 PyGILState_Release(gstate);
2215 sinp->update(SETVALUE, 0, sinp);
2216 return true;
2217 }
2218 catch (Exception& ex)
2219 {
2220 DEBTRACE("CommandSetInPortValue::localExecute() : " << ex.what());
2221 //Py_DECREF(result);
2222 PyGILState_Release(gstate);
2223 setErrorMsg(ex);
2224 return false;
2225 }
2226}
2227
2228// ----------------------------------------------------------------------------
2229
2231 std::string port,
2232 std::string value)
2233 : Command(), _node(node), _port(port), _value(value)
2234{
2235 DEBTRACE("CommandSetOutPortValue::CommandSetOutPortValue " << node << " " << port << " " << value);
2236 _oldValue = "";
2237}
2238
2240{
2241 string ret ="CommandSetOutPortValue " + _node + " " + _port + " " + _value;
2242 return ret;
2243}
2244
2246{
2247 DEBTRACE("CommandSetOutPortValue::localExecute");
2248 OutputPresetPort *outpp = 0;
2249 OutputStudyPort *outsp = 0;
2250 DataNode *dnode = 0;
2251 SubjectDataPort *soutp = 0;
2252 try
2253 {
2254 Proc* proc = GuiContext::getCurrent()->getProc();
2255 Node* node = proc->getChildByName(_node);
2256 OutputPort* outp = node->getOutputPort(_port);
2257 outpp = dynamic_cast<OutputPresetPort*>(outp);
2258 outsp = dynamic_cast<OutputStudyPort*>(outp);
2259 dnode = dynamic_cast<DataNode*>(node);
2260 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
2262 }
2263 catch (Exception& ex)
2264 {
2265 DEBTRACE("CommandSetOutPortValue::localExecute() : " << ex.what());
2266 setErrorMsg(ex);
2267 return false;
2268 }
2269
2270 if (!outpp && !outsp)
2271 {
2272 DEBTRACE("Set value on output port only possible on a presetPort or a studyPort");
2273 GuiContext::getCurrent()->_lastErrorMessage = "Set value on output port only possible on a presetPort or a studyPort";
2274 return false;
2275 }
2276
2277 if (!dnode)
2278 {
2279 DEBTRACE("Set value on output port only possible on a dataNode");
2280 GuiContext::getCurrent()->_lastErrorMessage = "Set value on output port only possible on a dataNode";
2281 return false;
2282 }
2283
2284 if(outsp)
2285 {
2286 //It's a study port
2287 _oldValue = outsp->getAsString();
2288 DEBTRACE("old value="<< _oldValue);
2289 dnode->setData(outsp, _value );
2290 soutp->update(SETVALUE, 0, soutp);
2291 return true;
2292 }
2293
2294 PyObject *result;
2295 try
2296 {
2297 _oldValue = outpp->getAsString();
2298 if (_oldValue == "None") _oldValue = "";
2299 DEBTRACE("old value="<< _oldValue);
2300 std::string strval;
2301 if (outpp->edGetType()->kind() == YACS::ENGINE::String || outpp->edGetType()->isA(Runtime::_tc_file))
2302 strval = "\"" + _value + "\"";
2303 else
2304 strval = _value;
2305 result = YACS::ENGINE::getSALOMERuntime()->convertStringToPyObject(strval.c_str());
2306 }
2307 catch (Exception& ex)
2308 {
2309 DEBTRACE("CommandSetOutPortValue::localExecute() : " << ex.what());
2310 setErrorMsg(ex);
2311 return false;
2312 }
2313
2314 string val;
2315 PyGILState_STATE gstate = PyGILState_Ensure();
2316 try
2317 {
2318 DEBTRACE(PyObject_Str(result));
2319 val = convertPyObjectXml(outpp->edGetType(), result);
2320 DEBTRACE(val);
2321 dnode->setData(outpp, val );
2322 soutp->update(SETVALUE, 0, soutp);
2323 }
2324 catch (Exception& ex)
2325 {
2326 DEBTRACE("CommandSetOutPortValue::localExecute() : " << ex.what());
2327 setErrorMsg(ex);
2328 Py_DECREF(result);
2329 PyGILState_Release(gstate);
2330 return false;
2331 }
2332
2333 Py_DECREF(result);
2334 PyGILState_Release(gstate);
2335 return true;
2336}
2337
2339{
2340 DEBTRACE("CommandSetOutPortValue::localReverse");
2341 OutputPresetPort *outpp = 0;
2342 OutputStudyPort *outsp = 0;
2343 DataNode *dnode = 0;
2344 SubjectDataPort *soutp = 0;
2345 try
2346 {
2347 Proc* proc = GuiContext::getCurrent()->getProc();
2348 Node* node = proc->getChildByName(_node);
2349 OutputPort* outp = node->getOutputPort(_port);
2350 outpp = dynamic_cast<OutputPresetPort*>(outp);
2351 outsp = dynamic_cast<OutputStudyPort*>(outp);
2352 dnode = dynamic_cast<DataNode*>(node);
2353 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(outp));
2355 }
2356 catch (Exception& ex)
2357 {
2358 DEBTRACE("CommandSetOutPortValue::localExecute() : " << ex.what());
2359 setErrorMsg(ex);
2360 return false;
2361 }
2362
2363 if (!outpp && !outsp)
2364 {
2365 DEBTRACE("Set value on output port only possible on a presetPort or a studyPort");
2366 GuiContext::getCurrent()->_lastErrorMessage = "Set value on output port only possible on a presetPort or a studyPort";
2367 return false;
2368 }
2369
2370 if (!dnode)
2371 {
2372 DEBTRACE("Set value on output port only possible on a dataNode");
2373 GuiContext::getCurrent()->_lastErrorMessage = "Set value on output port only possible on a dataNode";
2374 return false;
2375 }
2376
2377 if(outsp)
2378 {
2379 //It's a study port
2380 _value = outsp->getAsString();
2381 DEBTRACE("value="<< _value);
2382 DEBTRACE("old value="<< _oldValue);
2383 dnode->setData(outsp, _oldValue );
2384 soutp->update(SETVALUE, 0, soutp);
2385 return true;
2386 }
2387
2388 PyObject *result = Py_None;
2389 try
2390 {
2391 _value = outpp->getAsString();
2392 DEBTRACE("value="<< _value);
2393 DEBTRACE("old value="<< _oldValue);
2394 if (!_oldValue.empty())
2395 {
2396 std::string strval;
2397 if (outpp->edGetType()->kind() == YACS::ENGINE::String || outpp->edGetType()->isA(Runtime::_tc_file))
2398 strval = "\"" + _value + "\"";
2399 else
2400 strval = _value;
2401 result = YACS::ENGINE::getSALOMERuntime()->convertStringToPyObject(strval.c_str());
2402 }
2403 }
2404 catch (Exception& ex)
2405 {
2406 DEBTRACE("CommandSetOutPortValue::localExecute() : " << ex.what());
2407 setErrorMsg(ex);
2408 return false;
2409 }
2410
2411 string val;
2412 PyGILState_STATE gstate = PyGILState_Ensure();
2413 try
2414 {
2415 DEBTRACE(PyObject_Str(result));
2416 val = convertPyObjectXml(outpp->edGetType(), result);
2417 DEBTRACE(val);
2418 dnode->setData(outpp, val );
2419 soutp->update(SETVALUE, 0, soutp);
2420 }
2421 catch (Exception& ex)
2422 {
2423 DEBTRACE("CommandSetOutPortValue::localExecute() : " << ex.what());
2424 setErrorMsg(ex);
2425 Py_DECREF(result);
2426 PyGILState_Release(gstate);
2427 return false;
2428 }
2429
2430 Py_DECREF(result);
2431 PyGILState_Release(gstate);
2432 return true;
2433}
2434
2435// ----------------------------------------------------------------------------
2436
2438 std::string value)
2439 : Command(), _switch(aSwitch), _value(value)
2440{
2441 DEBTRACE("CommandSetSwitchSelect::CommandSetSwitchSelect");
2442 _oldValue = "0";
2443}
2444
2446{
2447 string ret ="CommandSetSwitchSelect " + _switch + " " + _value;
2448 return ret;
2449}
2450
2452{
2453 DEBTRACE("CommandSetSwitchSelect::localExecute");
2454 try
2455 {
2456 Proc* proc = GuiContext::getCurrent()->getProc();
2457 Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2458 InputPort *condPort = aSwitch->edGetConditionPort();
2459 _oldValue = condPort->getAsString();
2460 if (_oldValue == "None") _oldValue = "0";
2461 int val = atoi(_value.c_str());
2462 condPort->edInit(val);
2463 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2465 snode->update(SETSELECT, 0, snode);
2466 }
2467 catch (Exception& ex)
2468 {
2469 DEBTRACE("CommandSetSwitchSelect::localExecute() : " << ex.what());
2470 setErrorMsg(ex);
2471 return false;
2472 }
2473 return true;
2474}
2475
2477{
2478 DEBTRACE("CommandSetSwitchSelect::localReverse");
2479 try
2480 {
2481 Proc* proc = GuiContext::getCurrent()->getProc();
2482 Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2483 InputPort *condPort = aSwitch->edGetConditionPort();
2484 int val = atoi(_oldValue.c_str());
2485 condPort->edInit(val);
2486 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2488 snode->update(SETSELECT, 0, snode);
2489 }
2490 catch (Exception& ex)
2491 {
2492 DEBTRACE("CommandSetSwitchSelect::localReverse() : " << ex.what());
2493 setErrorMsg(ex);
2494 return false;
2495 }
2496 return true;
2497}
2498
2499// ----------------------------------------------------------------------------
2500
2502 std::string node,
2503 std::string value)
2504 : Command(), _switch(aSwitch), _node(node), _value(value)
2505{
2506 DEBTRACE("CommandSetSwitchCase::CommandSetSwitchCase");
2507 _oldValue = 0;
2508 _oldNode = "";
2509}
2510
2512{
2513 string ret ="CommandSetSwitchCase " + _switch + " " + _node + " " + _value;
2514 return ret;
2515}
2516
2518{
2519 DEBTRACE("CommandSetSwitchCase::localExecute");
2520 try
2521 {
2522 DEBTRACE("CommandSetSwitchCase::localExecute");
2523 Proc* proc = GuiContext::getCurrent()->getProc();
2524 Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2525 Node* node = proc->getChildByName(_node);
2526 int val = atoi(_value.c_str());
2527 if (aSwitch->edGetNode(val))
2528 {
2529 throw YACS::Exception("Set Switch Case impossible: value already used");
2530 }
2531 int oldVal = aSwitch->getRankOfNode(node);
2532 aSwitch->edChangeCase(oldVal,val);
2533 _oldValue = oldVal;
2534 _oldNode = proc->getChildName(node);
2535 DEBTRACE("CommandSetSwitchCase::localExecute OK " << val);
2536 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2539 ssw->update(SETCASE, val, snode);
2540 snode->recursiveUpdate(RENAME, 0, snode);
2541 return true;
2542 }
2543 catch (Exception& ex)
2544 {
2545 DEBTRACE("CommandSetSwitchCase::localExecute() : " << ex.what());
2546 setErrorMsg(ex);
2547 return false;
2548 }
2549}
2550
2552{
2553 DEBTRACE("CommandSetSwitchCase::localReverse");
2554 try
2555 {
2556 DEBTRACE("CommandSetSwitchCase::localReverse");
2557 Proc* proc = GuiContext::getCurrent()->getProc();
2558 Switch* aSwitch = dynamic_cast<Switch*>(proc->getChildByName(_switch));
2559 Node* node = proc->getChildByName(_oldNode);
2560 int val = _oldValue;
2561 if (aSwitch->edGetNode(val))
2562 {
2563 throw YACS::Exception("Set Switch Case impossible: value already used");
2564 }
2565 int oldVal = aSwitch->getRankOfNode(node);
2566 aSwitch->edChangeCase(oldVal,val);
2567 DEBTRACE("CommandSetSwitchCase::localReverse OK " << val);
2568 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(aSwitch));
2571 ssw->update(SETCASE, val, snode);
2572 snode->recursiveUpdate(RENAME, 0, snode);
2573 return true;
2574 }
2575 catch (Exception& ex)
2576 {
2577 DEBTRACE("CommandSetSwitchCase::localReverse() : " << ex.what());
2578 setErrorMsg(ex);
2579 return false;
2580 }
2581}
2582
2583// ----------------------------------------------------------------------------
2584
2586 std::string value)
2587 : Command(), _forLoop(forLoop), _value(value)
2588{
2589 DEBTRACE("CommandSetForLoopSteps::CommandSetForLoopSteps");
2590 _oldValue = 0;
2591}
2592
2593
2595{
2596 string ret ="CommandSetForLoopSteps " + _forLoop + " " + _value;
2597 return ret;
2598}
2599
2601{
2602 DEBTRACE("CommandSetForLoopSteps::localExecute");
2603 try
2604 {
2605 DEBTRACE("CommandSetForLoopSteps::localExecute");
2606 Proc* proc = GuiContext::getCurrent()->getProc();
2607 ForLoop* forLoop = dynamic_cast<ForLoop*>(proc->getChildByName(_forLoop));
2608 InputPort *nbSteps = forLoop->edGetNbOfTimesInputPort();
2609 _oldValue = atoi(forLoop->edGetNbOfTimesInputPort()->getAsString().c_str());
2610 int val = atoi(_value.c_str());
2611 nbSteps->edInit(val);
2612 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(forLoop));
2614 snode->update(SETVALUE, 0, snode);
2615 return true;
2616 }
2617 catch (Exception& ex)
2618 {
2619 DEBTRACE("CommandSetForLoopSteps::localExecute() : " << ex.what());
2620 setErrorMsg(ex);
2621 return false;
2622 }
2623}
2624
2626{
2627 DEBTRACE("CommandSetForLoopSteps::localReverse");
2628 try
2629 {
2630 DEBTRACE("CommandSetForLoopSteps::localReverse");
2631 Proc* proc = GuiContext::getCurrent()->getProc();
2632 ForLoop* forLoop = dynamic_cast<ForLoop*>(proc->getChildByName(_forLoop));
2633 InputPort *nbSteps = forLoop->edGetNbOfTimesInputPort();
2634 nbSteps->edInit(_oldValue);
2635 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(forLoop));
2637 snode->update(SETVALUE, 0, snode);
2638 return true;
2639 }
2640 catch (Exception& ex)
2641 {
2642 DEBTRACE("CommandSetForLoopSteps::localReverse() : " << ex.what());
2643 setErrorMsg(ex);
2644 return false;
2645 }
2646}
2647
2648// ----------------------------------------------------------------------------
2649
2651 std::string value)
2652 : Command(), _whileLoop(whileLoop), _value(value)
2653{
2654 DEBTRACE("CommandSetWhileCondition::CommandSetWhileCondition");
2655 _oldValue = 0;
2656}
2657
2659{
2660 string ret ="CommandSetWhileCondition " + _whileLoop + " " + _value;
2661 return ret;
2662}
2663
2665{
2666 DEBTRACE("CommandSetWhileCondition::localExecute");
2667 try
2668 {
2669 Proc* proc = GuiContext::getCurrent()->getProc();
2670 WhileLoop* whileLoop = dynamic_cast<WhileLoop*>(proc->getChildByName(_whileLoop));
2671 InputPort *cond = whileLoop->edGetConditionPort();
2672 _oldValue = atoi(whileLoop->edGetConditionPort()->getAsString().c_str());
2673 bool val = atoi(_value.c_str());
2674 cond->edInit(val);
2675 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(whileLoop));
2677 snode->update(SETVALUE, 0, snode);
2678 return true;
2679 }
2680 catch (Exception& ex)
2681 {
2682 DEBTRACE("CommandSetWhileCondition::localExecute() : " << ex.what());
2683 setErrorMsg(ex);
2684 return false;
2685 }
2686}
2687
2689{
2690 DEBTRACE("CommandSetWhileCondition::localReverse");
2691 try
2692 {
2693 Proc* proc = GuiContext::getCurrent()->getProc();
2694 WhileLoop* whileLoop = dynamic_cast<WhileLoop*>(proc->getChildByName(_whileLoop));
2695 InputPort *cond = whileLoop->edGetConditionPort();
2696 cond->edInit(_oldValue);
2697 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(whileLoop));
2699 snode->update(SETVALUE, 0, snode);
2700 return true;
2701 }
2702 catch (Exception& ex)
2703 {
2704 DEBTRACE("CommandSetWhileCondition::localReverse() : " << ex.what());
2705 setErrorMsg(ex);
2706 return false;
2707 }
2708}
2709
2710// ----------------------------------------------------------------------------
2711
2713 std::string value)
2714 : Command(), _forEach(forEach), _value(value)
2715{
2716 DEBTRACE("CommandSetForEachBranch::CommandSetForEachBranch");
2717 _oldValue = 0;
2718}
2719
2721{
2722 string ret ="CommandSetForEachBranch " + _forEach + " " + _value;
2723 return ret;
2724}
2725
2727{
2728 DEBTRACE("CommandSetForEachBranch::localExecute");
2729 try
2730 {
2731 Proc* proc = GuiContext::getCurrent()->getProc();
2732 Node* node=proc->getChildByName(_forEach);
2733 InputPort *nbBranches = node->getInputPort("nbBranches");
2734 _oldValue = atoi(nbBranches->getAsString().c_str());
2735 int val = atoi(_value.c_str());
2736 nbBranches->edInit(val);
2737 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(nbBranches));
2738 SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(nbBranches)];
2739 spo->update(SETVALUE, 0, spo);
2740 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
2742 snode->update(SETVALUE, 0, snode);
2743 return true;
2744 }
2745 catch (Exception& ex)
2746 {
2747 DEBTRACE("CommandSetForEachBranch::localExecute() : " << ex.what());
2748 setErrorMsg(ex);
2749 return false;
2750 }
2751}
2752
2754{
2755 DEBTRACE("CommandSetForEachBranch::localReverse");
2756 try
2757 {
2758 Proc* proc = GuiContext::getCurrent()->getProc();
2759 Node* node=proc->getChildByName(_forEach);
2760 InputPort *nbBranches = node->getInputPort("nbBranches");
2761 nbBranches->edInit(_oldValue);
2762 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(nbBranches));
2763 SubjectDataPort *spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(nbBranches)];
2764 spo->update(SETVALUE, 0, spo);
2765 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
2767 snode->update(SETVALUE, 0, snode);
2768 return true;
2769 }
2770 catch (Exception& ex)
2771 {
2772 DEBTRACE("CommandSetForEachBranch::localReverse() : " << ex.what());
2773 setErrorMsg(ex);
2774 return false;
2775 }
2776}
2777
2778// ----------------------------------------------------------------------------
2779
2780CommandSetAlgo::CommandSetAlgo(std::string optimizer, std::string alglib, std::string symbol)
2781 : Command(), _optimizer(optimizer), _alglib(alglib), _symbol(symbol)
2782{
2783 DEBTRACE("CommandSetAlgo::CommandSetAlgo" << _optimizer << " " << _alglib << " " << _symbol);
2784 _oldAlglib = "";
2785 _oldSymbol = "";
2786}
2787
2789{
2790 string ret ="CommandSetAlgo " + _optimizer + " " + _alglib + " " + _symbol;
2791 return ret;
2792}
2793
2795{
2796 DEBTRACE("CommandSetAlgo::localExecute");
2797 try
2798 {
2799 Proc* proc = GuiContext::getCurrent()->getProc();
2800 OptimizerLoop* loop = dynamic_cast<OptimizerLoop*>(proc->getChildByName(_optimizer));
2804 InputPort *port = loop->edGetPortForOutPool();
2805 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(static_cast<DataPort*>(port)));
2807 spo->update(UPDATE, 0, spo);
2808 OutputPort *oport = loop->edGetSamplePort();
2809 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(static_cast<DataPort*>(oport)));
2810 spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(oport)];
2811 spo->update(UPDATE, 0, spo);
2812 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(loop));
2814 snode->update(SETVALUE, 0, snode);
2815 return true;
2816 }
2817 catch (Exception& ex)
2818 {
2819 DEBTRACE("CommandSetAlgo::localExecute() : " << ex.what());
2820 setErrorMsg(ex);
2821 return false;
2822 }
2823}
2824
2826{
2827 DEBTRACE("CommandSetAlgo::localReverse");
2828 try
2829 {
2830 Proc* proc = GuiContext::getCurrent()->getProc();
2831 OptimizerLoop* loop = dynamic_cast<OptimizerLoop*>(proc->getChildByName(_optimizer));
2833 InputPort *port = loop->edGetPortForOutPool();
2834 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(static_cast<DataPort*>(port)));
2836 spo->update(UPDATE, 0, spo);
2837 OutputPort *oport = loop->edGetSamplePort();
2838 YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(static_cast<DataPort*>(oport)));
2839 spo = GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(oport)];
2840 spo->update(UPDATE, 0, spo);
2841 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(loop));
2843 snode->update(SETVALUE, 0, snode);
2844 return true;
2845 }
2846 catch (Exception& ex)
2847 {
2848 DEBTRACE("CommandSetAlgo::localReverse() : " << ex.what());
2849 setErrorMsg(ex);
2850 return false;
2851 }
2852 return true;
2853}
2854
2855// ----------------------------------------------------------------------------
2856
2857CommandAddLink::CommandAddLink(std::string outNode, std::string outPort, TypeOfElem outPortType,
2858 std::string inNode, std::string inPort, TypeOfElem inPortType, bool control)
2859 : Command(), _outNode(outNode), _outPort(outPort), _outPortType(outPortType),
2860 _inNode(inNode), _inPort(inPort), _inPortType(inPortType), _control(control)
2861{
2862 DEBTRACE("CommandAddLink::CommandAddLink "<<outNode<<"."<<outPort<<"->"<<inNode<<"."<<inPort<<" "<<control);
2863 _controlCreatedWithDF = false;
2864}
2865
2867{
2868 string s = "false";
2869 if (_control) s = "true";
2870 string ret ="CommandAddLink " + _outNode + " " + _outPort + " " + _inNode + " " + _inPort + " " + s;
2871 return ret;
2872}
2873
2875{
2876 DEBTRACE("CommandAddLink::localExecute");
2877 DEBTRACE(_outNode<<"."<<_outPort<<"->"<<_inNode<<"."<<_inPort<<" "<<_control);
2878 try
2879 {
2880 Proc* proc = GuiContext::getCurrent()->getProc();
2881 Node* outn = proc->getChildByName(_outNode);
2882 Node* inn = proc->getChildByName(_inNode);
2883 OutPort* outp;
2884 InPort* inp;
2885
2886 // --- is a control link already existing ?
2887 bool preexistingControl = false;
2888 {
2889 Node* outn2=outn;
2890 Node* inn2=inn;
2891 ComposedNode* father = ComposedNode::getLowestCommonAncestor(outn2,inn2);
2892 if(outn2==father || inn2==father)
2893 preexistingControl = true;
2894 else
2895 {
2896 while(outn2->getFather() != father)
2897 outn2 = outn2->getFather();
2898 while(inn2->getFather() != father)
2899 inn2 = inn2->getFather();
2900 OutGate *ogate = outn2->getOutGate();
2901 InGate *igate = inn2->getInGate();
2902 if (ogate->isAlreadyInSet(igate))
2903 preexistingControl = true;
2904 }
2905 }
2906
2908 outp = outn->getOutputPort(_outPort);
2909 else
2910 outp = outn->getOutputDataStreamPort(_outPort);
2911
2912 if(_inPortType == INPUTPORT)
2913 inp = inn->getInputPort(_inPort);
2914 else
2915 inp = inn->getInputDataStreamPort(_inPort);
2916
2917 ComposedNode *cla = ComposedNode::getLowestCommonAncestor(outn->getFather(),inn->getFather());
2918 DEBTRACE(cla->getName());
2919 if (dynamic_cast<OutputDataStreamPort*>(outp))
2920 cla->edAddLink(outp,inp);
2921 else if(_control)
2922 cla->edAddDFLink(outp,inp);
2923 else
2924 cla->edAddLink(outp,inp);
2925
2926 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(cla));
2928 SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(sub);
2929 DEBTRACE(scla->getName());
2934 SubjectLink *slink = scla->addSubjectLink(sno, subOutport, sni, subInport);
2935
2936 // --- if control link, identify the nodes linked and draw the control link if not already existing
2937
2938 if (_control)
2939 {
2940 ComposedNode* father = ComposedNode::getLowestCommonAncestor(outn,inn);
2941 if(outn==father || inn==father) return true;
2942 while(outn->getFather() != father)
2943 outn = outn->getFather();
2944 while(inn->getFather() != father)
2945 inn = inn->getFather();
2946 OutGate *ogate = outn->getOutGate();
2947 InGate *igate = inn->getInGate();
2948 if (ogate->isAlreadyInSet(igate))
2949 {
2950 if (!preexistingControl)
2951 _controlCreatedWithDF = true;
2952 pair<Node*,Node*> keyLink(outn,inn);
2953 if (!GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keyLink))
2954 {
2957 if (!sfno || !sfni) return true;
2958 SubjectControlLink *sclink = scla->addSubjectControlLink(sfno, sfni);
2959 }
2960 }
2961 }
2962 return true;
2963 }
2964 catch (Exception& ex)
2965 {
2966 DEBTRACE("CommandAddLink::localExecute() : " << ex.what());
2967 setErrorMsg(ex);
2968 return false;
2969 }
2970}
2971
2973{
2974 DEBTRACE("CommandAddLink::localReverse");
2975 try
2976 {
2977 SubjectLink *slink =0;
2978 SubjectControlLink *sclink = 0;
2979 Proc* proc = GuiContext::getCurrent()->getProc();
2980 Node* outn = proc->getChildByName(_outNode);
2981 Node* inn = proc->getChildByName(_inNode);
2982 OutPort* outp;
2983 InPort* inp;
2985 outp = outn->getOutputPort(_outPort);
2986 else
2987 outp = outn->getOutputDataStreamPort(_outPort);
2988 if(_inPortType == INPUTPORT)
2989 inp = inn->getInputPort(_inPort);
2990 else
2991 inp = inn->getInputDataStreamPort(_inPort);
2992 YASSERT(GuiContext::getCurrent()->_mapOfSubjectLink.count(pair<OutPort*,InPort*>(outp,inp)));
2993 slink = GuiContext::getCurrent()->_mapOfSubjectLink[pair<OutPort*,InPort*>(outp,inp)];
2995 {
2996 YASSERT(GuiContext::getCurrent()->_mapOfSubjectControlLink.count(pair<Node*,Node*>(outn,inn)));
2997 sclink = GuiContext::getCurrent()->_mapOfSubjectControlLink[pair<Node*,Node*>(outn,inn)];
2998 }
2999
3000 Subject *father = slink->getParent();
3001 Subject::erase(slink);
3002 slink = 0;
3003 if (father)
3004 {
3005 DEBTRACE("REMOVE");
3006 father->select(true);
3007 father->update(REMOVE,0,0);
3008 }
3009 if (!sclink)
3010 return true;
3011 father=sclink->getParent();
3012 Subject::erase(sclink);
3013 sclink = 0;
3014 if (father)
3015 {
3016 DEBTRACE("REMOVE");
3017 father->select(true);
3018 father->update(REMOVE,0,0);
3019 }
3020 return true;
3021 }
3022 catch (Exception& ex)
3023 {
3024 DEBTRACE("CommandAddLink::localReverse(): " << ex.what());
3025 setErrorMsg(ex);
3026 return false;
3027 }
3028}
3029
3030// ----------------------------------------------------------------------------
3031
3032CommandAddControlLink::CommandAddControlLink(std::string outNode, std::string inNode)
3033 : Command(), _outNode(outNode), _inNode(inNode)
3034{
3035 DEBTRACE("CommandAddControlLink::CommandAddControlLink "<<outNode<<"-->>"<<inNode);
3036}
3037
3039{
3040 string ret ="CommandAddControlLink " + _outNode + " " + _inNode;
3041 return ret;
3042}
3043
3045{
3046 DEBTRACE("CommandAddControlLink::localExecute");
3047 try
3048 {
3049 Proc* proc = GuiContext::getCurrent()->getProc();
3050 Node* outn = proc;
3051 if (! _outNode.empty())
3052 outn = proc->getChildByName(_outNode);
3053 Node* inn = proc;
3054 if (! _inNode.empty())
3055 inn = proc->getChildByName(_inNode);
3056 ComposedNode *cla = ComposedNode::getLowestCommonAncestor(outn,inn);
3057 DEBTRACE(cla->getName());
3058 bool ret= cla->edAddCFLink(outn,inn);
3059 if(ret==false)
3060 GuiContext::getCurrent()->_lastErrorMessage = "Link already exists";
3061
3062 cla = ComposedNode::getLowestCommonAncestor(outn->getFather(),
3063 inn->getFather());
3064 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(cla));
3066 SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(sub);
3067 DEBTRACE(scla->getName());
3070 SubjectControlLink *sclink = scla->addSubjectControlLink(sno,sni);
3071 return ret;
3072 }
3073 catch (Exception& ex)
3074 {
3075 DEBTRACE("CommandAddControlLink::localExecute() : " << ex.what());
3076 setErrorMsg(ex);
3077 return false;
3078 }
3079}
3080
3082{
3083 DEBTRACE("CommandAddControlLink::localReverse");
3084 try
3085 {
3086 SubjectControlLink *sclink = 0;
3087 Proc* proc = GuiContext::getCurrent()->getProc();
3088 Node* outn = proc->getChildByName(_outNode);
3089 Node* inn = proc->getChildByName(_inNode);
3090 YASSERT(GuiContext::getCurrent()->_mapOfSubjectControlLink.count(pair<Node*,Node*>(outn,inn)));
3091 sclink = GuiContext::getCurrent()->_mapOfSubjectControlLink[pair<Node*,Node*>(outn,inn)];
3092
3093 Subject *father=sclink->getParent();
3094 Subject::erase(sclink);
3095 sclink = 0;
3096 if (father)
3097 {
3098 DEBTRACE("REMOVE");
3099 father->select(true);
3100 father->update(REMOVE,0,0);
3101 }
3102 return true;
3103 }
3104 catch (Exception& ex)
3105 {
3106 DEBTRACE("CommandAddControlLink::localReverse(): " << ex.what());
3107 setErrorMsg(ex);
3108 return false;
3109 }
3110}
3111
3112// ----------------------------------------------------------------------------
3113
3114CommandAddContainerBase::CommandAddContainerBase(std::string name, std::string refContainer)
3115 : Command(), _name(name), _containerToClone(refContainer), _subcont(0)
3116{
3117 DEBTRACE("CommandAddContainerBase::CommandAddContainerBase " << name << " " << refContainer);
3118}
3119
3121{
3122}
3123
3125{
3126 DEBTRACE("CommandAddContainerBase::localExecute");
3127 try
3128 {
3129 Proc* proc = GuiContext::getCurrent()->getProc();
3130 if (proc->containerMap.count(_name))
3131 {
3132 GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name";
3133 return false;
3134 }
3135 Container *container(createNewInstance());
3136 if (! _containerToClone.empty())
3137 {
3138 if (proc->containerMap.count(_containerToClone))
3139 {
3141 YASSERT(ref);
3142 container->setProperties(ref->getProperties());
3143 }
3144 else
3145 {
3146 GuiContext::getCurrent()->_lastErrorMessage = "There is no reference container to clone properties";
3147 return false;
3148 }
3149 }
3150 container->setName(_name);
3151 container->setProc(proc);
3152 proc->containerMap[_name] = container;
3153
3155 _subcont = sproc->addSubjectContainer(container, _name);
3156 return true;
3157 }
3158 catch (Exception& ex)
3159 {
3160 DEBTRACE("CommandAddContainerBase::localExecute() : " << ex.what());
3161 setErrorMsg(ex);
3162 return false;
3163 }
3164}
3165
3167{
3168 DEBTRACE("CommandAddContainerBase::localReverse");
3169 try
3170 {
3171 Proc* proc = GuiContext::getCurrent()->getProc();
3172 YASSERT(proc->containerMap.count(_name));
3173 Container *container = proc->containerMap[_name];
3174 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container));
3176 YASSERT(!_subcont->isUsed());
3179 return true;
3180 }
3181 catch (Exception& ex)
3182 {
3183 DEBTRACE("CommandAddContainer::localExecute() : " << ex.what());
3184 setErrorMsg(ex);
3185 return false;
3186 }
3187}
3188
3189// ----------------------------------------------------------------------------
3190
3191CommandAddContainer::CommandAddContainer(std::string name, std::string refContainer):CommandAddContainerBase(name,refContainer)
3192{
3193}
3194
3196{
3197 string ret ="CommandAddContainer " + _name + " " + _containerToClone;
3198 return ret;
3199}
3200
3202{
3203 return new SalomeContainer;
3204}
3205
3206// ----------------------------------------------------------------------------
3207
3208CommandAddHPContainer::CommandAddHPContainer(std::string name, std::string refContainer):CommandAddContainerBase(name,refContainer)
3209{
3210}
3211
3213{
3214 string ret ="CommandAddHPContainer " + _name + " " + _containerToClone;
3215 return ret;
3216}
3217
3219{
3220 return new SalomeHPContainer;
3221}
3222
3223// ----------------------------------------------------------------------------
3224
3225CommandSetNodeProperties::CommandSetNodeProperties(std::string position, std::map<std::string,std::string> properties)
3226 : Command(), _position(position), _properties(properties)
3227{
3228 DEBTRACE("CommandSetNodeProperties::CommandSetNodeProperties " << position);
3229 _oldProp.clear();
3230}
3231
3233{
3234 string ret ="CommandSetNodeProperties " + _position;
3235 return ret;
3236}
3237
3239{
3240 DEBTRACE("CommandSetNodeProperties::localExecute");
3241 try
3242 {
3243 Proc* proc = GuiContext::getCurrent()->getProc();
3244 Node* node = proc;
3245
3246 if (!_position.empty()) node = proc->getChildByName(_position);
3247
3248 if (node)
3249 {
3250 _oldProp = node->getPropertyMap();
3253 snode->update(SETVALUE, 0, snode);
3254 return true;
3255 }
3256 GuiContext::getCurrent()->_lastErrorMessage = "node not found: " + _position;
3257 return false;
3258 }
3259 catch (Exception& ex)
3260 {
3261 DEBTRACE("CommandSetNodeProperties::localExecute() : " << ex.what());
3262 setErrorMsg(ex);
3263 return false;
3264 }
3265}
3266
3268{
3269 DEBTRACE("CommandSetNodeProperties::localReverse");
3270 try
3271 {
3272 Proc* proc = GuiContext::getCurrent()->getProc();
3273 Node* node = proc;
3274
3275 if (!_position.empty()) node = proc->getChildByName(_position);
3276
3277 if (node)
3278 {
3279 node->setProperties(_oldProp);
3281 snode->update(SETVALUE, 0, snode);
3282 return true;
3283 }
3284 GuiContext::getCurrent()->_lastErrorMessage = "node not found: " + _position;
3285 return false;
3286 }
3287 catch (Exception& ex)
3288 {
3289 DEBTRACE("CommandSetNodeProperties::localReverse() : " << ex.what());
3290 setErrorMsg(ex);
3291 return false;
3292 }
3293}
3294
3295// ----------------------------------------------------------------------------
3296
3298 std::map<std::string,std::string> properties)
3299 : Command(), _compoinstance(compoinstance), _properties(properties)
3300{
3301 DEBTRACE("CommandSetComponentInstanceProperties::CommandSetComponentInstanceProperties " << compoinstance);
3302 _oldProp.clear();
3303}
3304
3306{
3307 string ret ="CommandSetComponentInstanceProperties " + _compoinstance;
3308 return ret;
3309}
3310
3312{
3313 DEBTRACE("CommandSetComponentInstanceProperties::localExecute");
3314 try
3315 {
3316 Proc* proc = GuiContext::getCurrent()->getProc();
3317 if (proc->componentInstanceMap.count(_compoinstance))
3318 {
3320 YASSERT(ref);
3321 _oldProp = ref->getProperties();
3322 _oldAnon = ref->isAnonymous();
3323 ref->setProperties(_properties);
3324 ref->setAnonymous(false);
3326 subcompo->update(SETVALUE, 0, subcompo);
3327 return true;
3328 }
3329 GuiContext::getCurrent()->_lastErrorMessage = "compoinstance not found: " + _compoinstance;
3330 return false;
3331 }
3332 catch (Exception& ex)
3333 {
3334 DEBTRACE("CommandSetComponentInstanceProperties::localExecute() : " << ex.what());
3335 setErrorMsg(ex);
3336 return false;
3337 }
3338}
3339
3341{
3342 DEBTRACE("CommandSetComponentInstanceProperties::localReverse");
3343 try
3344 {
3345 Proc* proc = GuiContext::getCurrent()->getProc();
3346 if (proc->componentInstanceMap.count(_compoinstance))
3347 {
3349 YASSERT(ref);
3350 ref->setProperties(_oldProp);
3351 ref->setAnonymous(_oldAnon);
3353 subcompo->update(SETVALUE, 0, subcompo);
3354 return true;
3355 }
3356 GuiContext::getCurrent()->_lastErrorMessage = "compoinstance not found: " + _compoinstance;
3357 return false;
3358 }
3359 catch (Exception& ex)
3360 {
3361 DEBTRACE("CommandSetComponentInstanceProperties::localReverse() : " << ex.what());
3362 setErrorMsg(ex);
3363 return false;
3364 }
3365}
3366
3367// ----------------------------------------------------------------------------
3368
3370 std::map<std::string,std::string> properties)
3371 : Command(), _container(container), _properties(properties)
3372{
3373 DEBTRACE("CommandSetContainerProperties::CommandSetContainerProperties " << container);
3374 _oldProp.clear();
3375}
3376
3378{
3379 string ret ="CommandSetContainerProperties " + _container;
3380 return ret;
3381}
3382
3384{
3385 DEBTRACE("CommandSetContainerProperties::localExecute");
3386 try
3387 {
3388 Proc* proc = GuiContext::getCurrent()->getProc();
3389 if (proc->containerMap.count(_container))
3390 {
3392 YASSERT(ref);
3393 _oldProp = ref->getProperties();
3394 ref->setProperties(_properties);
3395 SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[ref]);
3396 scont->update(UPDATE, 0, scont);
3398 return true;
3399 }
3400 GuiContext::getCurrent()->_lastErrorMessage = "container not found: " + _container;
3401 return false;
3402 }
3403 catch (Exception& ex)
3404 {
3405 DEBTRACE("CommandSetContainerProperties::localExecute() : " << ex.what());
3406 setErrorMsg(ex);
3407 return false;
3408 }
3409}
3410
3412{
3413 DEBTRACE("CommandSetContainerProperties::localReverse");
3414 try
3415 {
3416 Proc* proc = GuiContext::getCurrent()->getProc();
3417 if (proc->containerMap.count(_container))
3418 {
3420 YASSERT(ref);
3421 ref->setProperties(_oldProp);
3422 return true;
3423 }
3424 GuiContext::getCurrent()->_lastErrorMessage = "container not found: " + _container;
3425 return false;
3426 }
3427 catch (Exception& ex)
3428 {
3429 DEBTRACE("CommandSetContainerProperties::localReverse() : " << ex.what());
3430 setErrorMsg(ex);
3431 return false;
3432 }
3433}
3434
3435// ----------------------------------------------------------------------------
3436
3437CommandSetDSPortProperties::CommandSetDSPortProperties(std::string node, std::string port, bool isInport,
3438 std::map<std::string,std::string> properties)
3439 : Command(), _nodeName(node), _portName(port), _isInport(isInport), _properties(properties)
3440{
3441 DEBTRACE("CommandSetDSPortProperties::CommandSetDSPortProperties " << node << "." << port << " " << isInport);
3442 _oldProp.clear();
3443}
3444
3446{
3447 string s = "false";
3448 if (_isInport) s = "true";
3449 string ret ="CommandSetDSPortProperties " + _nodeName + " " + _portName + " " + s;
3450 return ret;
3451}
3452
3454{
3455 DEBTRACE("CommandSetDSPortProperties::localExecute");
3456 try
3457 {
3458 Proc* proc = GuiContext::getCurrent()->getProc();
3459 Node* node = proc->getChildByName(_nodeName);
3460 DataStreamPort* DSPort = 0;
3461 if (_isInport)
3462 DSPort = node->getInputDataStreamPort(_portName);
3463 else
3464 DSPort = node->getOutputDataStreamPort(_portName);
3465 _oldProp = DSPort->getProperties();
3466 DSPort->setProperties(_properties);
3467 return true;
3468 }
3469 catch (Exception& ex)
3470 {
3471 DEBTRACE("CommandSetDSPortProperties::localExecute() : " << ex.what());
3472 setErrorMsg(ex);
3473 return false;
3474 }
3475}
3476
3478{
3479 DEBTRACE("CommandSetDSPortProperties::localReverse");
3480 try
3481 {
3482 Proc* proc = GuiContext::getCurrent()->getProc();
3483 Node* node = proc->getChildByName(_nodeName);
3484 DataStreamPort* DSPort = 0;
3485 if (_isInport)
3486 DSPort = node->getInputDataStreamPort(_portName);
3487 else
3488 DSPort = node->getOutputDataStreamPort(_portName);
3489 DSPort->setProperties(_oldProp);
3490 return true;
3491 }
3492 catch (Exception& ex)
3493 {
3494 DEBTRACE("CommandSetDSPortProperties::localReverse() : " << ex.what());
3495 setErrorMsg(ex);
3496 return false;
3497 }
3498}
3499
3500// ----------------------------------------------------------------------------
3501
3502CommandSetLinkProperties::CommandSetLinkProperties(std::string startnode, std::string startport,
3503 std::string endnode, std::string endport,
3504 std::map<std::string,std::string> properties)
3505 : Command(), _startNodeName(startnode), _startPortName(startport),
3506 _endNodeName(endnode), _endPortName(endport),
3507 _properties(properties)
3508{
3509 DEBTRACE("CommandSetLinkProperties::CommandSetLinkProperties " );
3510 _oldProp.clear();
3511}
3512
3514{
3515 string ret ="CommandSetLinkProperties " + _startNodeName + " " + _startPortName + " " + _endNodeName + " " + _endPortName;
3516 return ret;
3517}
3518
3520{
3521 DEBTRACE("CommandSetLinkProperties::localExecute");
3522 try
3523 {
3524 Proc* proc = GuiContext::getCurrent()->getProc();
3525 Node* node;
3526 InputDataStreamPort* inDSPort = 0;
3527 OutputDataStreamPort* outDSPort = 0;
3528
3529 node = proc->getChildByName(_startNodeName);
3530 outDSPort = node->getOutputDataStreamPort(_startPortName);
3531 outDSPort->setProperties(_properties);
3532
3533 node = proc->getChildByName(_endNodeName);
3534 inDSPort = node->getInputDataStreamPort(_endPortName);
3535 _oldProp = inDSPort->getProperties();
3536 inDSPort->setProperties(_properties);
3537
3538 std::pair<OutPort*,InPort*> keymap = std::pair<OutPort*,InPort*>(outDSPort,inDSPort);
3540 subject->update(SETVALUE, 0, subject);
3541 return true;
3542 }
3543 catch (Exception& ex)
3544 {
3545 DEBTRACE("CommandSetDSPortProperties::localExecute() : " << ex.what());
3546 setErrorMsg(ex);
3547 return false;
3548 }
3549}
3550
3552{
3553 DEBTRACE("CommandSetLinkProperties::localReverse");
3554 try
3555 {
3556 Proc* proc = GuiContext::getCurrent()->getProc();
3557 Node* node;
3558 InputDataStreamPort* inDSPort = 0;
3559 OutputDataStreamPort* outDSPort = 0;
3560
3561 node = proc->getChildByName(_startNodeName);
3562 outDSPort = node->getOutputDataStreamPort(_startPortName);
3563 outDSPort->setProperties(_properties);
3564
3565 node = proc->getChildByName(_endNodeName);
3566 inDSPort = node->getInputDataStreamPort(_endPortName);
3567 inDSPort->setProperties(_oldProp);
3568
3569 std::pair<OutPort*,InPort*> keymap = std::pair<OutPort*,InPort*>(outDSPort,inDSPort);
3571 subject->update(SETVALUE, 0, subject);
3572 return true;
3573 }
3574 catch (Exception& ex)
3575 {
3576 DEBTRACE("CommandSetDSPortProperties::localReverse() : " << ex.what());
3577 setErrorMsg(ex);
3578 return false;
3579 }
3580}
3581
3582// ----------------------------------------------------------------------------
3583
3585 : Command(), _nodeName(node), _funcName(funcName)
3586{
3587 DEBTRACE("CommandSetFuncNodeFunctionName::CommandSetFuncNodeFunctionName " << node << " " <<funcName);
3588 _oldName.clear();
3589}
3590
3592{
3593 string ret ="CommandSetFuncNodeFunctionName " + _nodeName + " " + _funcName;
3594 return ret;
3595}
3596
3598{
3599 DEBTRACE("CommandSetFuncNodeFunctionName::localExecute");
3600 try
3601 {
3602 Proc* proc = GuiContext::getCurrent()->getProc();
3603 Node* node = proc->getChildByName(_nodeName);
3604 if (_funcName.empty())
3605 {
3606 GuiContext::getCurrent()->_lastErrorMessage = "InlineFuncNode function name empty: " + _nodeName;
3607 return false;
3608 }
3609 if (YACS::ENGINE::InlineFuncNode* funcNode = dynamic_cast<YACS::ENGINE::InlineFuncNode*>(node))
3610 {
3611 _oldName = funcNode->getFname();
3612 funcNode->setFname(_funcName);
3613 return true;
3614 }
3615 else
3616 {
3617 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineFuncNode: " + _nodeName;
3618 return false;
3619 }
3620 }
3621 catch (Exception& ex)
3622 {
3623 DEBTRACE("CommandSetFuncNodeFunctionName::localExecute() : " << ex.what());
3624 setErrorMsg(ex);
3625 return false;
3626 }
3627}
3628
3630{
3631 DEBTRACE("CommandSetFuncNodeFunctionName::localReverse");
3632 try
3633 {
3634 Proc* proc = GuiContext::getCurrent()->getProc();
3635 Node* node = proc->getChildByName(_nodeName);
3636 if (YACS::ENGINE::InlineFuncNode* funcNode = dynamic_cast<YACS::ENGINE::InlineFuncNode*>(node))
3637 {
3638 funcNode->setFname(_oldName);
3639 return true;
3640 }
3641 else
3642 {
3643 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineFuncNode: " + _nodeName;
3644 return false;
3645 }
3646 }
3647 catch (Exception& ex)
3648 {
3649 DEBTRACE("CommandSetFuncNodeFunctionName::localReverse() : " << ex.what());
3650 setErrorMsg(ex);
3651 return false;
3652 }
3653}
3654
3655// ----------------------------------------------------------------------------
3656
3658 : Command(), _nodeName(node), _script(script)
3659{
3660 DEBTRACE("CommandSetInlineNodeScript::CommandSetInlineNodeScript " << node << " " <<script);
3661 _oldScript.clear();
3662}
3663
3665{
3666 string ret ="CommandSetInlineNodeScript " + _nodeName;
3667 return ret;
3668}
3669
3671{
3672 DEBTRACE("CommandSetInlineNodeScript::localExecute");
3673 try
3674 {
3675 Proc* proc = GuiContext::getCurrent()->getProc();
3676 Node* node = proc->getChildByName(_nodeName);
3677 if (_script.empty())
3678 {
3679 GuiContext::getCurrent()->_lastErrorMessage = "InlineNode script empty: " + _nodeName;
3680 return false;
3681 }
3682 if (YACS::ENGINE::InlineNode* inlineNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3683 {
3684 _oldScript = inlineNode->getScript();
3685 inlineNode->setScript(_script);
3686 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
3688 snode->update(SYNCHRO,0,snode);
3689 return true;
3690 }
3691 else
3692 {
3693 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3694 return false;
3695 }
3696 }
3697 catch (Exception& ex)
3698 {
3699 DEBTRACE("CommandSetInlineNodeScript::localExecute() : " << ex.what());
3700 setErrorMsg(ex);
3701 return false;
3702 }
3703}
3704
3706{
3707 DEBTRACE("CommandSetInlineNodeScript::localReverse");
3708 try
3709 {
3710 Proc* proc = GuiContext::getCurrent()->getProc();
3711 Node* node = proc->getChildByName(_nodeName);
3712 if (YACS::ENGINE::InlineNode* inlineNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3713 {
3714 inlineNode->setScript(_oldScript);
3715 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
3717 snode->update(SYNCHRO,0,snode);
3718 return true;
3719 }
3720 else
3721 {
3722 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3723 return false;
3724 }
3725 }
3726 catch (Exception& ex)
3727 {
3728 DEBTRACE("CommandSetInlineNodeScript::localExecute() : " << ex.what());
3729 setErrorMsg(ex);
3730 return false;
3731 }
3732}
3733
3734// ----------------------------------------------------------------------------
3735
3737 std::string container,
3738 std::string name)
3739 : Command(), _compoName(compoName), _container(container), _name(name), _subcompo(0)
3740{
3741 DEBTRACE("CommandAddComponentInstance::CommandAddComponentInstance " <<_compoName);
3742}
3743
3745{
3746 string ret ="CommandAddComponentInstance " + _compoName + " " + _container + " " + _name;
3747 return ret;
3748}
3749
3751{
3752 DEBTRACE("CommandAddComponentInstance::localExecute "<< _compoName << " " << _container << " " << _name);
3753 try
3754 {
3755 Proc* proc = GuiContext::getCurrent()->getProc();
3756 YASSERT(proc->containerMap.count(_container));
3757 Container *cont = proc->containerMap[_container];
3759 compoInst->setContainer(cont);
3760 proc->addComponentInstance(compoInst, _name);
3761
3763 _subcompo = sproc->addSubjectComponent(compoInst);
3764 _name = compoInst->getInstanceName();
3765 DEBTRACE(_name);
3766 return true;
3767 }
3768 catch (Exception& ex)
3769 {
3770 DEBTRACE("CommandAddComponentInstance::localExecute() : " << ex.what());
3771 setErrorMsg(ex);
3772 return false;
3773 }
3774}
3775
3777{
3778 DEBTRACE("CommandAddComponentInstance::localReverse");
3779 try
3780 {
3781 Proc* proc = GuiContext::getCurrent()->getProc();
3782 YASSERT(proc->componentInstanceMap.count(_name));
3784 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
3787 Container *cont = compo->getContainer();
3788 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
3790 subcont->detachComponent(_subcompo);
3792 proc->removeComponentInstance(compo);
3793 return true;
3794 }
3795 catch (Exception& ex)
3796 {
3797 DEBTRACE("CommandAddComponentInstance::localReverse() : " << ex.what());
3798 setErrorMsg(ex);
3799 return false;
3800 }
3801}
3802
3803// ----------------------------------------------------------------------------
3804CommandSetExecutionMode::CommandSetExecutionMode(std::string nodeName, std::string mode)
3805 : Command(), _mode(mode),_nodeName(nodeName)
3806{
3807 DEBTRACE("CommandSetExecutionMode::CommandSetExecutionMode " << nodeName << " " << mode);
3808 _oldmode = "local";
3809}
3810
3812{
3813 string ret ="CommandSetExecutionMode " + _mode + " " + _nodeName;
3814 return ret;
3815}
3816
3818{
3819 DEBTRACE("CommandSetExecutionMode::localExecute");
3820 try
3821 {
3822 Proc* proc = GuiContext::getCurrent()->getProc();
3823 Node* node = proc->getChildByName(_nodeName);
3824 if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3825 {
3826 _oldmode = pyNode->getExecutionMode();
3827 pyNode->setExecutionMode(_mode);
3829 snode->update(UPDATE, 0, 0);
3830 return true;
3831 }
3832 else
3833 {
3834 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3835 return false;
3836 }
3837 }
3838 catch (Exception& ex)
3839 {
3840 DEBTRACE("CommandSetExecutionMode::localExecute() : " << ex.what());
3841 setErrorMsg(ex);
3842 return false;
3843 }
3844}
3845
3847{
3848 DEBTRACE("CommandSetExecutionMode::localReverse");
3849 try
3850 {
3851 if (_oldmode == _mode) return true;
3852 Proc* proc = GuiContext::getCurrent()->getProc();
3853 Node* node = proc->getChildByName(_nodeName);
3854 if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3855 {
3856 pyNode->setExecutionMode(_oldmode);
3858 snode->update(UPDATE, 0, 0);
3859 return true;
3860 }
3861 else
3862 {
3863 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3864 return false;
3865 }
3866 }
3867 catch (Exception& ex)
3868 {
3869 DEBTRACE("CommandSetExecutionMode::localReverse() : " << ex.what());
3870 setErrorMsg(ex);
3871 return false;
3872 }
3873 return true;
3874}
3875
3876
3877// ----------------------------------------------------------------------------
3878
3879CommandSetContainer::CommandSetContainer(std::string nodeName, std::string container)
3880 : Command(), _container(container),_nodeName(nodeName)
3881{
3882 DEBTRACE("CommandSetContainer::CommandSetContainer " << nodeName << " " << container);
3883 _oldcont = "DefaultContainer";
3884}
3885
3887{
3888 string ret ="CommandSetContainer " + _container + " " + _nodeName;
3889 return ret;
3890}
3891
3893{
3894 DEBTRACE("CommandSetContainer::localExecute");
3895 try
3896 {
3897 Proc* proc = GuiContext::getCurrent()->getProc();
3898 if (proc->containerMap.count(_container))
3899 {
3900 Container *cont = proc->containerMap[_container];
3901 Node* node = proc->getChildByName(_nodeName);
3902 if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3903 {
3904 Container* oldcont = pyNode->getContainer();
3905 if(oldcont)
3906 _oldcont = pyNode->getContainer()->getName();
3907 pyNode->setContainer(cont);
3910 snode->update(ASSOCIATE, 0, subcont);
3911 return true;
3912 }
3913 else
3914 {
3915 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3916 return false;
3917 }
3918 }
3919 else
3920 GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _container;
3921 return false;
3922 }
3923 catch (Exception& ex)
3924 {
3925 DEBTRACE("CommandSetContainer::localExecute() : " << ex.what());
3926 setErrorMsg(ex);
3927 return false;
3928 }
3929}
3930
3932{
3933 DEBTRACE("CommandSetContainer::localReverse");
3934 try
3935 {
3936 if (_oldcont == _container) return true;
3937 Proc* proc = GuiContext::getCurrent()->getProc();
3938 if (proc->containerMap.count(_oldcont))
3939 {
3940 Container *cont = proc->containerMap[_oldcont];
3941 Node* node = proc->getChildByName(_nodeName);
3942 if (YACS::ENGINE::InlineNode* pyNode = dynamic_cast<YACS::ENGINE::InlineNode*>(node))
3943 {
3944 pyNode->setContainer(cont);
3947 snode->update(ASSOCIATE, 0, subcont);
3948 return true;
3949 }
3950 else
3951 {
3952 GuiContext::getCurrent()->_lastErrorMessage = "node is not an InlineNode: " + _nodeName;
3953 return false;
3954 }
3955 }
3956 else
3957 GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _oldcont;
3958 return false;
3959 }
3960 catch (Exception& ex)
3961 {
3962 DEBTRACE("CommandSetContainer::localReverse() : " << ex.what());
3963 setErrorMsg(ex);
3964 return false;
3965 }
3966 return true;
3967}
3968
3969
3970
3971// ----------------------------------------------------------------------------
3972
3974 std::string container)
3975 : Command(), _container(container),_instanceName(instanceName)
3976{
3977 DEBTRACE("CommandAssociateComponentToContainer::CommandAssociateComponentToContainer " << instanceName << " " << container);
3978 _oldcont = "DefaultContainer";
3979}
3980
3982{
3983 string ret ="CommandAssociateComponentToContainer " + _container + " " + _instanceName;
3984 return ret;
3985}
3986
3988{
3989 DEBTRACE("CommandAssociateComponentToContainer::localExecute");
3990 try
3991 {
3992 Proc* proc = GuiContext::getCurrent()->getProc();
3993 if (proc->containerMap.count(_container))
3994 {
3995 Container *cont = proc->containerMap[_container];
3996 if (proc->componentInstanceMap.count(_instanceName))
3997 {
4000 if (compo->getContainer())
4001 _oldcont = compo->getContainer()->getName();
4002 compo->setContainer(cont);
4003
4004 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4006 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
4008 scomp->addSubjectReference(subcont);
4009 if (scomp->_subRefContainer)
4010 subcont->moveComponent(scomp->_subRefContainer);
4011 else
4012 scomp->_subRefContainer = subcont->attachComponent(scomp);
4013 scomp->notifyServicesChange(ASSOCIATE, CONTAINER, subcont);
4014 return true;
4015 }
4016 else
4017 GuiContext::getCurrent()->_lastErrorMessage = "Component instance not found: " + _instanceName;
4018 }
4019 else
4020 GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _container;
4021 return false;
4022 }
4023 catch (Exception& ex)
4024 {
4025 DEBTRACE("CommandAssociateComponentToContainer::localExecute() : " << ex.what());
4026 setErrorMsg(ex);
4027 return false;
4028 }
4029}
4030
4032{
4033 DEBTRACE("CommandAssociateComponentToContainer::localReverse");
4034 try
4035 {
4036 if (_oldcont == _container) return true;
4037 Proc* proc = GuiContext::getCurrent()->getProc();
4038 if (proc->containerMap.count(_oldcont))
4039 {
4040 Container *cont = proc->containerMap[_oldcont];
4041 if (proc->componentInstanceMap.count(_instanceName))
4042 {
4045 compo->setContainer(cont);
4046
4047 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4049 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
4051 scomp->addSubjectReference(subcont);
4052 if (scomp->_subRefContainer)
4053 subcont->moveComponent(scomp->_subRefContainer);
4054 else
4055 scomp->_subRefContainer = subcont->attachComponent(scomp);
4056 scomp->notifyServicesChange(ASSOCIATE, CONTAINER, subcont);
4057 return true;
4058 }
4059 else
4060 GuiContext::getCurrent()->_lastErrorMessage = "Component instance not found: " + _instanceName;
4061 }
4062 else
4063 GuiContext::getCurrent()->_lastErrorMessage = "Container not found: " + _oldcont;
4064 return false;
4065 }
4066 catch (Exception& ex)
4067 {
4068 DEBTRACE("CommandAssociateComponentToContainer::localReverse() : " << ex.what());
4069 setErrorMsg(ex);
4070 return false;
4071 }
4072 return true;
4073}
4074
4075// ----------------------------------------------------------------------------
4076
4078 std::string instanceName)
4079 : Command(), _service(service), _instanceName(instanceName)
4080{
4081 DEBTRACE("CommandAssociateServiceToComponent::CommandAssociateServiceToComponent "<< service << " " <<instanceName);
4082 _oldInstance="";
4083}
4084
4086{
4087 string ret ="CommandAssociateServiceToComponent " + _service + " " + _instanceName;
4088 return ret;
4089}
4090
4092{
4093 DEBTRACE("CommandAssociateServiceToComponent::localExecute");
4094 try
4095 {
4096 Proc* proc = GuiContext::getCurrent()->getProc();
4097 if (_service == proc->getName()) return false; // proc is not an elementary node
4098 Node* node = proc->getChildByName(_service);
4099 if (ServiceNode *service = dynamic_cast<ServiceNode*>(node))
4100 {
4101 if (proc->componentInstanceMap.count(_instanceName))
4102 {
4105 service->setComponent(compo);
4106
4107 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(service));
4109 SubjectServiceNode *ssnode = dynamic_cast<SubjectServiceNode*>(snode);
4110 YASSERT(ssnode);
4111 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4113 snode->addSubjectReference(subCompo);
4114 if (ssnode->_subRefComponent)
4115 {
4116 SubjectComponent* oldcomp = dynamic_cast<SubjectComponent*>(ssnode->_subRefComponent->getParent());
4117 YASSERT(oldcomp);
4118 _oldInstance = oldcomp->getName();
4119 _oldcont = oldcomp->getComponent()->getContainer()->getName();
4120 subCompo->moveService(ssnode->_subRefComponent);
4121 }
4122 else
4123 ssnode->_subRefComponent = subCompo->attachService(ssnode);
4124
4125 return true;
4126 }
4127 else
4128 GuiContext::getCurrent()->_lastErrorMessage = "Component instance not found: " + _instanceName;
4129 }
4130 else
4131 GuiContext::getCurrent()->_lastErrorMessage = "Node is not a service node: " + _service;
4132 return false;
4133 }
4134 catch (Exception& ex)
4135 {
4136 DEBTRACE("CommandAssociateServiceToComponent::localExecute() : " << ex.what());
4137 setErrorMsg(ex);
4138 return false;
4139 }
4140}
4141
4143{
4144 DEBTRACE("CommandAssociateServiceToComponent::localReverse");
4145 try
4146 {
4147 Proc* proc = GuiContext::getCurrent()->getProc();
4148 if (_service == proc->getName()) return false; // proc is not an elementary node
4149 Node* node = proc->getChildByName(_service);
4150 if (ServiceNode *service = dynamic_cast<ServiceNode*>(node))
4151 {
4152 ComponentInstance *compo;
4153 if (!proc->componentInstanceMap.count(_oldInstance))
4154 {
4155 //component instance does not exist anymore recreate it
4156 ComponentInstance *oldcompo = service->getComponent();
4157 compo = oldcompo->cloneAlways();
4158 compo->setName(_oldInstance);
4159 proc->addComponentInstance(compo, _oldInstance);
4160 Container *cont = proc->containerMap[_oldcont];
4161 compo->setContainer(cont);
4163 sproc->addSubjectComponent(compo);
4164 }
4165 else
4166 {
4167 compo = proc->componentInstanceMap[_oldInstance];
4168 }
4169
4171 service->setComponent(compo);
4172
4173 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(service));
4175 SubjectServiceNode *ssnode = dynamic_cast<SubjectServiceNode*>(snode);
4176 YASSERT(ssnode);
4177 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4179 snode->addSubjectReference(subCompo);
4180 if (ssnode->_subRefComponent)
4181 subCompo->moveService(ssnode->_subRefComponent);
4182 else
4183 ssnode->_subRefComponent = subCompo->attachService(ssnode);
4184
4185 return true;
4186 }
4187 else
4188 GuiContext::getCurrent()->_lastErrorMessage = "Node is not a service node: " + _service;
4189 return false;
4190 }
4191 catch (Exception& ex)
4192 {
4193 DEBTRACE("CommandAssociateServiceToComponent::localReverse() : " << ex.what());
4194 setErrorMsg(ex);
4195 return false;
4196 }
4197}
4198
4199// ----------------------------------------------------------------------------
4200
4202 std::string position,
4203 std::string compo,
4204 std::string service)
4205 : Command(), _catalog(catalog), _position(position), _compo(compo), _service(service)
4206{
4207 DEBTRACE("CommandAddComponentFromCatalog::CommandAddComponentFromCatalog " << position << " " << compo << " " << service);
4208 _nameInProc="";
4209 _createdInstance = false;
4210}
4211
4213{
4214 string ret = "CommandAddComponentFromCatalog " + _position + " " + _compo + " " + _service;
4215 return ret;
4216}
4217
4219{
4220 DEBTRACE("CommandAddComponentFromCatalog::localExecute");
4221 try
4222 {
4223 DEBTRACE("_nameInProc: " << _nameInProc);
4224 Proc* proc = GuiContext::getCurrent()->getProc();
4225 Node* node = proc;
4226 if (!_position.empty()) node = proc->getChildByName(_position);
4227 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
4229 SubjectServiceNode *ssnode = dynamic_cast<SubjectServiceNode*>(snode);
4230 YASSERT(ssnode);
4231 if (_catalog->_componentMap.count(_compo))
4232 {
4234 if (compodef->_serviceMap.count(_service))
4235 {
4236 Proc* proc = GuiContext::getCurrent()->getProc();
4237 ComponentInstance *instance =ssnode->_serviceNode->getComponent();
4238 YASSERT(instance);
4239 SubjectComponent* subCompo = 0;
4240 _createdInstance = false;
4241 if(!GuiContext::getCurrent()->_mapOfSubjectComponent.count(instance))
4242 {
4243 _createdInstance = true;
4244 //automatic rename of the component instance by the proc on first execute
4245 DEBTRACE("name given to proc:" << _nameInProc);
4246 proc->addComponentInstance(instance,_nameInProc, true);
4247 _nameInProc= instance->getInstanceName();
4248 DEBTRACE("name given by proc:" << _nameInProc);
4250 }
4251 else
4252 subCompo = GuiContext::getCurrent()->_mapOfSubjectComponent[instance];
4253 YASSERT(subCompo);
4254 ssnode->addSubjectReference(subCompo);
4255 YASSERT(! ssnode->_subRefComponent);
4256 ssnode->_subRefComponent = subCompo->attachService(ssnode);
4257 }
4258 }
4259 return true;
4260 }
4261 catch (Exception& ex)
4262 {
4263 DEBTRACE("CommandAddComponentFromCatalog::localExecute() : " << ex.what());
4264 setErrorMsg(ex);
4265 return false;
4266 }
4267}
4268
4270{
4271 DEBTRACE("CommandAddComponentFromCatalog::localReverse");
4272 try
4273 {
4274 Proc* proc = GuiContext::getCurrent()->getProc();
4275 Node* node = proc;
4276 if (!_position.empty()) node = proc->getChildByName(_position);
4277 YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(node));
4279 SubjectServiceNode *ssnode = dynamic_cast<SubjectServiceNode*>(snode);
4280 YASSERT(ssnode);
4281
4282 DEBTRACE("_nameInProc: " << _nameInProc);
4285 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
4287
4288 subCompo->detachService(ssnode);
4289 if (subCompo->hasServices())
4290 throw YACS::Exception("Component instance with services attached, not removed");
4291 Container *cont = compo->getContainer();
4292 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont));
4294 subcont->detachComponent(subCompo);
4295 //remove componentInstance from proc, from context
4296 if (_createdInstance)
4297 {
4299 proc->removeComponentInstance(compo);
4300 }
4301 DEBTRACE("_nameInProc: " << _nameInProc);
4302 return true;
4303 }
4304 catch (Exception& ex)
4305 {
4306 DEBTRACE("CommandAddComponentFromCatalog::localReverse() : " << ex.what());
4307 setErrorMsg(ex);
4308 return false;
4309 }
4310}
4311
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36
std::list< Node * > getChildren() const
Definition: Bloc.hxx:57
Class for CORBA Service Node.
Definition: CORBANode.hxx:45
class for YACS catalogs.
Definition: Catalog.hxx:42
std::map< std::string, ComposedNode * > _composednodeMap
Definition: Catalog.hxx:52
std::map< std::string, ComponentDefinition * > _componentMap
Definition: Catalog.hxx:50
std::map< std::string, Node * > _nodeMap
Definition: Catalog.hxx:51
std::map< std::string, TypeCode * > _typeMap
Definition: Catalog.hxx:49
Base class for component definition.
std::map< std::string, ServiceNode * > _serviceMap
Base class for all component instances.
virtual bool setContainer(Container *cont)
void setName(const std::string &name)
virtual ComponentInstance * cloneAlways() const =0
const std::string & getInstanceName() const
const std::string & getCompoName() const
Base class for all composed nodes.
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
std::string getName() const
virtual void edRemoveChild(Node *node)
Remove a child node.
virtual bool edAddDFLink(OutPort *start, InPort *end)
Connect an OutPort to an InPort and add the necessary control link.
virtual bool edAddChild(Node *DISOWNnode)
bool edAddCFLink(Node *nodeS, Node *nodeE)
Add a controlflow link between two nodes.
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
void setName(std::string name)
WARNING ! name is used in edition to identify different containers, it is not the runtime name of the...
Definition: Container.hxx:83
void setProc(Proc *proc)
Definition: Container.hxx:84
virtual void setProperties(const std::map< std::string, std::string > &properties)
Definition: Container.cxx:103
virtual std::string getName() const
Definition: Container.hxx:81
Class for C++ Nodes (in process component)
Definition: CppNode.hxx:47
Class for data parameters specification.
Definition: DataNode.hxx:38
virtual void setData(InputPort *port, const std::string &data)
Definition: DataNode.cxx:29
TypeCode * edGetType() const
Definition: DataPort.hxx:53
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: DataPort.cxx:84
void setName(std::string theName)
Definition: DataPort.hxx:56
std::string getName() const
Definition: DataPort.hxx:55
virtual void setProperties(std::map< std::string, std::string > properties)
Set the values of all properties of the port.
std::map< std::string, std::string > getProperties() const
Base class for dynamically (fully or semifully) built graphs.
Definition: DynParaLoop.hxx:41
OutputPort * edGetSamplePort()
Definition: DynParaLoop.hxx:90
Base class for all calculation nodes.
virtual OutputDataStreamPort * edAddOutputDataStreamPort(const std::string &outputPortDSName, TypeCode *type)
std::list< OutputPort * > getSetOfOutputPort() const
InputPort * getInputPort(const std::string &name) const
OutputDataStreamPort * getOutputDataStreamPort(const std::string &name) const
OutputPort * getOutputPort(const std::string &name) const
virtual InputPort * edAddInputPort(const std::string &inputPortName, TypeCode *type)
virtual InputDataStreamPort * edAddInputDataStreamPort(const std::string &inputPortDSName, TypeCode *type)
InputDataStreamPort * getInputDataStreamPort(const std::string &name) const
std::list< InputPort * > getSetOfInputPort() const
virtual void edOrderInputPorts(const std::list< InputPort * > &ports)
virtual void edOrderOutputPorts(const std::list< OutputPort * > &ports)
virtual OutputPort * edAddOutputPort(const std::string &outputPortName, TypeCode *type)
Class for for loop node.
Definition: ForLoop.hxx:33
InputPort * edGetNbOfTimesInputPort()
Definition: ForLoop.hxx:45
Class for calculation node (function) inlined (and executed) in the schema.
Definition: InlineNode.hxx:93
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
Base class for Input Ports.
Definition: InputPort.hxx:44
void edInit(T value)
Definition: InputPort.hxx:129
Class for PRESET input Ports.
Definition: PresetPorts.hxx:50
Class for Study input Ports.
Definition: StudyPorts.hxx:51
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: StudyPorts.cxx:341
Base class for loop node.
Definition: Loop.hxx:147
Base class for all nodes.
Definition: Node.hxx:70
std::map< std::string, std::string > getPropertyMap()
Definition: Node.hxx:173
const std::string & getName() const
Definition: Node.hxx:125
ComposedNode * getFather() const
Definition: Node.hxx:127
std::string getQualifiedName() const
same as Node::getName() in most cases, but differs for children of switch
Definition: Node.cxx:632
void setName(const std::string &name)
Change the name of the node.
Definition: Node.cxx:162
Node * clone(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
Definition: Node.cxx:131
OutGate * getOutGate()
Definition: Node.hxx:124
virtual OutputPort * getOutputPort(const std::string &name) const =0
InGate * getInGate()
Definition: Node.hxx:123
virtual OutputDataStreamPort * getOutputDataStreamPort(const std::string &name) const =0
virtual void setProperties(std::map< std::string, std::string > properties)
Definition: Node.cxx:521
Node * cloneWithoutCompAndContDeepCpy(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
Definition: Node.cxx:150
virtual InputPort * getInputPort(const std::string &name) const
Definition: Node.cxx:260
virtual InputDataStreamPort * getInputDataStreamPort(const std::string &name) const =0
class to build optimization loops
virtual void setAlgorithm(const std::string &alglib, const std::string &symbol, bool checkLinks=true, Proc *procForTypes=NULL)
Set the algorithm library name and factory name (symbol in library) to create the algorithm and chang...
bool isAlreadyInSet(InGate *inGate) const
Definition: OutGate.cxx:150
Class for data out node.
Definition: OutNode.hxx:30
Class for PRESET output Ports.
Definition: PresetPorts.hxx:33
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Class for Study output Ports.
Definition: StudyPorts.hxx:33
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: StudyPorts.cxx:134
Class for data in node.
Definition: PresetNode.hxx:31
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, TypeCode * > typeMap
Definition: Proc.hxx:90
virtual void removeComponentInstance(ComponentInstance *inst)
Remove a componentInstance from the componentInstanceMap.
Definition: Proc.cxx:566
std::map< std::string, Container * > containerMap
Definition: Proc.hxx:91
virtual void addComponentInstance(ComponentInstance *inst, const std::string &name="", bool resetCtr=false)
Add a ComponentInstance into componentInstanceMap.
Definition: Proc.cxx:526
std::map< std::string, ComponentInstance * > componentInstanceMap
Definition: Proc.hxx:92
virtual PyObject * convertStringToPyObject(const std::string &s)
Catalog * getBuiltinCatalog()
Get the catalog of base nodes (elementary and composed)
Definition: Runtime.cxx:314
Class for Salome component instance.
Class for Salome component Service Node.
Definition: CORBANode.hxx:68
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
virtual void setComponent(ComponentInstance *compo)
Associate an existing component instance to this service node AND check the consistency regarding the...
virtual ComponentInstance * getComponent()
Return the associated component instance.
Control node that emulates the C switch.
Definition: Switch.hxx:85
InputPort * edGetConditionPort()
Definition: Switch.hxx:115
Node * edGetNode(int caseId)
Definition: Switch.cxx:527
void edChangeCase(int oldCase, int newCase)
Change the case of a node.
Definition: Switch.cxx:575
int getRankOfNode(Node *node) const
Definition: Switch.cxx:752
Base class for all type objects.
Definition: TypeCode.hxx:68
virtual int isA(const char *repositoryId) const
Definition: TypeCode.cxx:99
DynType kind() const
Definition: TypeCode.cxx:47
Class for a while loop.
Definition: WhileLoop.hxx:39
InputPort * edGetConditionPort()
Definition: WhileLoop.hxx:48
CommandAddComponentFromCatalog(YACS::ENGINE::Catalog *catalog, std::string position, std::string compo, std::string service)
CommandAddComponentInstance(std::string compoName, std::string container, std::string name="")
virtual YACS::ENGINE::Container * createNewInstance() const =0
CommandAddContainerBase(std::string name, std::string refContainer)
SubjectContainerBase * _subcont
CommandAddContainer(std::string name, std::string refContainer="")
YACS::ENGINE::Container * createNewInstance() const
YACS::ENGINE::TypeCode * getTypeCode()
CommandAddDataTypeFromCatalog(YACS::ENGINE::Catalog *catalog, std::string typeName)
CommandAddHPContainer(std::string name, std::string refContainer="")
YACS::ENGINE::Container * createNewInstance() const
CommandAddIDSPortFromCatalog(YACS::ENGINE::Catalog *catalog, std::string type, std::string node, std::string name)
YACS::ENGINE::InputDataStreamPort * getIDSPort()
SubjectInputDataStreamPort * _sip
SubjectInputDataStreamPort * getSubjectIDSPort()
YACS::ENGINE::InputDataStreamPort * _IDSPort
CommandAddInputPortFromCatalog(YACS::ENGINE::Catalog *catalog, std::string type, std::string node, std::string name)
YACS::ENGINE::InputPort * getInputPort()
YACS::HMI::SubjectNode * getSubjectNode()
YACS::HMI::SubjectNode * _snode
YACS::ENGINE::Catalog * _catalog
CommandAddNodeFromCatalog(YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string position, std::string name, bool newCompoInst=true, int swCase=0)
YACS::ENGINE::OutputDataStreamPort * getODSPort()
SubjectOutputDataStreamPort * getSubjectODSPort()
CommandAddODSPortFromCatalog(YACS::ENGINE::Catalog *catalog, std::string type, std::string node, std::string name)
SubjectOutputDataStreamPort * _sop
YACS::ENGINE::OutputDataStreamPort * _ODSPort
YACS::ENGINE::OutputPort * getOutputPort()
CommandAddOutputPortFromCatalog(YACS::ENGINE::Catalog *catalog, std::string type, std::string node, std::string name)
YACS::ENGINE::OutputPort * _outputPort
CommandAssociateComponentToContainer(std::string instanceName, std::string container)
CommandAssociateServiceToComponent(std::string service, std::string instanceName)
YACS::ENGINE::Node * _clone
YACS::ENGINE::Proc * _fromproc
CommandCopyNode(YACS::ENGINE::Proc *fromproc, std::string position, std::string newParent, int acase=0)
YACS::ENGINE::Node * getNode()
virtual std::string dump()
virtual std::string dump()
CommandDestroy(TypeOfElem elemType, std::string startnode, std::string startport, TypeOfElem startportType, std::string endnode, std::string endport, TypeOfElem endportType)
CommandOrderInputPorts(std::string node, std::string port, int isUp)
CommandOrderOutputPorts(std::string node, std::string port, int isUp)
CommandPutInComposedNode(std::string position, std::string newParent, std::string type, bool toSaveRestoreLinks=true)
CommandRenameContainer(std::string oldName, std::string newName)
CommandRenameInDataPort(std::string position, std::string oldName, std::string newName, TypeOfElem portType)
CommandRenameNode(std::string position, std::string name)
virtual std::string dump()
CommandRenameOutDataPort(std::string position, std::string oldName, std::string newName, TypeOfElem portType)
virtual std::string dump()
CommandReparentNode(std::string position, std::string newParent)
CommandSetAlgo(std::string optimizer, std::string alglib, std::string symbol)
virtual std::string dump()
std::map< std::string, std::string > _oldProp
CommandSetComponentInstanceProperties(std::string compoinstance, std::map< std::string, std::string > properties)
std::map< std::string, std::string > _properties
std::map< std::string, std::string > _oldProp
std::map< std::string, std::string > _properties
CommandSetContainerProperties(std::string container, std::map< std::string, std::string > properties)
virtual std::string dump()
CommandSetContainer(std::string nodeName, std::string container)
std::map< std::string, std::string > _properties
std::map< std::string, std::string > _oldProp
CommandSetDSPortProperties(std::string node, std::string port, bool isInport, std::map< std::string, std::string > properties)
CommandSetExecutionMode(std::string nodeName, std::string mode)
CommandSetForEachBranch(std::string forEach, std::string value)
CommandSetForLoopSteps(std::string forLoop, std::string value)
CommandSetFuncNodeFunctionName(std::string node, std::string funcName)
CommandSetInPortValue(std::string node, std::string port, std::string value)
CommandSetInlineNodeScript(std::string node, std::string script)
std::map< std::string, std::string > _properties
CommandSetLinkProperties(std::string startnode, std::string startport, std::string endnode, std::string endport, std::map< std::string, std::string > properties)
std::map< std::string, std::string > _oldProp
std::map< std::string, std::string > _properties
std::map< std::string, std::string > _oldProp
CommandSetNodeProperties(std::string position, std::map< std::string, std::string > properties)
CommandSetOutPortValue(std::string node, std::string port, std::string value)
CommandSetSwitchCase(std::string aSwitch, std::string node, std::string value)
CommandSetSwitchSelect(std::string aSwitch, std::string value)
CommandSetWhileCondition(std::string whileLoop, std::string value)
void setCurrentCatalog(YACS::ENGINE::Catalog *cata)
Definition: guiContext.hxx:61
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::string _lastErrorMessage
Definition: guiContext.hxx:79
std::map< std::pair< YACS::ENGINE::OutPort *, YACS::ENGINE::InPort * >, YACS::HMI::SubjectLink * > _mapOfSubjectLink
Definition: guiContext.hxx:72
std::map< YACS::ENGINE::Container *, YACS::HMI::SubjectContainerBase * > _mapOfSubjectContainer
Definition: guiContext.hxx:75
std::map< std::string, YACS::ENGINE::ComponentInstance * > _mapOfLastComponentInstance
Definition: guiContext.hxx:78
std::map< YACS::ENGINE::DataPort *, YACS::HMI::SubjectDataPort * > _mapOfSubjectDataPort
Definition: guiContext.hxx:71
std::map< std::pair< YACS::ENGINE::Node *, YACS::ENGINE::Node * >, YACS::HMI::SubjectControlLink * > _mapOfSubjectControlLink
Definition: guiContext.hxx:73
std::map< YACS::ENGINE::ComponentInstance *, YACS::HMI::SubjectComponent * > _mapOfSubjectComponent
Definition: guiContext.hxx:74
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
static std::map< int, std::string > _typeNameMap
static std::string getTypeName(TypeOfElem type)
static TypeOfElem getTypeOfPort(YACS::ENGINE::DataPort *port)
static TypeOfElem getTypeOfNode(YACS::ENGINE::Node *node)
YACS::ENGINE::ComponentInstance * getComponent() const
virtual SubjectReference * attachService(SubjectServiceNode *service)
SubjectReference * _subRefContainer
virtual void notifyServicesChange(GuiEvent event, int type, Subject *son)
virtual std::string getName()
virtual void detachService(SubjectServiceNode *service)
virtual void moveService(SubjectReference *reference)
SubjectControlLink * addSubjectControlLink(SubjectNode *sno, SubjectNode *sni)
SubjectNode * addSubjectNode(YACS::ENGINE::Node *node, std::string name="", YACS::ENGINE::Catalog *catalog=0, std::string compo="", std::string type="")
virtual void houseKeepingAfterCutPaste(bool isCut, SubjectNode *son)
SubjectLink * addSubjectLink(SubjectNode *sno, SubjectDataPort *spo, SubjectNode *sni, SubjectDataPort *spi)
virtual void notifyComponentsChange(GuiEvent event, int type, Subject *son)
virtual void moveComponent(SubjectReference *reference)
virtual SubjectReference * attachComponent(SubjectComponent *component)
virtual void detachComponent(SubjectComponent *component)
virtual void removeExternalControlLinks()
virtual std::string getName()
virtual SubjectInputDataStreamPort * addSubjectIDSPort(YACS::ENGINE::InputDataStreamPort *port, std::string name="")
virtual SubjectOutputPort * addSubjectOutputPort(YACS::ENGINE::OutputPort *port, std::string name="")
virtual void update(GuiEvent event, int type, Subject *son)
virtual void restoreLinks()
virtual void recursiveUpdate(GuiEvent event, int type, Subject *son)
virtual SubjectInputPort * addSubjectInputPort(YACS::ENGINE::InputPort *port, std::string name="")
virtual void removeExternalLinks()
virtual void saveLinks()
virtual SubjectOutputDataStreamPort * addSubjectODSPort(YACS::ENGINE::OutputDataStreamPort *port, std::string name="")
SubjectContainerBase * addSubjectContainer(YACS::ENGINE::Container *cont, std::string name="")
SubjectDataType * addSubjectDataType(YACS::ENGINE::TypeCode *type, std::string alias)
void removeSubjectContainer(SubjectContainerBase *scont)
SubjectComponent * addSubjectComponent(YACS::ENGINE::ComponentInstance *compo)
void removeSubjectDataType(std::string typeName)
SubjectReference * _subRefComponent
YACS::ENGINE::ServiceNode * _serviceNode
virtual void addSubjectReference(Subject *ref)
virtual void loadLinks()
virtual void update(GuiEvent event, int type, Subject *son)
static void erase(Subject *sub, Command *command=0, bool post=false)
virtual Subject * getParent()
virtual std::string getName()
virtual void loadChildren()
virtual void setParent(Subject *son)
virtual void addSubjectReference(Subject *ref)
virtual void select(bool isSelected)
void setErrorMsg(YACS::Exception &ex)
static std::map< int, std::string > createErrorMsgMap()
std::map< int, std::string > ErrorMsg
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()
std::string convertPyObjectXml(const TypeCode *t, PyObject *data)
@ OUTPUTDATASTREAMPORT
@ INPUTDATASTREAMPORT
def ref(target, callback=None)
Definition: CONNECTOR.py:120