Version: 8.3.0
YACS::HMI::CommandAddControlLink Class Reference

#include <commandsProc.hxx>

Inheritance diagram for YACS::HMI::CommandAddControlLink:
Collaboration diagram for YACS::HMI::CommandAddControlLink:

Public Member Functions

 CommandAddControlLink (std::string outNode, std::string inNode)
 
- 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 _outNode
 
std::string _inNode
 
- Protected Attributes inherited from YACS::HMI::Command
std::vector< Command * > _subCommands
 
bool _normalReverse
 

Detailed Description

Definition at line 518 of file commandsProc.hxx.

Constructor & Destructor Documentation

CommandAddControlLink::CommandAddControlLink ( std::string  outNode,
std::string  inNode 
)

Definition at line 3030 of file commandsProc.cxx.

References DEBTRACE.

3031  : Command(), _outNode(outNode), _inNode(inNode)
3032 {
3033  DEBTRACE("CommandAddControlLink::CommandAddControlLink "<<outNode<<"-->>"<<inNode);
3034 }

Member Function Documentation

std::string CommandAddControlLink::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3036 of file commandsProc.cxx.

References _inNode, _outNode, and PMMLBasicsTestLauncher::ret.

3037 {
3038  string ret ="CommandAddControlLink " + _outNode + " " + _inNode;
3039  return ret;
3040 }
bool CommandAddControlLink::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3042 of file commandsProc.cxx.

References _inNode, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::GuiContext::_mapOfSubjectNode, _outNode, YACS::HMI::SubjectComposedNode::addSubjectControlLink(), DEBTRACE, YACS::ENGINE::ComposedNode::edAddCFLink(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getFather(), YACS::ENGINE::ComposedNode::getName(), YACS::HMI::SubjectNode::getName(), YACS::HMI::GuiContext::getProc(), PMMLBasicsTestLauncher::ret, setErrorMsg(), YACS::Exception::what(), and YASSERT.

3043 {
3044  DEBTRACE("CommandAddControlLink::localExecute");
3045  try
3046  {
3047  Proc* proc = GuiContext::getCurrent()->getProc();
3048  Node* outn = proc;
3049  if (! _outNode.empty())
3050  outn = proc->getChildByName(_outNode);
3051  Node* inn = proc;
3052  if (! _inNode.empty())
3053  inn = proc->getChildByName(_inNode);
3054  ComposedNode *cla = ComposedNode::getLowestCommonAncestor(outn,inn);
3055  DEBTRACE(cla->getName());
3056  bool ret= cla->edAddCFLink(outn,inn);
3057  if(ret==false)
3058  GuiContext::getCurrent()->_lastErrorMessage = "Link already exists";
3059 
3060  cla = ComposedNode::getLowestCommonAncestor(outn->getFather(),
3061  inn->getFather());
3062  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(cla));
3064  SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(sub);
3065  DEBTRACE(scla->getName());
3068  SubjectControlLink *sclink = scla->addSubjectControlLink(sno,sni);
3069  return ret;
3070  }
3071  catch (Exception& ex)
3072  {
3073  DEBTRACE("CommandAddControlLink::localExecute() : " << ex.what());
3074  setErrorMsg(ex);
3075  return false;
3076  }
3077 }
bool CommandAddControlLink::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3079 of file commandsProc.cxx.

References _inNode, YACS::HMI::GuiContext::_mapOfSubjectControlLink, _outNode, DEBTRACE, YACS::HMI::Subject::erase(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::HMI::GuiContext::getCurrent(), 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.

3080 {
3081  DEBTRACE("CommandAddControlLink::localReverse");
3082  try
3083  {
3084  SubjectControlLink *sclink = 0;
3085  Proc* proc = GuiContext::getCurrent()->getProc();
3086  Node* outn = proc->getChildByName(_outNode);
3087  Node* inn = proc->getChildByName(_inNode);
3088  YASSERT(GuiContext::getCurrent()->_mapOfSubjectControlLink.count(pair<Node*,Node*>(outn,inn)));
3089  sclink = GuiContext::getCurrent()->_mapOfSubjectControlLink[pair<Node*,Node*>(outn,inn)];
3090 
3091  Subject *father=sclink->getParent();
3092  Subject::erase(sclink);
3093  sclink = 0;
3094  if (father)
3095  {
3096  DEBTRACE("REMOVE");
3097  father->select(true);
3098  father->update(REMOVE,0,0);
3099  }
3100  return true;
3101  }
3102  catch (Exception& ex)
3103  {
3104  DEBTRACE("CommandAddControlLink::localReverse(): " << ex.what());
3105  setErrorMsg(ex);
3106  return false;
3107  }
3108 }

Member Data Documentation

std::string YACS::HMI::CommandAddControlLink::_inNode
protected

Definition at line 527 of file commandsProc.hxx.

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

std::string YACS::HMI::CommandAddControlLink::_outNode
protected

Definition at line 526 of file commandsProc.hxx.

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


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