Version: 8.3.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 ( 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.

1201  : Command(), _catalog(catalog), _typePort(type), _node(node), _name(name)
1202 {
1203  _inputPort = 0;
1204  _sip = 0;
1205 }

Member Function Documentation

std::string CommandAddInputPortFromCatalog::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 1207 of file commandsProc.cxx.

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

1208 {
1209  string ret ="CommandAddInputPortFromCatalog " + _typePort + " " + _node + " " + _name;
1210  return ret;
1211 }
YACS::ENGINE::InputPort * CommandAddInputPortFromCatalog::getInputPort ( )

Definition at line 1213 of file commandsProc.cxx.

References _inputPort.

1214 {
1215  return _inputPort;
1216 }
SubjectInputPort * CommandAddInputPortFromCatalog::getSubjectInputPort ( )

Definition at line 1218 of file commandsProc.cxx.

References _sip.

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

1219 {
1220  return _sip;
1221 }
bool CommandAddInputPortFromCatalog::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 1223 of file commandsProc.cxx.

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

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

Implements YACS::HMI::Command.

Definition at line 1261 of file commandsProc.cxx.

References _inputPort, YACS::HMI::GuiContext::_mapOfSubjectDataPort, _name, _node, _sip, DEBTRACE, YACS::HMI::Subject::erase(), 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(), YACS::Exception::what(), and YASSERT.

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();
1277  Subject::erase(_sip);
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 }

Member Data Documentation

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

Definition at line 274 of file commandsProc.hxx.

Referenced by localExecute().

YACS::ENGINE::InputPort* YACS::HMI::CommandAddInputPortFromCatalog::_inputPort
protected
std::string YACS::HMI::CommandAddInputPortFromCatalog::_name
protected

Definition at line 277 of file commandsProc.hxx.

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

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

Definition at line 276 of file commandsProc.hxx.

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

SubjectInputPort* YACS::HMI::CommandAddInputPortFromCatalog::_sip
protected
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: