Version: 9.15.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::CommandAddControlLink ( std::string  outNode,
std::string  inNode 
)

Definition at line 3032 of file commandsProc.cxx.

3033  : Command(), _outNode(outNode), _inNode(inNode)
3034 {
3035  DEBTRACE("CommandAddControlLink::CommandAddControlLink "<<outNode<<"-->>"<<inNode);
3036 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References DEBTRACE.

Member Function Documentation

◆ dump()

std::string CommandAddControlLink::dump ( )
protectedvirtual

Reimplemented from YACS::HMI::Command.

Definition at line 3038 of file commandsProc.cxx.

3039 {
3040  string ret ="CommandAddControlLink " + _outNode + " " + _inNode;
3041  return ret;
3042 }

References _inNode, and _outNode.

◆ localExecute()

bool CommandAddControlLink::localExecute ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3044 of file commandsProc.cxx.

3045 {
3046  DEBTRACE("CommandAddControlLink::localExecute");
3047  try
3048  {
3049  Proc* proc = GuiContext::getCurrent()->getProc();
3050  Node* outn = proc;
3051  if (! _outNode.empty())
3052  outn = proc->getChildByName(_outNode);
3053  Node* inn = proc;
3054  if (! _inNode.empty())
3055  inn = proc->getChildByName(_inNode);
3056  ComposedNode *cla = ComposedNode::getLowestCommonAncestor(outn,inn);
3057  DEBTRACE(cla->getName());
3058  bool ret= cla->edAddCFLink(outn,inn);
3059  if(ret==false)
3060  GuiContext::getCurrent()->_lastErrorMessage = "Link already exists";
3061 
3062  cla = ComposedNode::getLowestCommonAncestor(outn->getFather(),
3063  inn->getFather());
3064  YASSERT(GuiContext::getCurrent()->_mapOfSubjectNode.count(cla));
3066  SubjectComposedNode *scla = dynamic_cast<SubjectComposedNode*>(sub);
3067  DEBTRACE(scla->getName());
3070  SubjectControlLink *sclink = scla->addSubjectControlLink(sno,sni);
3071  return ret;
3072  }
3073  catch (Exception& ex)
3074  {
3075  DEBTRACE("CommandAddControlLink::localExecute() : " << ex.what());
3076  setErrorMsg(ex);
3077  return false;
3078  }
3079 }
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Base class for all composed nodes.
Node * getChildByName(const std::string &name) const
std::string getName() const
bool edAddCFLink(Node *nodeS, Node *nodeE)
Add a controlflow link between two nodes.
Base class for all nodes.
Definition: Node.hxx:70
ComposedNode * getFather() const
Definition: Node.hxx:127
Base class for all schema objects.
Definition: Proc.hxx:44
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
SubjectControlLink * addSubjectControlLink(SubjectNode *sno, SubjectNode *sni)
virtual std::string getName()
void setErrorMsg(YACS::Exception &ex)

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

◆ localReverse()

bool CommandAddControlLink::localReverse ( )
protectedvirtual

Implements YACS::HMI::Command.

Definition at line 3081 of file commandsProc.cxx.

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

Member Data Documentation

◆ _inNode

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

Definition at line 527 of file commandsProc.hxx.

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

◆ _outNode

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: