Version: 9.16.0
YACS::HMI::CommandOrderInputPorts Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandOrderInputPorts:
Collaboration diagram for YACS::HMI::CommandOrderInputPorts:

Public Member Functions

 CommandOrderInputPorts (std::string node, std::string port, int isUp)
 
int getRank ()
 
- Public Member Functions inherited from YACS::HMI::Command
 Command ()
 
virtual bool execute ()
 the command is executed a first time after its registration for undo redo, then on redo More...
 
virtual bool reverse (bool isNormal=true)
 Reverse action: undo. More...
 
virtual bool executeSubOnly ()
 execute only sub commands in a reverse action More...
 
virtual std::string dump ()
 
std::string recursiveDump (int level=0)
 
void addSubCommand (Command *command)
 
bool isNormalReverse ()
 

Protected Member Functions

virtual bool localExecute ()
 
virtual bool localReverse ()
 
virtual std::string dump ()
 
virtual bool localExecute ()=0
 
virtual bool localReverse ()=0
 

Protected Attributes

std::string _node
 
std::string _port
 
int _isUp
 
int _rank
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 345 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandOrderInputPorts()

CommandOrderInputPorts::CommandOrderInputPorts ( std::string  node,
std::string  port,
int  isUp 
)

move up or down a port in the list of ports of a node. if isUp = 0, move down one step, if isUp = n>0, move up n steps.

Definition at line 1598 of file commandsProc.cxx.

1601 : Command(), _node(node), _port(port), _isUp(isUp), _rank(-1)
1602{
1603 DEBTRACE("CommandOrderInputPorts");
1604}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandOrderInputPorts::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1606 of file commandsProc.cxx.

1607{
1608 ostringstream s;
1609 s << _isUp;
1610 string ret ="CommandOrderInputPorts " + _node + " " + _port + " " + s.str();
1611 return ret;
1612}

References _isUp, _node, and _port.

◆ getRank()

int YACS::HMI::CommandOrderInputPorts::getRank ( )
inline

Definition at line 351 of file commandsProc.hxx.

351{return _rank; };

References _rank.

◆ localExecute()

bool CommandOrderInputPorts::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1614 of file commandsProc.cxx.

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}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Node * getChildByName(const std::string &name) const
std::string getName() const
Definition: DataPort.hxx:55
Base class for all calculation nodes.
InputPort * getInputPort(const std::string &name) const
std::list< InputPort * > getSetOfInputPort() const
virtual void edOrderInputPorts(const std::list< InputPort * > &ports)
Base class for Input Ports.
Definition: InputPort.hxx:44
Base class for all nodes.
Definition: Node.hxx:70
Base class for all schema objects.
Definition: Proc.hxx:44
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::DataPort *, YACS::HMI::SubjectDataPort * > _mapOfSubjectDataPort
Definition: guiContext.hxx:71
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

References _isUp, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _node, _port, _rank, DEBTRACE, YACS::ENGINE::ElementaryNode::edOrderInputPorts(), testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ElementaryNode::getInputPort(), YACS::ENGINE::DataPort::getName(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ElementaryNode::getSetOfInputPort(), YACS::HMI::ORDER, setErrorMsg(), YACS::HMI::SYNCHRO, YACS::HMI::SubjectNode::update(), and YASSERT.

◆ localReverse()

bool CommandOrderInputPorts::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1682 of file commandsProc.cxx.

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}

References _isUp, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _node, _port, _rank, DEBTRACE, YACS::ENGINE::ElementaryNode::edOrderInputPorts(), testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ElementaryNode::getInputPort(), YACS::ENGINE::DataPort::getName(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ElementaryNode::getSetOfInputPort(), YACS::HMI::ORDER, setErrorMsg(), YACS::HMI::SYNCHRO, YACS::HMI::SubjectNode::update(), and YASSERT.

Member Data Documentation

◆ _isUp

int YACS::HMI::CommandOrderInputPorts::_isUp
protected

Definition at line 358 of file commandsProc.hxx.

Referenced by dump(), localExecute(), and localReverse().

◆ _node

std::string YACS::HMI::CommandOrderInputPorts::_node
protected

Definition at line 356 of file commandsProc.hxx.

Referenced by dump(), localExecute(), and localReverse().

◆ _port

std::string YACS::HMI::CommandOrderInputPorts::_port
protected

Definition at line 357 of file commandsProc.hxx.

Referenced by dump(), localExecute(), and localReverse().

◆ _rank

int YACS::HMI::CommandOrderInputPorts::_rank
protected

Definition at line 359 of file commandsProc.hxx.

Referenced by getRank(), localExecute(), and localReverse().


The documentation for this class was generated from the following files: