Version: 9.15.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::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.

Member Function Documentation

◆ dump()

std::string CommandAddOutputPortFromCatalog::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1308 of file commandsProc.cxx.

1309 {
1310  string ret ="CommandAddOutputPortFromCatalog " + _typePort + " " + _node + " " + _name;
1311  return ret;
1312 }

References _name, _node, and _typePort.

◆ getOutputPort()

YACS::ENGINE::OutputPort * CommandAddOutputPortFromCatalog::getOutputPort ( )

Definition at line 1314 of file commandsProc.cxx.

1315 {
1316  return _outputPort;
1317 }

References _outputPort.

◆ getSubjectOutputPort()

SubjectOutputPort * CommandAddOutputPortFromCatalog::getSubjectOutputPort ( )

Definition at line 1319 of file commandsProc.cxx.

1320 {
1321  return _sop;
1322 }

References _sop.

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

◆ localExecute()

bool CommandAddOutputPortFromCatalog::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1324 of file commandsProc.cxx.

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 }
#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
std::map< std::string, TypeCode * > _typeMap
Definition: Catalog.hxx:49
Node * getChildByName(const std::string &name) const
Base class for all calculation nodes.
virtual OutputPort * edAddOutputPort(const std::string &outputPortName, TypeCode *type)
Base class for all nodes.
Definition: Node.hxx:70
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, TypeCode * > typeMap
Definition: Proc.hxx:90
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
std::string _lastErrorMessage
Definition: guiContext.hxx:79
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:68
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
virtual SubjectOutputPort * addSubjectOutputPort(YACS::ENGINE::OutputPort *port, std::string name="")
virtual void update(GuiEvent event, int type, Subject *son)
void setErrorMsg(YACS::Exception &ex)

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

◆ localReverse()

bool CommandAddOutputPortFromCatalog::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1362 of file commandsProc.cxx.

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();
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 }
OutputPort * getOutputPort(const std::string &name) const
std::map< YACS::ENGINE::DataPort *, YACS::HMI::SubjectDataPort * > _mapOfSubjectDataPort
Definition: guiContext.hxx:71
virtual void update(GuiEvent event, int type, Subject *son)
static void erase(Subject *sub, Command *command=0, bool post=false)
virtual Subject * getParent()
virtual void select(bool isSelected)

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, _name, _node, _outputPort, _sop, DEBTRACE, YACS::HMI::Subject::erase(), testCppPluginInvokation::ex, 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(), and YASSERT.

Member Data Documentation

◆ _catalog

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

Definition at line 295 of file commandsProc.hxx.

Referenced by localExecute().

◆ _name

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

Definition at line 298 of file commandsProc.hxx.

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

◆ _node

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

Definition at line 297 of file commandsProc.hxx.

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

◆ _outputPort

YACS::ENGINE::OutputPort* YACS::HMI::CommandAddOutputPortFromCatalog::_outputPort
protected

◆ _sop

SubjectOutputPort* YACS::HMI::CommandAddOutputPortFromCatalog::_sop
protected

◆ _typePort

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: