Version: 8.3.0
YACS::HMI::CommandOrderOutputPorts Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandOrderOutputPorts:
Collaboration diagram for YACS::HMI::CommandOrderOutputPorts:

Public Member Functions

 CommandOrderOutputPorts (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...
 
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 ()
 

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 362 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandOrderOutputPorts::CommandOrderOutputPorts ( 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 1756 of file commandsProc.cxx.

References DEBTRACE.

1759  : Command(), _node(node), _port(port), _isUp(isUp), _rank(-1)
1760 {
1761  DEBTRACE("CommandOrderOutputPorts");
1762 }

Member Function Documentation

std::string CommandOrderOutputPorts::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1764 of file commandsProc.cxx.

References _isUp, _node, _port, and PMMLBasicsTestLauncher::ret.

1765 {
1766  ostringstream s;
1767  s << _isUp;
1768  string ret ="CommandOrderOutputPorts " + _node + " " + _port + " " + s.str();
1769  return ret;
1770 }
int YACS::HMI::CommandOrderOutputPorts::getRank ( )
inline

Definition at line 368 of file commandsProc.hxx.

References _rank.

368 {return _rank; };
bool CommandOrderOutputPorts::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1772 of file commandsProc.cxx.

References _isUp, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _node, _port, _rank, DEBTRACE, YACS::ENGINE::ElementaryNode::edOrderOutputPorts(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::ElementaryNode::getOutputPort(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ElementaryNode::getSetOfOutputPort(), YACS::HMI::ORDER, setErrorMsg(), YACS::HMI::SYNCHRO, YACS::Exception::what(), and YASSERT.

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 }
bool CommandOrderOutputPorts::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1840 of file commandsProc.cxx.

References _isUp, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _node, _port, _rank, DEBTRACE, YACS::ENGINE::ElementaryNode::edOrderOutputPorts(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::ElementaryNode::getOutputPort(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ElementaryNode::getSetOfOutputPort(), YACS::HMI::ORDER, setErrorMsg(), YACS::HMI::SYNCHRO, YACS::Exception::what(), and YASSERT.

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 }

Member Data Documentation

int YACS::HMI::CommandOrderOutputPorts::_isUp
protected

Definition at line 375 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandOrderOutputPorts::_node
protected

Definition at line 373 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandOrderOutputPorts::_port
protected

Definition at line 374 of file commandsProc.hxx.

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

int YACS::HMI::CommandOrderOutputPorts::_rank
protected

Definition at line 376 of file commandsProc.hxx.

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


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