Version: 9.16.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 SubjectNodegetChild (YACS::ENGINE::Node *node=0) const
 
virtual void loadChildren ()
 
virtual void loadLinks ()
 
virtual void completeChildrenSubjectList (SubjectNode *son)
 
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 ()
 
virtual void houseKeepingAfterCutPaste (bool isCut, SubjectNode *son)
 
virtual bool hasValue ()
 
virtual std::string getValue ()
 
virtual void clean (Command *command=0)
 
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 ()
 
virtual void clean (Command *command=0)
 
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 recursiveUpdate (GuiEvent event, int type, Subject *son)
 
virtual void removeExternalLinks ()
 
virtual void removeExternalControlLinks ()
 
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 void update (GuiEvent event, int type, Subject *son)
 
virtual std::string getName ()
 
virtual bool setName (std::string name)
 
virtual bool setProperties (std::map< std::string, std::string > properties)
 
virtual std::map< std::string, std::string > getProperties ()
 
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 loadChildren ()
 
virtual void loadLinks ()
 
virtual void addSubjectReference (Subject *ref)
 
virtual void clean (Command *command=0)
 
void localclean (Command *command=0)
 
void registerUndoDestroy ()
 
void askRegisterUndoDestroy ()
 
bool isDestructible ()
 
virtual TypeOfElem getType ()
 
virtual void setProgress (std::string newProgress)
 
virtual std::string getProgress ()
 
- Public Member Functions inherited from YACS::ENGINE::Observer
virtual void notifyObserver (Node *object, const std::string &event)
 
virtual void notifyObserver2 (Node *object, const std::string &event, void *something)
 
virtual void notifyObserverFromClone (Node *originalInstance, const std::string &event, Node *clonedInstanceGeneratingEvent)
 
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...
 
- Static Public Member Functions inherited from YACS::HMI::SubjectNode
static bool tryCreateLink (SubjectNode *subOutNode, SubjectNode *subInNode)
 
- Static Public Member Functions inherited from YACS::HMI::Subject
static void erase (Subject *sub, Command *command=0, bool post=false)
 
- 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)
 
- Protected Member Functions inherited from YACS::HMI::SubjectNode
virtual SubjectInputPortaddSubjectInputPort (YACS::ENGINE::InputPort *port, std::string name="")
 
virtual SubjectOutputPortaddSubjectOutputPort (YACS::ENGINE::OutputPort *port, std::string name="")
 
virtual SubjectInputDataStreamPortaddSubjectIDSPort (YACS::ENGINE::InputDataStreamPort *port, std::string name="")
 
virtual SubjectOutputDataStreamPortaddSubjectODSPort (YACS::ENGINE::OutputDataStreamPort *port, std::string name="")
 
virtual void notifyObserver (YACS::ENGINE::Node *object, const std::string &event)
 

Detailed Description

Definition at line 586 of file guiObservers.hxx.

Constructor & Destructor Documentation

◆ SubjectSwitch()

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

Definition at line 3092 of file guiObservers.cxx.

3093 : SubjectComposedNode(aSwitch, parent), _switch(aSwitch)
3094{
3095 _bodyMap.clear();
3096}
SubjectComposedNode(YACS::ENGINE::ComposedNode *composedNode, Subject *parent)
YACS::ENGINE::Switch * _switch
std::map< int, SubjectNode * > _bodyMap

References _bodyMap.

◆ ~SubjectSwitch()

SubjectSwitch::~SubjectSwitch ( )
virtual

Definition at line 3098 of file guiObservers.cxx.

3099{
3100 DEBTRACE("SubjectSwitch::~SubjectSwitch " << getName());
3101}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual std::string getName()

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

Member Function Documentation

◆ addNode()

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.

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}
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::string _lastErrorMessage
Definition: guiContext.hxx:79
virtual SubjectNode * createNode(YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst, int swCase=0)

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().

◆ clean()

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.

3104{
3105 if (_askRegisterUndo)
3106 {
3107 _askRegisterUndo = false;
3109 }
3110 localclean(command);
3112}
virtual void clean(Command *command=0)
void localclean(Command *command=0)

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

◆ completeChildrenSubjectList()

void SubjectSwitch::completeChildrenSubjectList ( SubjectNode son)
virtual

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3190 of file guiObservers.cxx.

3191{
3192 DEBTRACE("SubjectSwitch::completeChildrenSubjectList");
3193 _bodyMap[_switch->getRankOfNode(son->getNode())] = son;
3194}
int getRankOfNode(Node *node) const
Definition: Switch.cxx:752
virtual YACS::ENGINE::Node * getNode()

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

◆ getBodyMap()

std::map< int, SubjectNode * > SubjectSwitch::getBodyMap ( )

Definition at line 3175 of file guiObservers.cxx.

3176{
3177 return _bodyMap;
3178}

References _bodyMap.

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

◆ getChild()

SubjectNode * SubjectSwitch::getChild ( YACS::ENGINE::Node node = 0) const
virtual

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3196 of file guiObservers.cxx.

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}

References _bodyMap.

◆ getType()

virtual TypeOfElem YACS::HMI::SubjectSwitch::getType ( )
inlinevirtual

Reimplemented from YACS::HMI::Subject.

Definition at line 610 of file guiObservers.hxx.

610{return SWITCH;}

References YACS::HMI::SWITCH.

◆ getValue()

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.

3259{
3261}
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: DataPort.cxx:84
InputPort * edGetConditionPort()
Definition: Switch.hxx:115

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

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

◆ hasValue()

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.

3254{
3255 return true;
3256}

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

◆ houseKeepingAfterCutPaste()

void SubjectSwitch::houseKeepingAfterCutPaste ( bool  isCut,
SubjectNode son 
)
virtual

Reimplemented from YACS::HMI::SubjectComposedNode.

Definition at line 3180 of file guiObservers.cxx.

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}

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

◆ localclean()

void SubjectSwitch::localclean ( Command command = 0)

Definition at line 3114 of file guiObservers.cxx.

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}
static void erase(Subject *sub, Command *command=0, bool post=false)

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

Referenced by clean().

◆ recursiveUpdate()

void SubjectSwitch::recursiveUpdate ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SubjectNode.

Definition at line 3123 of file guiObservers.cxx.

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}
virtual void update(GuiEvent event, int type, Subject *son)

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

◆ removeNode()

void SubjectSwitch::removeNode ( SubjectNode son)
virtual

Definition at line 3150 of file guiObservers.cxx.

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}

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

◆ setCase()

bool SubjectSwitch::setCase ( std::string  caseId,
SubjectNode snode 
)
virtual

Definition at line 3229 of file guiObservers.cxx.

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}
std::string getChildName(const Node *node) const
Base class for all nodes.
Definition: Node.hxx:70
Base class for all schema objects.
Definition: Proc.hxx:44
Control node that emulates the C switch.
Definition: Switch.hxx:85
virtual bool execute()
the command is executed a first time after its registration for undo redo, then on redo
Definition: commands.cxx:51
YACS::HMI::ProcInvoc * getInvoc()
Definition: guiContext.hxx:51
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
void add(Command *command)
Definition: commands.cxx:156

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().

◆ setSelect()

bool SubjectSwitch::setSelect ( std::string  select)
virtual

Member Data Documentation

◆ _bodyMap

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

◆ _switch

YACS::ENGINE::Switch* YACS::HMI::SubjectSwitch::_switch
protected

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