Version: 8.3.0
YACS::HMI::CommandAddOutputPortFromCatalog Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAddOutputPortFromCatalog:
Collaboration diagram for YACS::HMI::CommandAddOutputPortFromCatalog:

Public Member Functions

 CommandAddOutputPortFromCatalog (YACS::ENGINE::Catalog *catalog, std::string type, std::string node, std::string name)
 
YACS::ENGINE::OutputPortgetOutputPort ()
 
SubjectOutputPortgetSubjectOutputPort ()
 
- 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

YACS::ENGINE::Catalog_catalog
 
std::string _typePort
 
std::string _node
 
std::string _name
 
YACS::ENGINE::OutputPort_outputPort
 
SubjectOutputPort_sop
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 282 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandAddOutputPortFromCatalog::CommandAddOutputPortFromCatalog ( YACS::ENGINE::Catalog catalog,
std::string  type,
std::string  node,
std::string  name 
)

Definition at line 1298 of file commandsProc.cxx.

References _outputPort, and _sop.

1302  : Command(), _catalog(catalog), _typePort(type), _node(node), _name(name)
1303 {
1304  _outputPort = 0;
1305  _sop = 0;
1306 }

Member Function Documentation

std::string CommandAddOutputPortFromCatalog::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1308 of file commandsProc.cxx.

References _name, _node, _typePort, and PMMLBasicsTestLauncher::ret.

1309 {
1310  string ret ="CommandAddOutputPortFromCatalog " + _typePort + " " + _node + " " + _name;
1311  return ret;
1312 }
YACS::ENGINE::OutputPort * CommandAddOutputPortFromCatalog::getOutputPort ( )

Definition at line 1314 of file commandsProc.cxx.

References _outputPort.

1315 {
1316  return _outputPort;
1317 }
SubjectOutputPort * CommandAddOutputPortFromCatalog::getSubjectOutputPort ( )

Definition at line 1319 of file commandsProc.cxx.

References _sop.

Referenced by YACS::HMI::SubjectElementaryNode::addOutputPort().

1320 {
1321  return _sop;
1322 }
bool CommandAddOutputPortFromCatalog::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1324 of file commandsProc.cxx.

References _catalog, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectNode, _name, _node, _outputPort, _sop, YACS::ENGINE::Catalog::_typeMap, _typePort, DEBTRACE, YACS::ENGINE::ElementaryNode::edAddOutputPort(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), setErrorMsg(), YACS::HMI::SYNCHRO, YACS::ENGINE::Proc::typeMap, YACS::HMI::Subject::update(), YACS::Exception::what(), and YASSERT.

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))
1339  son = father->edAddOutputPort(_name, _catalog->_typeMap[_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 }
bool CommandAddOutputPortFromCatalog::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1362 of file commandsProc.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, _name, _node, _outputPort, _sop, DEBTRACE, YACS::HMI::Subject::erase(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ElementaryNode::getOutputPort(), YACS::HMI::Subject::getParent(), YACS::HMI::GuiContext::getProc(), YACS::HMI::REMOVE, YACS::HMI::Subject::select(), setErrorMsg(), YACS::HMI::Subject::update(), YACS::Exception::what(), and YASSERT.

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);
1371  _outputPort = enode->getOutputPort(_name);
1373  YASSERT(GuiContext::getCurrent()->_mapOfSubjectDataPort.count(_outputPort));
1375  YASSERT(_sop);
1376 
1377  Subject *father=_sop->getParent();
1378  Subject::erase(_sop);
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 }

Member Data Documentation

YACS::ENGINE::Catalog* YACS::HMI::CommandAddOutputPortFromCatalog::_catalog
protected

Definition at line 295 of file commandsProc.hxx.

Referenced by localExecute().

std::string YACS::HMI::CommandAddOutputPortFromCatalog::_name
protected

Definition at line 298 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAddOutputPortFromCatalog::_node
protected

Definition at line 297 of file commandsProc.hxx.

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

YACS::ENGINE::OutputPort* YACS::HMI::CommandAddOutputPortFromCatalog::_outputPort
protected
SubjectOutputPort* YACS::HMI::CommandAddOutputPortFromCatalog::_sop
protected
std::string YACS::HMI::CommandAddOutputPortFromCatalog::_typePort
protected

Definition at line 296 of file commandsProc.hxx.

Referenced by dump(), and localExecute().


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