Version: 9.15.0
YACS::HMI::CommandAddInputPortFromCatalog Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAddInputPortFromCatalog:
Collaboration diagram for YACS::HMI::CommandAddInputPortFromCatalog:

Public Member Functions

 CommandAddInputPortFromCatalog (YACS::ENGINE::Catalog *catalog, std::string type, std::string node, std::string name)
 
YACS::ENGINE::InputPortgetInputPort ()
 
SubjectInputPortgetSubjectInputPort ()
 
- 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::InputPort_inputPort
 
SubjectInputPort_sip
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 261 of file commandsProc.hxx.

Constructor & Destructor Documentation

◆ CommandAddInputPortFromCatalog()

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

Definition at line 1197 of file commandsProc.cxx.

References _inputPort, and _sip.

Member Function Documentation

◆ dump()

std::string CommandAddInputPortFromCatalog::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1207 of file commandsProc.cxx.

1208 {
1209  string ret ="CommandAddInputPortFromCatalog " + _typePort + " " + _node + " " + _name;
1210  return ret;
1211 }

References _name, _node, and _typePort.

◆ getInputPort()

YACS::ENGINE::InputPort * CommandAddInputPortFromCatalog::getInputPort ( )

Definition at line 1213 of file commandsProc.cxx.

1214 {
1215  return _inputPort;
1216 }

References _inputPort.

◆ getSubjectInputPort()

SubjectInputPort * CommandAddInputPortFromCatalog::getSubjectInputPort ( )

Definition at line 1218 of file commandsProc.cxx.

1219 {
1220  return _sip;
1221 }

References _sip.

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

◆ localExecute()

bool CommandAddInputPortFromCatalog::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1223 of file commandsProc.cxx.

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))
1238  son = father->edAddInputPort(_name, _catalog->_typeMap[_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 }
#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 InputPort * edAddInputPort(const std::string &inputPortName, TypeCode *type)
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
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 void update(GuiEvent event, int type, Subject *son)
virtual SubjectInputPort * addSubjectInputPort(YACS::ENGINE::InputPort *port, std::string name="")
void setErrorMsg(YACS::Exception &ex)

References _catalog, _inputPort, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectNode, _name, _node, _sip, YACS::ENGINE::Catalog::_typeMap, _typePort, YACS::HMI::SubjectNode::addSubjectInputPort(), DEBTRACE, YACS::ENGINE::ElementaryNode::edAddInputPort(), 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 CommandAddInputPortFromCatalog::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1261 of file commandsProc.cxx.

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 }
InputPort * getInputPort(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 _inputPort, YACS::HMI::GuiContext::_mapOfSubjectDataPort, _name, _node, _sip, DEBTRACE, YACS::HMI::Subject::erase(), testCppPluginInvokation::ex, YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::ElementaryNode::getInputPort(), 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::CommandAddInputPortFromCatalog::_catalog
protected

Definition at line 274 of file commandsProc.hxx.

Referenced by localExecute().

◆ _inputPort

YACS::ENGINE::InputPort* YACS::HMI::CommandAddInputPortFromCatalog::_inputPort
protected

◆ _name

std::string YACS::HMI::CommandAddInputPortFromCatalog::_name
protected

Definition at line 277 of file commandsProc.hxx.

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

◆ _node

std::string YACS::HMI::CommandAddInputPortFromCatalog::_node
protected

Definition at line 276 of file commandsProc.hxx.

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

◆ _sip

SubjectInputPort* YACS::HMI::CommandAddInputPortFromCatalog::_sip
protected

◆ _typePort

std::string YACS::HMI::CommandAddInputPortFromCatalog::_typePort
protected

Definition at line 275 of file commandsProc.hxx.

Referenced by dump(), and localExecute().


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