Version: 8.3.0
YACS::HMI::SubjectSwitch Class Reference

#include <guiObservers.hxx>

Inheritance diagram for YACS::HMI::SubjectSwitch:
Collaboration diagram for YACS::HMI::SubjectSwitch:

Public Member Functions

 SubjectSwitch (YACS::ENGINE::Switch *aSwitch, Subject *parent)
 
virtual ~SubjectSwitch ()
 
virtual SubjectNodeaddNode (YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst, int swCase, bool replace=false)
 
virtual void recursiveUpdate (GuiEvent event, int type, Subject *son)
 
virtual void removeNode (SubjectNode *son)
 
std::map< int, SubjectNode * > getBodyMap ()
 
virtual void completeChildrenSubjectList (SubjectNode *son)
 
virtual SubjectNodegetChild (YACS::ENGINE::Node *node=0) const
 
virtual bool setSelect (std::string select)
 
virtual bool setCase (std::string caseId, SubjectNode *snode)
 
virtual bool hasValue ()
 
virtual std::string getValue ()
 
virtual void houseKeepingAfterCutPaste (bool isCut, SubjectNode *son)
 
virtual void clean (Command *command=0)
 
void localclean (Command *command=0)
 
virtual TypeOfElem getType ()
 
- Public Member Functions inherited from YACS::HMI::SubjectComposedNode
 SubjectComposedNode (YACS::ENGINE::ComposedNode *composedNode, Subject *parent)
 
virtual ~SubjectComposedNode ()
 
virtual SubjectNodeaddNode (YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst)
 
virtual void loadChildren ()
 
virtual void loadLinks ()
 
SubjectNodeaddSubjectNode (YACS::ENGINE::Node *node, std::string name="", YACS::ENGINE::Catalog *catalog=0, std::string compo="", std::string type="")
 
SubjectLinkaddSubjectLink (SubjectNode *sno, SubjectDataPort *spo, SubjectNode *sni, SubjectDataPort *spi)
 
SubjectControlLinkaddSubjectControlLink (SubjectNode *sno, SubjectNode *sni)
 
virtual void removeLink (SubjectLink *link)
 
virtual void removeControlLink (SubjectControlLink *link)
 
virtual void removeExternalControlLinks ()
 
void localclean (Command *command=0)
 
- Public Member Functions inherited from YACS::HMI::SubjectNode
 SubjectNode (YACS::ENGINE::Node *node, Subject *parent)
 
virtual ~SubjectNode ()
 
virtual bool setProperties (std::map< std::string, std::string > properties)
 
virtual std::map< std::string,
std::string > 
getProperties ()
 
virtual bool reparent (Subject *parent)
 
virtual bool copy (Subject *parent)
 
virtual std::string getName ()
 
virtual bool setName (std::string name)
 
virtual YACS::ENGINE::NodegetNode ()
 
void registerUndoDestroy ()
 
SubjectControlLinkaddSubjectControlLink (SubjectControlLink *sub)
 
void removeSubjectControlLink (SubjectControlLink *sub)
 
std::list< SubjectLink * > getSubjectLinks () const
 
std::list< SubjectControlLink * > getSubjectControlLinks () const
 
std::list< SubjectInputPort * > getSubjectInputPorts () const
 
std::list< SubjectOutputPort * > getSubjectOutputPorts () const
 
std::list
< SubjectInputDataStreamPort * > 
getSubjectInputDataStreamPorts () const
 
std::list
< SubjectOutputDataStreamPort * > 
getSubjectOutputDataStreamPorts () const
 
void localclean (Command *command=0)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void removeExternalLinks ()
 
virtual void saveLinks ()
 
virtual void restoreLinks ()
 
virtual bool putInComposedNode (std::string name, std::string type, bool toSaveRestoreLinks=true)
 
virtual int isValid ()
 
void setExecState (int execState)
 
- Public Member Functions inherited from YACS::HMI::Subject
 Subject (Subject *parent=0)
 
virtual ~Subject ()
 
virtual void attach (GuiObserver *obs)
 
virtual void detach (GuiObserver *obs)
 
virtual void select (bool isSelected)
 
virtual std::vector< std::string > knownProperties ()
 
virtual SubjectgetParent ()
 
virtual void setParent (Subject *son)
 
virtual bool destroy (Subject *son)
 From user action in Ihm, destroy an object. More...
 
virtual void addSubjectReference (Subject *ref)
 
void localclean (Command *command=0)
 
void registerUndoDestroy ()
 
void askRegisterUndoDestroy ()
 
bool isDestructible ()
 
virtual void setProgress (std::string newProgress)
 
virtual std::string getProgress ()
 
- Public Member Functions inherited from YACS::ENGINE::Observer
virtual void notifyObserver2 (Node *object, const std::string &event, void *something)
 
virtual ~Observer ()
 

Protected Attributes

YACS::ENGINE::Switch_switch
 
std::map< int, SubjectNode * > _bodyMap
 
- Protected Attributes inherited from YACS::HMI::SubjectComposedNode
YACS::ENGINE::ComposedNode_composedNode
 
- Protected Attributes inherited from YACS::HMI::SubjectNode
YACS::ENGINE::Node_node
 
std::list< SubjectInputPort * > _listSubjectInputPort
 
std::list< SubjectOutputPort * > _listSubjectOutputPort
 
std::list
< SubjectInputDataStreamPort * > 
_listSubjectIDSPort
 
std::list
< SubjectOutputDataStreamPort * > 
_listSubjectODSPort
 
std::list< SubjectLink * > _listSubjectLink
 
std::list< SubjectControlLink * > _listSubjectControlLink
 
int _execState
 
std::list
< YACS::ENGINE::OutGate * > 
loutgate
 
std::list< YACS::ENGINE::InGate * > singate
 
std::vector< std::pair
< YACS::ENGINE::OutPort
*, YACS::ENGINE::InPort * > > 
dataLinks
 
std::vector< std::pair
< YACS::ENGINE::OutPort
*, YACS::ENGINE::InPort * > > 
dataflowLinks
 
- Protected Attributes inherited from YACS::HMI::Subject
std::set< GuiObserver * > _setObs
 
Subject_parent
 
bool _destructible
 
bool _askRegisterUndo
 
std::string _progress
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::HMI::SubjectComposedNode
static SubjectComposedNodegetLowestCommonAncestor (SubjectNode *snode1, SubjectNode *snode2)
 Retrieves the lowest common ancestor of 2 nodes. More...
 
- Protected Member Functions inherited from YACS::HMI::SubjectComposedNode
virtual SubjectNodecreateNode (YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst, int swCase=0)
 

Detailed Description

Definition at line 585 of file guiObservers.hxx.

Constructor & Destructor Documentation

SubjectSwitch::SubjectSwitch ( YACS::ENGINE::Switch aSwitch,
Subject parent 
)

Definition at line 3092 of file guiObservers.cxx.

References _bodyMap.

3093  : SubjectComposedNode(aSwitch, parent), _switch(aSwitch)
3094 {
3095  _bodyMap.clear();
3096 }
SubjectSwitch::~SubjectSwitch ( )
virtual

Definition at line 3098 of file guiObservers.cxx.

References DEBTRACE, and YACS::HMI::SubjectNode::getName().

3099 {
3100  DEBTRACE("SubjectSwitch::~SubjectSwitch " << getName());
3101 }

Member Function Documentation

SubjectNode * SubjectSwitch::addNode ( YACS::ENGINE::Catalog catalog,
std::string  compo,
std::string  type,
std::string  name,
bool  newCompoInst,
int  swCase,
bool  replace = false 
)
virtual

Definition at line 3131 of file guiObservers.cxx.

References _bodyMap, YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::SubjectComposedNode::createNode(), DEBTRACE, and YACS::HMI::GuiContext::getCurrent().

Referenced by YACS::HMI::GuiEditor::_createNode(), and gui.GraphViewer.GraphViewer::popup().

3138 {
3139  DEBTRACE("SubjectSwitch::addNode("<<catalog<<","<<compo<<","<<type<<","<<name<<","<<swCase<<","<<(int)replace<<")");
3140  SubjectNode* body = 0;
3141  if (!replace && _bodyMap.count(swCase))
3142  {
3143  GuiContext::getCurrent()->_lastErrorMessage = "If you need several nodes in a switch case, put the nodes in a bloc";
3144  return body;
3145  }
3146  body = createNode(catalog, compo, type, name, newCompoInst, swCase);
3147  return body;
3148 }
void SubjectSwitch::clean ( Command command = 0)
virtual

Clean process prior to delete is redefined in derived classes: a local clean treatment relative to the derived class, then a call to the parent class clean method.

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3103 of file guiObservers.cxx.

References YACS::HMI::Subject::_askRegisterUndo, YACS::HMI::SubjectComposedNode::clean(), localclean(), and YACS::HMI::SubjectNode::registerUndoDestroy().

3104 {
3105  if (_askRegisterUndo)
3106  {
3107  _askRegisterUndo = false;
3109  }
3110  localclean(command);
3111  SubjectComposedNode::clean(command);
3112 }
void SubjectSwitch::completeChildrenSubjectList ( SubjectNode son)
virtual

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3190 of file guiObservers.cxx.

References _bodyMap, _switch, DEBTRACE, YACS::HMI::SubjectNode::getNode(), and YACS::ENGINE::Switch::getRankOfNode().

3191 {
3192  DEBTRACE("SubjectSwitch::completeChildrenSubjectList");
3193  _bodyMap[_switch->getRankOfNode(son->getNode())] = son;
3194 }
std::map< int, SubjectNode * > SubjectSwitch::getBodyMap ( )

Definition at line 3175 of file guiObservers.cxx.

References _bodyMap.

Referenced by YACS::HMI::GuiEditor::_createNode().

3176 {
3177  return _bodyMap;
3178 }
SubjectNode * SubjectSwitch::getChild ( YACS::ENGINE::Node node = 0) const
virtual

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3196 of file guiObservers.cxx.

References _bodyMap.

3197 {
3198  SubjectNode* aChild = 0;
3199 
3200  if (node)
3201  {
3202  map<int, SubjectNode*>::const_iterator it;
3203  for (it = _bodyMap.begin(); it != _bodyMap.end(); ++it)
3204  if ( (*it).second->getNode() == node )
3205  {
3206  aChild = (*it).second;
3207  break;
3208  }
3209  }
3210 
3211  return aChild;
3212 }
virtual TypeOfElem YACS::HMI::SubjectSwitch::getType ( )
inlinevirtual

Reimplemented from YACS::HMI::Subject.

Definition at line 609 of file guiObservers.hxx.

References YACS::HMI::SWITCH.

609 {return SWITCH;}
std::string SubjectSwitch::getValue ( )
virtual

used in derived classes using a counter, a selector, or a condition: ForLoop, ForEachLoop, Switch, WhileLoop.

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3258 of file guiObservers.cxx.

References _switch, YACS::ENGINE::Switch::edGetConditionPort(), and YACS::ENGINE::DataPort::getAsString().

Referenced by YACS::HMI::SchemaComposedNodeItem::update().

3259 {
3260  return _switch->edGetConditionPort()->getAsString();
3261 }
bool SubjectSwitch::hasValue ( )
virtual

used in derived classes using a counter, a selector, or a condition: ForLoop, ForEachLoop, Switch, WhileLoop.

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3253 of file guiObservers.cxx.

Referenced by YACS::HMI::SchemaComposedNodeItem::update().

3254 {
3255  return true;
3256 }
void SubjectSwitch::houseKeepingAfterCutPaste ( bool  isCut,
SubjectNode son 
)
virtual

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3180 of file guiObservers.cxx.

References _bodyMap, _switch, DEBTRACE, YACS::HMI::SubjectNode::getNode(), and YACS::ENGINE::Switch::getRankOfNode().

3181 {
3182  DEBTRACE("SubjectSwitch::houseKeepingAfterCutPaste");
3183  if (isCut)
3184  _bodyMap.erase(_switch->getRankOfNode(son->getNode()));
3185  else
3186  _bodyMap[_switch->getRankOfNode(son->getNode())] = son;
3187 }
void SubjectSwitch::localclean ( Command command = 0)

Definition at line 3114 of file guiObservers.cxx.

References _bodyMap, DEBTRACE, and YACS::HMI::Subject::erase().

Referenced by clean().

3115 {
3116  DEBTRACE("SubjectSwitch::localClean ");
3117  map<int, SubjectNode*>::iterator it;
3118  map<int, SubjectNode*> bodyMapCpy = _bodyMap;
3119  for (it = bodyMapCpy.begin(); it != bodyMapCpy.end(); ++it)
3120  erase((*it).second);
3121 }
void SubjectSwitch::recursiveUpdate ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SubjectNode.

Definition at line 3123 of file guiObservers.cxx.

References _bodyMap, and YACS::HMI::SubjectNode::update().

3124 {
3125  update(event, type, son);
3126  map<int, SubjectNode*>::iterator it = _bodyMap.begin();
3127  for (; it != _bodyMap.end(); ++it)
3128  (*it).second->recursiveUpdate(event, type, son);
3129 }
void SubjectSwitch::removeNode ( SubjectNode son)
virtual

Definition at line 3150 of file guiObservers.cxx.

References _bodyMap, DEBTRACE, and YACS::HMI::SubjectNode::getName().

3151 {
3152  DEBTRACE("SubjectSwitch::removeNode("<<son->getName()<<")");
3153  if (son)
3154  {
3155  int id;
3156  bool isFound = false;
3157  map<int, SubjectNode*>::const_iterator it;
3158  for (it = _bodyMap.begin(); it != _bodyMap.end(); ++it)
3159  {
3160  if ( (*it).second == son )
3161  {
3162  isFound = true;
3163  id = (*it).first;
3164  break;
3165  }
3166  }
3167  if (isFound)
3168  {
3169  DEBTRACE("id = "<<id);
3170  _bodyMap.erase(id);
3171  }
3172  }
3173 }
bool SubjectSwitch::setCase ( std::string  caseId,
SubjectNode snode 
)
virtual

Definition at line 3229 of file guiObservers.cxx.

References YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::GuiContext::getProc(), and YACS::ENGINE::Switch::getRankOfNode().

Referenced by YACS::HMI::EditionSwitch::onCommitData(), and YACS::HMI::TreeView::onCommitData().

3230 {
3231  DEBTRACE("SubjectSwitch::setCase " << caseId);
3232  Proc *proc = GuiContext::getCurrent()->getProc();
3233 
3234  Switch* aSwitch = dynamic_cast<Switch*>(getNode());
3235  Node* node =snode->getNode();
3236  int previousRank = aSwitch->getRankOfNode(node);
3237  int newRank = atoi(caseId.c_str());
3238  if (previousRank == newRank) return true; // nothing to do.
3239 
3240  CommandSetSwitchCase *command =
3242  proc->getChildName(snode->getNode()),
3243  caseId);
3244  if (command->execute())
3245  {
3246  GuiContext::getCurrent()->getInvoc()->add(command);
3247  return true;
3248  }
3249  else delete command;
3250  return false;
3251 }
bool SubjectSwitch::setSelect ( std::string  select)
virtual

Definition at line 3214 of file guiObservers.cxx.

References YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::GuiContext::getProc(), and YACS::HMI::Subject::select().

3215 {
3216  DEBTRACE("SubjectSwitch::setSelect " << select);
3217  Proc *proc = GuiContext::getCurrent()->getProc();
3218  CommandSetSwitchSelect *command =
3220  if (command->execute())
3221  {
3222  GuiContext::getCurrent()->getInvoc()->add(command);
3223  return true;
3224  }
3225  else delete command;
3226  return false;
3227 }

Member Data Documentation

std::map<int, SubjectNode*> YACS::HMI::SubjectSwitch::_bodyMap
protected
YACS::ENGINE::Switch* YACS::HMI::SubjectSwitch::_switch
protected

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