Version: 8.3.0
YACS::HMI::SubjectNode Class Reference

#include <guiObservers.hxx>

Inheritance diagram for YACS::HMI::SubjectNode:
Collaboration diagram for YACS::HMI::SubjectNode:

Public Member Functions

 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 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)
 
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 notifyObserver2 (Node *object, const std::string &event, void *something)
 
virtual ~Observer ()
 

Static Public Member Functions

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

virtual SubjectInputPortaddSubjectInputPort (YACS::ENGINE::InputPort *port, std::string name="")
 
virtual SubjectOutputPortaddSubjectOutputPort (YACS::ENGINE::OutputPort *port, std::string name="")
 
virtual
SubjectInputDataStreamPort
addSubjectIDSPort (YACS::ENGINE::InputDataStreamPort *port, std::string name="")
 
virtual
SubjectOutputDataStreamPort
addSubjectODSPort (YACS::ENGINE::OutputDataStreamPort *port, std::string name="")
 
virtual void notifyObserver (YACS::ENGINE::Node *object, const std::string &event)
 

Protected Attributes

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
 

Friends

class CommandAddInputPortFromCatalog
 
class CommandAddOutputPortFromCatalog
 
class CommandAddIDSPortFromCatalog
 
class CommandAddODSPortFromCatalog
 

Detailed Description

Definition at line 284 of file guiObservers.hxx.

Constructor & Destructor Documentation

SubjectNode::SubjectNode ( YACS::ENGINE::Node node,
Subject parent 
)

Definition at line 503 of file guiObservers.cxx.

References _execState, _listSubjectControlLink, _listSubjectIDSPort, _listSubjectInputPort, _listSubjectLink, _listSubjectODSPort, _listSubjectOutputPort, YACS::ENGINE::Dispatcher::addObserver(), and YACS::UNDEFINED.

504  : Subject(parent), _node(node)
505 {
506  _listSubjectInputPort.clear();
507  _listSubjectOutputPort.clear();
508  _listSubjectIDSPort.clear();
509  _listSubjectODSPort.clear();
510  _listSubjectLink.clear();
511  _listSubjectControlLink.clear();
513  Dispatcher* d=Dispatcher::getDispatcher();
514  d->addObserver(this,node,"status");
515 }
SubjectNode::~SubjectNode ( )
virtual

all destruction is done in generic class SubjectNode

Definition at line 520 of file guiObservers.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectNode, _node, DEBTRACE, YACS::ENGINE::ComposedNode::edRemoveChild(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getFather(), getName(), and YACS::Exception::what().

521 {
522  DEBTRACE("SubjectNode::~SubjectNode " << getName());
523  Dispatcher::getDispatcher()->removeObserver(this,_node,"status");
524 
525  ComposedNode* father = _node->getFather();
527  if (father)
528  try
529  {
530  // Remove child except if it's the splitter node of a ForEachLoop
531  if (dynamic_cast<ForEachLoop*>(father) == NULL ||
532  getName() != ForEachLoop::NAME_OF_SPLITTERNODE)
533  {
534  father->edRemoveChild(_node);
535  }
536  }
537  catch (YACS::Exception &e)
538  {
539  DEBTRACE("------------------------------------------------------------------------------");
540  DEBTRACE("SubjectNode::localClean: father->edRemoveChild: YACS exception " << e.what());
541  DEBTRACE("------------------------------------------------------------------------------");
542  }
543 }

Member Function Documentation

SubjectControlLink* YACS::HMI::SubjectNode::addSubjectControlLink ( SubjectControlLink sub)
inline

Definition at line 302 of file guiObservers.hxx.

Referenced by YACS::HMI::SubjectComposedNode::addSubjectControlLink().

302 { _listSubjectControlLink.push_back(sub); return sub; };
SubjectInputDataStreamPort * SubjectNode::addSubjectIDSPort ( YACS::ENGINE::InputDataStreamPort port,
std::string  name = "" 
)
protectedvirtual
SubjectInputPort * SubjectNode::addSubjectInputPort ( YACS::ENGINE::InputPort port,
std::string  name = "" 
)
protectedvirtual

Definition at line 1131 of file guiObservers.cxx.

References _listSubjectInputPort, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::ADD, YACS::HMI::SubjectProc::addSubjectDataType(), DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::DataPort::getName(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::INPUTPORT, YACS::ENGINE::TypeCode::name(), YACS::HMI::SubjectDataPort::setName(), and update().

Referenced by YACS::HMI::SubjectComposedNode::loadChildren(), and YACS::HMI::SubjectElementaryNode::loadChildren().

1133 {
1134  string theName = name;
1135  if (name.empty()) theName =port->getName();
1136  DEBTRACE("SubjectNode::addSubjectInputPort "<< theName);
1137  SubjectInputPort *son = new SubjectInputPort(port, this);
1138  GuiContext::getCurrent()->_mapOfSubjectDataPort[static_cast<DataPort*>(port)] = son;
1139  _listSubjectInputPort.push_back(son);
1140  if (!name.empty()) son->setName(name);
1141  update(ADD, INPUTPORT ,son);
1142  YACS::ENGINE::TypeCode *typcod = port->edGetType();
1143  if (!GuiContext::getCurrent()->getSubjectProc()->addComSubjectDataType(typcod, typcod->name()))
1144  GuiContext::getCurrent()->getSubjectProc()->addSubjectDataType(typcod, typcod->name()); // --- new type of forEachLoop
1145  return son;
1146 }
SubjectOutputDataStreamPort * SubjectNode::addSubjectODSPort ( YACS::ENGINE::OutputDataStreamPort port,
std::string  name = "" 
)
protectedvirtual
SubjectOutputPort * SubjectNode::addSubjectOutputPort ( YACS::ENGINE::OutputPort port,
std::string  name = "" 
)
protectedvirtual
bool SubjectNode::copy ( Subject parent)
virtual

Definition at line 812 of file guiObservers.cxx.

References YACS::HMI::GuiContext::_lastErrorMessage, _node, YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), getNode(), YACS::HMI::Subject::getParent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Node::getProc(), and YASSERT.

813 {
814  DEBTRACE("SubjectNode::copy");
815  Subject *sop = getParent(); // --- old parent subject
816  SubjectComposedNode *snp = dynamic_cast<SubjectComposedNode*>(parent); // --- new parent subject
817  if (!snp)
818  {
819  GuiContext::getCurrent()->_lastErrorMessage = "new parent must be a composed node";
820  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
821  return false;
822  }
823  ComposedNode *cnp = dynamic_cast<ComposedNode*>(snp->getNode());
824  YASSERT(cnp);
825  Proc *proc = GuiContext::getCurrent()->getProc();
826  Proc *fromproc=_node->getProc();
827  if(proc != fromproc)
828  {
829  GuiContext::getCurrent()->_lastErrorMessage = "It is not possible to paste an object from one schema to another.";
830  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
831  return false;
832  }
833 
834  string position = "";
835  if (fromproc != dynamic_cast<Proc*>(_node))
836  position = fromproc->getChildName(_node);
837  else
838  position = _node->getName();
839 
840  string newParent = "";
841  if (proc != dynamic_cast<Proc*>(cnp))
842  newParent = proc->getChildName(cnp);
843  else
844  newParent = cnp->getName();
845 
846  CommandCopyNode *command = new CommandCopyNode(fromproc, position, newParent);
847  if (command->execute())
848  {
849  GuiContext::getCurrent()->getInvoc()->add(command);
850  return true;
851  }
852  else delete command;
853  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
854  return false;
855 
856 }
std::string SubjectNode::getName ( )
virtual

Reimplemented from YACS::HMI::Subject.

Reimplemented in YACS::HMI::SubjectSplitterNode.

Definition at line 858 of file guiObservers.cxx.

References _node, and YACS::ENGINE::Node::getName().

Referenced by YACS::HMI::SubjectComposedNode::addSubjectControlLink(), YACS::HMI::SubjectComposedNode::addSubjectLink(), YACS::HMI::SubjectServiceNode::addSubjectReference(), YACS::HMI::SubjectServiceNode::associateToComponent(), YACS::HMI::SubjectProc::cleanPostErase(), YACS::HMI::SubjectForEachLoop::completeChildrenSubjectList(), YACS::HMI::GenericGui::displayPortLinks(), YACS::HMI::SubjectProc::loadProc(), YACS::HMI::SubjectDynParaLoop::localclean(), YACS::HMI::SubjectForEachLoop::localclean(), YACS::HMI::CommandAddLink::localExecute(), YACS::HMI::CommandAddControlLink::localExecute(), YACS::HMI::GenericGui::onEmphasisCtrlLinks(), YACS::HMI::GenericGui::onEmphasisPortLinks(), YACS::HMI::GuiEditor::PutGraphInBloc(), YACS::HMI::GuiEditor::PutGraphInNode(), registerUndoDestroy(), YACS::HMI::SubjectComposedNode::removeControlLink(), removeExternalControlLinks(), YACS::HMI::SubjectComposedNode::removeExternalControlLinks(), removeExternalLinks(), YACS::HMI::SubjectSwitch::removeNode(), YACS::HMI::SubjectForEachLoop::removeNode(), YACS::HMI::SubjectComponent::removeSubServiceFromSet(), YACS::HMI::SubjectControlLink::SubjectControlLink(), YACS::HMI::SubjectLink::SubjectLink(), tryCreateLink(), YACS::HMI::SubjectBloc::~SubjectBloc(), YACS::HMI::SubjectComposedNode::~SubjectComposedNode(), YACS::HMI::SubjectCORBANode::~SubjectCORBANode(), YACS::HMI::SubjectCppNode::~SubjectCppNode(), YACS::HMI::SubjectDataNode::~SubjectDataNode(), YACS::HMI::SubjectDynParaLoop::~SubjectDynParaLoop(), YACS::HMI::SubjectElementaryNode::~SubjectElementaryNode(), YACS::HMI::SubjectForEachLoop::~SubjectForEachLoop(), YACS::HMI::SubjectForLoop::~SubjectForLoop(), YACS::HMI::SubjectInlineNode::~SubjectInlineNode(), ~SubjectNode(), YACS::HMI::SubjectOptimizerLoop::~SubjectOptimizerLoop(), YACS::HMI::SubjectOutNode::~SubjectOutNode(), YACS::HMI::SubjectPresetNode::~SubjectPresetNode(), YACS::HMI::SubjectProc::~SubjectProc(), YACS::HMI::SubjectPyFuncNode::~SubjectPyFuncNode(), YACS::HMI::SubjectPythonNode::~SubjectPythonNode(), YACS::HMI::SubjectSalomeNode::~SubjectSalomeNode(), YACS::HMI::SubjectSalomePythonNode::~SubjectSalomePythonNode(), YACS::HMI::SubjectServiceNode::~SubjectServiceNode(), YACS::HMI::SubjectStudyInNode::~SubjectStudyInNode(), YACS::HMI::SubjectStudyOutNode::~SubjectStudyOutNode(), YACS::HMI::SubjectSwitch::~SubjectSwitch(), YACS::HMI::SubjectWhileLoop::~SubjectWhileLoop(), and YACS::HMI::SubjectXmlNode::~SubjectXmlNode().

859 {
860  return _node->getName();
861 }
YACS::ENGINE::Node * SubjectNode::getNode ( )
virtual

Definition at line 863 of file guiObservers.cxx.

References _node.

Referenced by YACS::HMI::GuiEditor::_createNode(), YACS::HMI::SubjectComposedNode::addSubjectControlLink(), YACS::HMI::SceneBlocItem::arrangeChildNodes(), YACS::HMI::SceneComposedNodeItem::arrangeNodes(), YACS::HMI::EditionScript::changeContainer(), YACS::HMI::SubjectForEachLoop::clean(), YACS::HMI::SubjectSwitch::completeChildrenSubjectList(), YACS::HMI::SubjectDynParaLoop::completeChildrenSubjectList(), copy(), YACS::HMI::GuiEditor::CreateInputPort(), YACS::HMI::GuiEditor::CreateOutputPort(), YACS::HMI::Subject::destroy(), YACS::HMI::EditionForEachLoop::EditionForEachLoop(), YACS::HMI::EditionNode::EditionNode(), YACS::HMI::EditionPyFunc::EditionPyFunc(), YACS::HMI::EditionSalomeNode::EditionSalomeNode(), YACS::HMI::EditionScript::EditionScript(), YACS::HMI::EditionScript::fillContainerPanel(), YACS::HMI::SchemaComposedNodeItem::getDirectDescendants(), YACS::HMI::SceneNodeItem::getHeaderLabel(), YACS::HMI::SubjectComposedNode::getLowestCommonAncestor(), YACS::HMI::SubjectSwitch::houseKeepingAfterCutPaste(), YACS::HMI::TablePortsEdition::on_pb_insert_clicked(), YACS::HMI::EditionScript::on_remote_toggled(), YACS::HMI::GenericGui::onGetContainerLog(), YACS::HMI::GenericGui::onGetErrorDetails(), YACS::HMI::GenericGui::onGetErrorReport(), YACS::HMI::EditionForEachLoop::onModifyCollection(), YACS::HMI::EditionOptimizerLoop::onModifyEntry(), YACS::HMI::EditionOptimizerLoop::onModifyInitFile(), YACS::HMI::EditionOptimizerLoop::onModifyLib(), YACS::HMI::EditionPyFunc::onTemplate(), YACS::HMI::SubjectDataPort::registerUndoDestroy(), YACS::HMI::SubjectInputDataStreamPort::registerUndoDestroy(), YACS::HMI::SubjectOutputDataStreamPort::registerUndoDestroy(), registerUndoDestroy(), YACS::HMI::SubjectLink::registerUndoDestroy(), YACS::HMI::SubjectControlLink::registerUndoDestroy(), YACS::HMI::SubjectComposedNode::removeControlLink(), removeExternalControlLinks(), YACS::HMI::SubjectComposedNode::removeExternalControlLinks(), removeExternalLinks(), reparent(), saveLinks(), YACS::HMI::SubjectOptimizerLoop::setAlgorithm(), YACS::HMI::SubjectSwitch::setCase(), YACS::HMI::SchemaNodeItem::setCaseValue(), YACS::HMI::SchemaComposedNodeItem::setCaseValue(), YACS::HMI::SubjectWhileLoop::setCondition(), YACS::HMI::SubjectDynParaLoop::setNbBranches(), YACS::HMI::SubjectForLoop::setNbSteps(), YACS::HMI::SubjectSwitch::setSelect(), YACS::HMI::SceneNodeItem::showOutScopeLinks(), YACS::HMI::SubjectControlLink::SubjectControlLink(), YACS::HMI::SubjectLink::SubjectLink(), YACS::HMI::EditionScript::synchronize(), YACS::HMI::SchemaNodeItem::toggleState(), YACS::HMI::SubjectDataPort::tryCreateLink(), tryCreateLink(), YACS::HMI::SchemaComponentItem::update(), YACS::HMI::SchemaNodeItem::update(), YACS::HMI::SchemaComposedNodeItem::update(), YACS::HMI::SceneComposedNodeItem::update(), YACS::HMI::EditionNode::update(), YACS::HMI::EditionLoop::update(), YACS::HMI::EditionForEachLoop::update(), YACS::HMI::EditionOptimizerLoop::update(), YACS::HMI::EditionScript::update(), YACS::HMI::GuiExecutor::updateSchema(), YACS::HMI::SceneNodeItem::updateState(), and YACS::HMI::SubjectControlLink::~SubjectControlLink().

864 {
865  return _node;
866 }
std::map< std::string, std::string > SubjectNode::getProperties ( )
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 1293 of file guiObservers.cxx.

References _node, and YACS::ENGINE::Node::getPropertyMap().

1294 {
1295  return _node->getPropertyMap();
1296 }
std::list<SubjectInputDataStreamPort*> YACS::HMI::SubjectNode::getSubjectInputDataStreamPorts ( ) const
inline

Definition at line 308 of file guiObservers.hxx.

308 { return _listSubjectIDSPort; };
std::list<SubjectInputPort*> YACS::HMI::SubjectNode::getSubjectInputPorts ( ) const
inline

Definition at line 306 of file guiObservers.hxx.

Referenced by YACS::HMI::GenericGui::onEmphasisPortLinks().

306 { return _listSubjectInputPort; };
std::list<SubjectLink*> YACS::HMI::SubjectNode::getSubjectLinks ( ) const
inline

Definition at line 304 of file guiObservers.hxx.

304 { return _listSubjectLink; };
std::list<SubjectOutputDataStreamPort*> YACS::HMI::SubjectNode::getSubjectOutputDataStreamPorts ( ) const
inline

Definition at line 309 of file guiObservers.hxx.

309 { return _listSubjectODSPort; };
std::list<SubjectOutputPort*> YACS::HMI::SubjectNode::getSubjectOutputPorts ( ) const
inline

Definition at line 307 of file guiObservers.hxx.

Referenced by YACS::HMI::GenericGui::onEmphasisPortLinks().

307 { return _listSubjectOutputPort; };
int SubjectNode::isValid ( )
virtual

Definition at line 868 of file guiObservers.cxx.

References _node, and YACS::ENGINE::Node::isValid().

Referenced by YACS::HMI::ComposedNodeMenu::popupMenu(), and YACS::HMI::ElementaryNodeMenu::popupMenu().

869 {
870  return _node->isValid();
871 }
void SubjectNode::localclean ( Command command = 0)

Definition at line 556 of file guiObservers.cxx.

References _listSubjectControlLink, _listSubjectIDSPort, _listSubjectInputPort, _listSubjectLink, _listSubjectODSPort, _listSubjectOutputPort, YACS::HMI::Subject::_parent, DEBTRACE, YACS::HMI::Subject::erase(), and removeExternalLinks().

Referenced by clean().

557 {
558  DEBTRACE("SubjectNode::localClean ");
560  {
561  list<SubjectLink*>::iterator its;
562  list<SubjectLink*> cpll = _listSubjectLink;
563  for (its = cpll.begin(); its != cpll.end(); ++its)
564  erase(*its);
565  }
566  {
567  list<SubjectControlLink*>::iterator its;
568  list<SubjectControlLink*> cplcl = _listSubjectControlLink;
569  for (its = cplcl.begin(); its != cplcl.end(); ++its)
570  erase(*its);
571  }
572  {
573  list<SubjectInputPort*>::iterator iti;
574  list<SubjectInputPort*> cpli = _listSubjectInputPort;
575  for(iti = cpli.begin(); iti != cpli.end(); ++iti)
576  erase(*iti);
577  }
578  {
579  list<SubjectOutputPort*>::iterator ito;
580  list<SubjectOutputPort*> cplo = _listSubjectOutputPort;
581  for(ito = cplo.begin(); ito != cplo.end(); ++ito)
582  erase(*ito);
583  }
584  {
585  list<SubjectInputDataStreamPort*>::iterator itid;
586  list<SubjectInputDataStreamPort*> cplid = _listSubjectIDSPort;
587  for(itid = cplid.begin(); itid != cplid.end(); ++itid)
588  erase(*itid);
589  }
590  {
591  list<SubjectOutputDataStreamPort*>::iterator itod;
592  list<SubjectOutputDataStreamPort*> cplod = _listSubjectODSPort;
593  for(itod = cplod.begin(); itod != cplod.end(); ++itod)
594  erase(*itod);
595  }
596  if (_parent)
597  {
598  if( SubjectBloc* sb = dynamic_cast<SubjectBloc*>(_parent) )
599  sb->removeNode(this);
600  else if( SubjectForLoop* sfl = dynamic_cast<SubjectForLoop*>(_parent) )
601  sfl->completeChildrenSubjectList( 0 );
602  else if( SubjectWhileLoop* swl = dynamic_cast<SubjectWhileLoop*>(_parent) )
603  swl->completeChildrenSubjectList( 0 );
604  else if( SubjectDynParaLoop* sdpl = dynamic_cast<SubjectDynParaLoop*>(_parent) )
605  sdpl->removeNode(this);
606  else if( SubjectSwitch* ss = dynamic_cast<SubjectSwitch*>(_parent) )
607  ss->removeNode(this);
608  }
609 }
void SubjectNode::notifyObserver ( YACS::ENGINE::Node object,
const std::string &  event 
)
protectedvirtual

Reimplemented from YACS::ENGINE::Observer.

Definition at line 892 of file guiObservers.cxx.

References DEBTRACE, YACS::ENGINE::Node::getName(), YACS::HMI::ProcInvoc::getTypeOfNode(), YACS::HMI::UPDATE, and update().

893 {
894  DEBTRACE("SubjectNode::notifyObserver " << object->getName() << " " << event);
895  TypeOfElem ntyp = ProcInvoc::getTypeOfNode(object);
896  update(UPDATE, ntyp , 0 );
897 }
bool SubjectNode::putInComposedNode ( std::string  name,
std::string  type,
bool  toSaveRestoreLinks = true 
)
virtual

Definition at line 1114 of file guiObservers.cxx.

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

Referenced by YACS::HMI::GuiEditor::_createNode(), YACS::HMI::GuiEditor::PutGraphInBloc(), and YACS::HMI::GuiEditor::PutGraphInNode().

1115 {
1116  Proc *proc = GuiContext::getCurrent()->getProc();
1117  string position = "";
1118  if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
1119 
1120  CommandPutInComposedNode *command = new CommandPutInComposedNode(position, name, type, toSaveRestoreLinks);
1121  if (command->execute())
1122  {
1123  GuiContext::getCurrent()->getInvoc()->add(command);
1124  return true;
1125  }
1126  else delete command;
1127  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
1128  return false;
1129 }
void SubjectNode::registerUndoDestroy ( )

Definition at line 611 of file guiObservers.cxx.

References YACS::HMI::Invocator::_ctr, YACS::HMI::GuiContext::_mapOfSubjectComponent, YACS::HMI::GuiContext::_mapOfSubjectLink, _node, YACS::HMI::Invocator::add(), YACS::ENGINE::ElementaryNode::begin(), YACS::ENGINE::Node::cloneWithoutCompAndContDeepCpy(), DEBTRACE, YACS::ENGINE::Bloc::edAddChild(), YACS::ENGINE::ComposedNode::edAddChild(), YACS::ENGINE::ComposedNode::getAllRecursiveNodes(), YACS::ENGINE::ComposedNode::getChildName(), YACS::ENGINE::ComponentInstance::getCompoName(), YACS::ENGINE::ServiceNode::getComponent(), YACS::ENGINE::ComponentInstance::getContainer(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getFather(), YACS::ENGINE::ComponentInstance::getInstanceName(), YACS::HMI::GuiContext::getInvoc(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Container::getName(), getName(), YACS::HMI::SubjectLink::getName(), getNode(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Node::getSetOfLinksComingInCurrentScope(), YACS::ENGINE::Node::getSetOfLinksLeavingCurrentScope(), getSubjectControlLinks(), YACS::HMI::Invocator::getUndoProc(), YACS::HMI::SubjectLink::registerUndoDestroy(), and YASSERT.

Referenced by clean(), YACS::HMI::SubjectComposedNode::clean(), YACS::HMI::SubjectBloc::clean(), YACS::HMI::SubjectProc::clean(), YACS::HMI::SubjectForLoop::clean(), YACS::HMI::SubjectWhileLoop::clean(), YACS::HMI::SubjectSwitch::clean(), YACS::HMI::SubjectDynParaLoop::clean(), YACS::HMI::SubjectForEachLoop::clean(), YACS::HMI::SubjectOptimizerLoop::clean(), YACS::HMI::SubjectElementaryNode::clean(), YACS::HMI::SubjectInlineNode::clean(), YACS::HMI::SubjectPythonNode::clean(), YACS::HMI::SubjectPyFuncNode::clean(), YACS::HMI::SubjectServiceNode::clean(), YACS::HMI::SubjectCORBANode::clean(), YACS::HMI::SubjectCppNode::clean(), YACS::HMI::SubjectSalomeNode::clean(), YACS::HMI::SubjectSalomePythonNode::clean(), YACS::HMI::SubjectXmlNode::clean(), YACS::HMI::SubjectSplitterNode::clean(), YACS::HMI::SubjectDataNode::clean(), YACS::HMI::SubjectPresetNode::clean(), YACS::HMI::SubjectOutNode::clean(), YACS::HMI::SubjectStudyInNode::clean(), and YACS::HMI::SubjectStudyOutNode::clean().

612 {
613  DEBTRACE("SubjectNode::registerUndoDestroy " << getName());
614 
615  Proc *undoProc = GuiContext::getCurrent()->getInvoc()->getUndoProc();
616  ComposedNode *oldFather = _node->getFather();
617 
618  // --- clone the node in undoProc
619 
620  ostringstream blocName;
621  blocName << "undoBloc_" << Invocator::_ctr++;
622  Bloc *undoBloc = new Bloc(blocName.str());
623  undoProc->edAddChild(undoBloc);
624  ComposedNode *newFather = undoBloc;
626  newFather->edAddChild(clone);
627 
628  // --- register a CommandCopyNode from undoProc
629 
630  Proc *proc = GuiContext::getCurrent()->getProc();
631  string position = proc->getName();
632  if (proc != dynamic_cast<Proc*>(_node->getFather())) position = proc->getChildName(_node->getFather());
633 
634  int swCase=0;
635  if (Switch* aswitch = dynamic_cast<Switch*>(_node->getFather()))
636  {
637  //the node is in a switch, save the case
638  swCase=aswitch->getRankOfNode(_node);
639  }
640 
641  CommandCopyNode *command = new CommandCopyNode(undoProc,
642  undoProc->getChildName(clone),
643  position, swCase);
644  GuiContext::getCurrent()->getInvoc()->add(command);
645 
646  // --- identify all the children service node
647 
648  list<ServiceNode*> serviceList;
649  serviceList.clear();
650  ServiceNode *service = 0;
651  ComposedNode *cnode = 0;
652  if (service = dynamic_cast<ServiceNode*>(_node))
653  serviceList.push_back(service);
654  else
655  cnode = dynamic_cast<ComposedNode*>(_node);
656  if (cnode)
657  {
658  list<Node*> children = cnode->getAllRecursiveNodes();
659  list<Node*>::iterator it = children.begin();
660  for (; it != children.end(); ++it)
661  if (service = dynamic_cast<ServiceNode*>(*it))
662  serviceList.push_back(service);
663  }
664 
665  // --- for all the children service node, find the componentInstance,
666  // see if the componentInstance has other services that will stay alive after the destroy
667  // if not, register a CommandAddComponentInstance
668  //
669 
670  list<ServiceNode*>::const_iterator ita = serviceList.begin();
671  for (; ita != serviceList.end(); ++ita)
672  {
673  bool instanceUsedOutside = false;
674  service = *ita;
675  ComponentInstance *compo = service->getComponent();
676  if (!compo) break;
677  YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo));
679  //list<ServiceNode*> compServiceSet;
680  set<SubjectServiceNode*>::const_iterator itset = scomp->_subServiceSet.begin();
681  for (; itset != scomp->_subServiceSet.end(); ++itset)
682  {
683  ServiceNode *sn = dynamic_cast<ServiceNode*>((*itset)->getNode());
684  if (sn && (sn != service))
685  {
686  //compServiceSet.push_back(sn);
687  instanceUsedOutside = true;
688  list<ServiceNode*>::const_iterator itb = serviceList.begin();
689  for (; itb != serviceList.end(); ++itb)
690  {
691  if ((*itb) == sn)
692  {
693  instanceUsedOutside = false;
694  break;
695  }
696  }
697  if (instanceUsedOutside)
698  break;
699  }
700  }
701 
702  string instanceName = compo->getInstanceName();
703  if (!instanceUsedOutside)
704  {
705  string compoName = compo->getCompoName();
706  string containerName = compo->getContainer()->getName();
707  CommandAddComponentInstance *comaci = new CommandAddComponentInstance(compoName, containerName, instanceName);
708  GuiContext::getCurrent()->getInvoc()->add(comaci);
709  }
710 
711  string servicePos = proc->getChildName(service);
713  instanceName);
714  GuiContext::getCurrent()->getInvoc()->add(comastc);
715  }
716 
717  // --- explore all the external links and register commands for recreation
718 
719  vector<pair<OutPort *, InPort *> > listLeaving = getNode()->getSetOfLinksLeavingCurrentScope();
720  vector<pair<InPort *, OutPort *> > listIncoming = getNode()->getSetOfLinksComingInCurrentScope();
721  vector<pair<OutPort *, InPort *> > globalList = listLeaving;
722  vector<pair<InPort *, OutPort *> >::iterator it1;
723  for (it1 = listIncoming.begin(); it1 != listIncoming.end(); ++it1)
724  {
725  pair<OutPort *, InPort *> outin = pair<OutPort *, InPort *>((*it1).second, (*it1).first);
726  globalList.push_back(outin);
727  }
728  vector<pair<OutPort *, InPort *> >::iterator it2;
729  for (it2 = globalList.begin(); it2 != globalList.end(); ++it2)
730  {
731  SubjectLink* subject = 0;
732  if (GuiContext::getCurrent()->_mapOfSubjectLink.count(*it2))
733  {
734  subject = GuiContext::getCurrent()->_mapOfSubjectLink[*it2];
735  YASSERT(subject);
736  DEBTRACE("register undo destroy link " << subject->getName());
737  subject->registerUndoDestroy();
738  }
739  }
740 
741  // --- explore all the external control links and register commands for recreation
742 
743  list<SubjectControlLink*> cplcl = getSubjectControlLinks();
744  list<SubjectControlLink*>::iterator its;
745  Node* node = getNode();
746  for (its = cplcl.begin(); its != cplcl.end(); ++its)
747  {
748  bool inside = true;
749  Node *nout = (*its)->getSubjectOutNode()->getNode();
750  Node *nin = (*its)->getSubjectInNode()->getNode();
751  inside = inside && (node == nout);
752  inside = inside && (node == nin);
753  if (!inside)
754  {
755  (*its)->registerUndoDestroy();
756  }
757  }
758 }
void SubjectNode::removeExternalControlLinks ( )
virtual

Reimplemented in YACS::HMI::SubjectComposedNode.

Definition at line 1275 of file guiObservers.cxx.

References DEBTRACE, YACS::HMI::Subject::erase(), getName(), getNode(), and getSubjectControlLinks().

Referenced by YACS::HMI::CommandReparentNode::localExecute(), YACS::HMI::CommandPutInComposedNode::localExecute(), YACS::HMI::CommandReparentNode::localReverse(), and YACS::HMI::CommandPutInComposedNode::localReverse().

1276 {
1277  DEBTRACE("SubjectNode::removeExternalControlLinks " << getName());
1278  list<SubjectControlLink*> cplcl = getSubjectControlLinks();
1279  list<SubjectControlLink*>::iterator its;
1280  Node* node = getNode();
1281  for (its = cplcl.begin(); its != cplcl.end(); ++its)
1282  {
1283  bool inside = true;
1284  Node *nout = (*its)->getSubjectOutNode()->getNode();
1285  Node *nin = (*its)->getSubjectInNode()->getNode();
1286  inside = inside && (node == nout);
1287  inside = inside && (node == nin);
1288  if (!inside)
1289  Subject::erase(*its);
1290  }
1291 }
void SubjectNode::removeExternalLinks ( )
virtual

Definition at line 1242 of file guiObservers.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectLink, DEBTRACE, YACS::HMI::Subject::erase(), YACS::HMI::GuiContext::getCurrent(), getName(), YACS::HMI::SubjectLink::getName(), getNode(), YACS::ENGINE::Node::getSetOfLinksComingInCurrentScope(), YACS::ENGINE::Node::getSetOfLinksLeavingCurrentScope(), and YASSERT.

Referenced by localclean(), YACS::HMI::CommandReparentNode::localExecute(), YACS::HMI::CommandPutInComposedNode::localExecute(), YACS::HMI::CommandReparentNode::localReverse(), and YACS::HMI::CommandPutInComposedNode::localReverse().

1243 {
1244  DEBTRACE("SubjectNode::removeExternalLinks " << getName());
1245  std::vector< std::pair<OutPort *, InPort *> > listLeaving = getNode()->getSetOfLinksLeavingCurrentScope();
1246  std::vector< std::pair<InPort *, OutPort *> > listIncoming = getNode()->getSetOfLinksComingInCurrentScope();
1247  std::vector< std::pair<OutPort *, InPort *> > globalList = listLeaving;
1248  std::vector< std::pair<InPort *, OutPort *> >::iterator it1;
1249  for (it1 = listIncoming.begin(); it1 != listIncoming.end(); ++it1)
1250  {
1251  std::pair<OutPort *, InPort *> outin = std::pair<OutPort *, InPort *>((*it1).second, (*it1).first);
1252  globalList.push_back(outin);
1253  }
1254  std::vector< std::pair<OutPort *, InPort *> >::iterator it2;
1255  for (it2 = globalList.begin(); it2 != globalList.end(); ++it2)
1256  {
1257  SubjectLink* subject = 0;
1258  if (GuiContext::getCurrent()->_mapOfSubjectLink.count(*it2))
1259  {
1260  subject = GuiContext::getCurrent()->_mapOfSubjectLink[*it2];
1261  YASSERT(subject);
1262  DEBTRACE("link to remove " << subject->getName());
1263  erase(subject);
1265  }
1266  else
1267  {
1268  DEBTRACE("------------------------------------------------------------------------------");
1269  DEBTRACE("SubjectNode::removeExternalLinks(): an external link not in map...");
1270  DEBTRACE("------------------------------------------------------------------------------");
1271  }
1272  }
1273 }
void YACS::HMI::SubjectNode::removeSubjectControlLink ( SubjectControlLink sub)
inline

Definition at line 303 of file guiObservers.hxx.

Referenced by YACS::HMI::SubjectComposedNode::removeControlLink().

303 { _listSubjectControlLink.remove(sub); };
bool SubjectNode::reparent ( Subject parent)
virtual

Definition at line 760 of file guiObservers.cxx.

References YACS::HMI::GuiContext::_lastErrorMessage, _node, YACS::HMI::Invocator::add(), YACS::HMI::Subject::CommandReparentNode, DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), getNode(), YACS::HMI::Subject::getParent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::Node::getProc(), and YASSERT.

Referenced by YACS::HMI::SceneComposedNodeItem::dropEvent(), and YACS::HMI::SchemaComposedNodeItem::dropMimeData().

761 {
762  DEBTRACE("SubjectNode::reparent");
763  Subject *sub = getParent(); // --- old parent subject
764  SubjectComposedNode *sop = dynamic_cast<SubjectComposedNode*>(sub);
765  YASSERT(sop);
766  SubjectComposedNode *snp = dynamic_cast<SubjectComposedNode*>(parent); // --- new parent subject
767  if (!snp)
768  {
769  GuiContext::getCurrent()->_lastErrorMessage = "new parent must be a composed node";
770  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
771  return false;
772  }
773  ComposedNode *cnp = dynamic_cast<ComposedNode*>(snp->getNode());
774  YASSERT(cnp);
775  Proc *proc = GuiContext::getCurrent()->getProc();
776  Proc *fromproc=_node->getProc();
777  if(proc != fromproc)
778  {
779  GuiContext::getCurrent()->_lastErrorMessage = "cut is not yet possible across procs";
780  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
781  return false;
782  }
783 
784  string position = "";
785  if (proc != dynamic_cast<Proc*>(_node))
786  position = proc->getChildName(_node);
787  else
788  position = _node->getName();
789 
790  string newParent = "";
791  if (proc != dynamic_cast<Proc*>(cnp))
792  newParent = proc->getChildName(cnp);
793  else
794  newParent = cnp->getName();
795 
796  CommandReparentNode *command = new CommandReparentNode(position, newParent);
797  if (command->execute())
798  {
799  GuiContext::getCurrent()->getInvoc()->add(command);
800  return true;
801  }
802  else delete command;
803  DEBTRACE(GuiContext::getCurrent()->_lastErrorMessage);
804  return false;
805 }
void SubjectNode::restoreLinks ( )
virtual

Reimplemented in YACS::HMI::SubjectElementaryNode.

Definition at line 987 of file guiObservers.cxx.

References YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::GuiContext::_mapOfSubjectNode, _node, YACS::HMI::SubjectComposedNode::addSubjectControlLink(), YACS::HMI::SubjectComposedNode::addSubjectLink(), dataflowLinks, dataLinks, DEBTRACE, YACS::ENGINE::ComposedNode::edAddCFLink(), YACS::ENGINE::ComposedNode::edAddDFLink(), YACS::ENGINE::ComposedNode::edAddLink(), YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getFather(), YACS::ENGINE::Node::getInGate(), YACS::ENGINE::Port::getNode(), YACS::ENGINE::Node::getOutGate(), YACS::ENGINE::OutGate::isAlreadyInSet(), loutgate, and singate.

Referenced by YACS::HMI::CommandReparentNode::localExecute(), YACS::HMI::CommandPutInComposedNode::localExecute(), YACS::HMI::CommandReparentNode::localReverse(), YACS::HMI::CommandPutInComposedNode::localReverse(), YACS::HMI::GuiEditor::PutGraphInBloc(), and YACS::HMI::SubjectElementaryNode::restoreLinks().

988 {
989  DEBTRACE("SubjectNode::restoreLinks");
990  //restore simple data links
991  std::vector< std::pair<OutPort *, InPort *> >::iterator it3;
992  for (it3 = dataLinks.begin(); it3 != dataLinks.end(); ++it3)
993  {
994  OutPort* p1=(*it3).first;
995  InPort* p2=(*it3).second;
996  Node* n1=p1->getNode();
997  Node* n2=p2->getNode();
998  ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
999  try
1000  {
1001  fath->edAddLink(p1,p2);
1002  }
1003  catch(Exception& ex)
1004  {
1005  // if a link can't be restored ignore it. It's possible when a node is reparented to a foreachloop
1006  continue;
1007  }
1009  SubjectNode *sno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n1)];
1010  SubjectNode *sni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n2)];
1013  scla->addSubjectLink(sno,spo,sni,spi);
1014  }
1015  //restore dataflow links
1016  for (it3 = dataflowLinks.begin(); it3 != dataflowLinks.end(); ++it3)
1017  {
1018  OutPort* p1=(*it3).first;
1019  InPort* p2=(*it3).second;
1020  Node* n1=p1->getNode();
1021  Node* n2=p2->getNode();
1022  ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
1023  try
1024  {
1025  fath->edAddDFLink(p1,p2);
1026  }
1027  catch(Exception& ex)
1028  {
1029  // if a link can't be restored ignore it. It's possible when a node is reparented to a foreachloop
1030  continue;
1031  }
1033  SubjectNode *sno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n1)];
1034  SubjectNode *sni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n2)];
1037  scla->addSubjectLink(sno,spo,sni,spi);
1038  if(n1==fath || n2==fath) continue;
1039  while(n1->getFather() != fath) n1=n1->getFather();
1040  while(n2->getFather() != fath) n2=n2->getFather();
1041  OutGate *ogate = n1->getOutGate();
1042  InGate *igate = n2->getInGate();
1043  if (ogate->isAlreadyInSet(igate))
1044  {
1045  pair<Node*,Node*> keyLink(n1,n2);
1046  if (!GuiContext::getCurrent()->_mapOfSubjectControlLink.count(keyLink))
1047  {
1048  SubjectNode *sfno = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n1)];
1049  SubjectNode *sfni = GuiContext::getCurrent()->_mapOfSubjectNode[static_cast<Node*>(n2)];
1050  scla->addSubjectControlLink(sfno, sfni);
1051  }
1052  }
1053  }
1054 
1055  //reconnect control links
1056  // links from another node to this node
1057  std::list<OutGate *>::const_iterator it;
1058  for(it=loutgate.begin();it != loutgate.end();it++)
1059  {
1060  Node* n1=(*it)->getNode();
1061  Node* n2=_node;
1062  if(GuiContext::getCurrent()->_mapOfSubjectNode.count(n1)==0)
1063  {
1064  //It's an internal node or a destroyed one : don't treat it
1065  continue;
1066  }
1067  ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
1068  if(n1 == fath)continue;
1069  if(n2 == fath)continue;
1070  //add a control link only if nodes are not in the same descendance
1071  while(n1->getFather() != fath) n1=n1->getFather();
1072  while(n2->getFather() != fath) n2=n2->getFather();
1073  OutGate *ogate = n1->getOutGate();
1074  InGate *igate = n2->getInGate();
1075  if (!ogate->isAlreadyInSet(igate))
1076  {
1077  fath->edAddCFLink(n1,n2);
1081  scla->addSubjectControlLink(subOutNode,subInNode);
1082  }
1083  }
1084 
1085  std::list<InGate *>::const_iterator it2;
1086  for(it2=singate.begin();it2 != singate.end();it2++)
1087  {
1088  Node* n1=_node;
1089  Node* n2=(*it2)->getNode();
1090  if(GuiContext::getCurrent()->_mapOfSubjectNode.count(n2)==0)
1091  {
1092  //It's an internal node or a destroyed one : don't treat it
1093  continue;
1094  }
1095  ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
1096  if(n1 == fath)continue;
1097  if(n2 == fath)continue;
1098  //add a control link only if nodes are not in the same descendance
1099  while(n1->getFather() != fath) n1=n1->getFather();
1100  while(n2->getFather() != fath) n2=n2->getFather();
1101  OutGate *ogate = n1->getOutGate();
1102  InGate *igate = n2->getInGate();
1103  if (!ogate->isAlreadyInSet(igate))
1104  {
1105  fath->edAddCFLink(n1,n2);
1109  scla->addSubjectControlLink(subOutNode,subInNode);
1110  }
1111  }
1112 }
void SubjectNode::saveLinks ( )
virtual

Reimplemented in YACS::HMI::SubjectElementaryNode.

Definition at line 899 of file guiObservers.cxx.

References _node, dataflowLinks, dataLinks, DEBTRACE, YACS::ENGINE::OutGate::edSetInGate(), YACS::ENGINE::InGate::getBackLinks(), YACS::ENGINE::Node::getFather(), YACS::ENGINE::Node::getInGate(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Port::getNode(), getNode(), YACS::ENGINE::Node::getOutGate(), YACS::ENGINE::Node::getSetOfLinksComingInCurrentScope(), YACS::ENGINE::Node::getSetOfLinksLeavingCurrentScope(), YACS::ENGINE::OutGate::isAlreadyInSet(), loutgate, and singate.

Referenced by YACS::HMI::CommandReparentNode::localExecute(), YACS::HMI::CommandPutInComposedNode::localExecute(), YACS::HMI::CommandReparentNode::localReverse(), YACS::HMI::CommandPutInComposedNode::localReverse(), YACS::HMI::GuiEditor::PutGraphInBloc(), and YACS::HMI::SubjectElementaryNode::saveLinks().

900 {
901  DEBTRACE("SubjectNode::saveLinks");
904  std::list<OutGate *>::const_iterator ito;
905  for(ito=loutgate.begin();ito != loutgate.end();ito++)
906  {
907  Node* n1=(*ito)->getNode();
908  Node* n2=_node;
909  DEBTRACE(n1->getName()<< " " << n2->getName());
910  }
911  std::list<InGate *>::const_iterator iti;
912  for(iti=singate.begin();iti != singate.end();iti++)
913  {
914  Node* n1=_node;
915  Node* n2=(*iti)->getNode();
916  DEBTRACE(n1->getName()<< " " << n2->getName());
917  }
918 
919  dataLinks.clear();
920  dataflowLinks.clear();
921 
922  std::vector< std::pair<OutPort *, InPort *> > listLeaving = getNode()->getSetOfLinksLeavingCurrentScope();
923  std::vector< std::pair<OutPort *, InPort *> >::iterator it3;
924  for (it3 = listLeaving.begin(); it3 != listLeaving.end(); ++it3)
925  {
926  OutPort* p1=(*it3).first;
927  InPort* p2=(*it3).second;
928  Node* n1=p1->getNode();
929  Node* n2=p2->getNode();
930  //are nodes in sequence (control link direct or indirect) ?
931  ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
932  if(n1 == fath ||n2 == fath)
933  {
934  //consider it as a data only link
935  DEBTRACE("It's a data link: " << n1->getName() << "." << p1->getName() << " -> "<< n2->getName() << "." << p2->getName());
936  dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
937  continue;
938  }
939  while(n1->getFather() != fath) n1=n1->getFather();
940  while(n2->getFather() != fath) n2=n2->getFather();
941  OutGate* outg=n1->getOutGate();
942  if(!outg->isAlreadyInSet(n2->getInGate()))
943  {
944  DEBTRACE("It's a data link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
945  dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
946  }
947  else
948  {
949  DEBTRACE("It's a dataflow link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
950  dataflowLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
951  }
952  }
953 
954  std::vector< std::pair<InPort *, OutPort *> > listIncoming = getNode()->getSetOfLinksComingInCurrentScope();
955  std::vector< std::pair<InPort *, OutPort *> >::iterator it4;
956  for (it4 = listIncoming.begin(); it4 != listIncoming.end(); ++it4)
957  {
958  OutPort* p1=(*it4).second;
959  InPort* p2=(*it4).first;
960  Node* n1=p1->getNode();
961  Node* n2=p2->getNode();
962  //are nodes in sequence (control link direct or indirect) ?
963  ComposedNode* fath= ComposedNode::getLowestCommonAncestor(n1,n2);
964  if(n1 == fath ||n2 == fath)
965  {
966  //consider it as a data only link
967  DEBTRACE("It's a data link: " << n1->getName() << "." << p1->getName() << " -> "<< n2->getName() << "." << p2->getName());
968  dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
969  continue;
970  }
971  while(n1->getFather() != fath) n1=n1->getFather();
972  while(n2->getFather() != fath) n2=n2->getFather();
973  OutGate* outg=n1->getOutGate();
974  if(!outg->isAlreadyInSet(n2->getInGate()))
975  {
976  DEBTRACE("It's a data link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
977  dataLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
978  }
979  else
980  {
981  DEBTRACE("It's a dataflow link: "<<p1->getNode()->getName()<<"."<<p1->getName()<<" -> "<< p2->getNode()->getName()<<"."<<p2->getName());
982  dataflowLinks.push_back(std::pair<OutPort *, InPort *>(p1,p2));
983  }
984  }
985 }
void SubjectNode::setExecState ( int  execState)

Definition at line 1166 of file guiObservers.cxx.

References _execState, update(), and YACS::HMI::UPDATEPROGRESS.

1167 {
1168  _execState = execState;
1170 }
bool SubjectNode::setName ( std::string  name)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 873 of file guiObservers.cxx.

References _node, YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), YACS::ENGINE::Node::getName(), and YACS::HMI::GuiContext::getProc().

Referenced by YACS::HMI::SubjectComposedNode::addSubjectNode().

874 {
875  DEBTRACE("SubjectNode::setName " << name);
876  Proc *proc = GuiContext::getCurrent()->getProc();
877  string position = "";
878  if (proc != dynamic_cast<Proc*>(_node))
879  position = proc->getChildName(_node);
880  else
881  position = _node->getName();
882  CommandRenameNode* command = new CommandRenameNode(position, name);
883  if (command->execute())
884  {
885  GuiContext::getCurrent()->getInvoc()->add(command);
886  return true;
887  }
888  else delete command;
889  return false;
890 }
bool SubjectNode::setProperties ( std::map< std::string, std::string >  properties)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 1298 of file guiObservers.cxx.

References _node, YACS::HMI::Invocator::add(), YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), and YACS::HMI::GuiContext::getProc().

1299 {
1300  Proc *proc = GuiContext::getCurrent()->getProc();
1301  string position = "";
1302  if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
1303 
1304  CommandSetNodeProperties *command = new CommandSetNodeProperties(position, properties);
1305  if (command->execute())
1306  {
1307  GuiContext::getCurrent()->getInvoc()->add(command);
1308  return true;
1309  }
1310  else delete command;
1311  return false;
1312 }
bool SubjectNode::tryCreateLink ( SubjectNode subOutNode,
SubjectNode subInNode 
)
static

Definition at line 1221 of file guiObservers.cxx.

References YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), getName(), getNode(), and YACS::HMI::GuiContext::getProc().

Referenced by YACS::HMI::SceneCtrlInPortItem::dropEvent(), YACS::HMI::SchemaNodeItem::dropMimeData(), and YACS::HMI::SchemaComposedNodeItem::dropMimeData().

1222 {
1223  DEBTRACE("SubjectNode::tryCreateLink " << subOutNode->getName() << " " << subInNode->getName());
1224  Proc *proc = GuiContext::getCurrent()->getProc();
1225  Node *outNode = subOutNode->getNode();
1226  string outNodePos = proc->getChildName(outNode);
1227  Node *inNode = subInNode->getNode();
1228  string inNodePos = proc->getChildName(inNode);
1229  CommandAddControlLink *command = new CommandAddControlLink(outNodePos, inNodePos);
1230  if (command->execute())
1231  {
1232  GuiContext::getCurrent()->getInvoc()->add(command);
1233  return true;
1234  }
1235  else
1236  {
1237  delete command;
1238  return false;
1239  }
1240 }
void SubjectNode::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 1148 of file guiObservers.cxx.

References YACS::HMI::Subject::update().

Referenced by YACS::HMI::SubjectProc::addSubjectComponent(), YACS::HMI::SubjectProc::addSubjectContainer(), YACS::HMI::SubjectComposedNode::addSubjectControlLink(), YACS::HMI::SubjectProc::addSubjectDataType(), addSubjectIDSPort(), addSubjectInputPort(), YACS::HMI::SubjectComposedNode::addSubjectLink(), YACS::HMI::SubjectComposedNode::addSubjectNode(), addSubjectODSPort(), addSubjectOutputPort(), YACS::HMI::SubjectServiceNode::addSubjectReference(), gui.graph.MyCanvas::customEvent(), YACS::HMI::GuiExecutor::event(), YACS::HMI::SubjectContainerBase::localclean(), YACS::HMI::CommandReparentNode::localExecute(), YACS::HMI::CommandPutInComposedNode::localExecute(), YACS::HMI::CommandSetNodeProperties::localExecute(), YACS::HMI::CommandSetExecutionMode::localExecute(), YACS::HMI::CommandSetContainer::localExecute(), YACS::HMI::CommandReparentNode::localReverse(), YACS::HMI::CommandPutInComposedNode::localReverse(), YACS::HMI::CommandSetNodeProperties::localReverse(), YACS::HMI::CommandSetExecutionMode::localReverse(), YACS::HMI::CommandSetContainer::localReverse(), notifyObserver(), recursiveUpdate(), YACS::HMI::SubjectBloc::recursiveUpdate(), YACS::HMI::SubjectForLoop::recursiveUpdate(), YACS::HMI::SubjectWhileLoop::recursiveUpdate(), YACS::HMI::SubjectSwitch::recursiveUpdate(), YACS::HMI::SubjectDynParaLoop::recursiveUpdate(), YACS::HMI::SubjectElementaryNode::recursiveUpdate(), YACS::HMI::ItemEdition::setEdited(), setExecState(), and YACS::HMI::GuiExecutor::updateSchema().

1149 {
1150  Subject::update( event, type, son );
1151 
1152  // remove subject data type if necessary
1153  YACS::HMI::SubjectDataPort* aSPort = dynamic_cast< YACS::HMI::SubjectDataPort* >( son );
1154 // if ( aSPort && event == REMOVE )
1155 // {
1156 // YACS::ENGINE::DataPort* aEPort = aSPort->getPort();
1157 // if ( aEPort )
1158 // {
1159 // YACS::ENGINE::TypeCode* aTypeCode = aEPort->edGetType();
1160 // if ( aTypeCode )
1161 // GuiContext::getCurrent()->getSubjectProc()->removeSubjectDataType( aTypeCode );
1162 // }
1163 // }
1164 }

Friends And Related Function Documentation

friend class CommandAddIDSPortFromCatalog
friend

Definition at line 289 of file guiObservers.hxx.

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

friend class CommandAddInputPortFromCatalog
friend

Definition at line 287 of file guiObservers.hxx.

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

friend class CommandAddODSPortFromCatalog
friend

Definition at line 290 of file guiObservers.hxx.

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

friend class CommandAddOutputPortFromCatalog
friend

Definition at line 288 of file guiObservers.hxx.

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

Member Data Documentation

int YACS::HMI::SubjectNode::_execState
protected

Definition at line 340 of file guiObservers.hxx.

Referenced by setExecState(), and SubjectNode().

std::list<SubjectControlLink*> YACS::HMI::SubjectNode::_listSubjectControlLink
protected
std::list<SubjectInputDataStreamPort*> YACS::HMI::SubjectNode::_listSubjectIDSPort
protected
std::list<SubjectInputPort*> YACS::HMI::SubjectNode::_listSubjectInputPort
protected
std::list<SubjectLink*> YACS::HMI::SubjectNode::_listSubjectLink
protected
std::list<SubjectOutputDataStreamPort*> YACS::HMI::SubjectNode::_listSubjectODSPort
protected
std::list<SubjectOutputPort*> YACS::HMI::SubjectNode::_listSubjectOutputPort
protected
std::vector< std::pair<YACS::ENGINE::OutPort *, YACS::ENGINE::InPort *> > YACS::HMI::SubjectNode::dataflowLinks
protected

Definition at line 344 of file guiObservers.hxx.

Referenced by restoreLinks(), and saveLinks().

std::vector< std::pair<YACS::ENGINE::OutPort *, YACS::ENGINE::InPort *> > YACS::HMI::SubjectNode::dataLinks
protected

Definition at line 343 of file guiObservers.hxx.

Referenced by restoreLinks(), and saveLinks().

std::list<YACS::ENGINE::OutGate *> YACS::HMI::SubjectNode::loutgate
protected

Definition at line 341 of file guiObservers.hxx.

Referenced by restoreLinks(), and saveLinks().

std::list<YACS::ENGINE::InGate *> YACS::HMI::SubjectNode::singate
protected

Definition at line 342 of file guiObservers.hxx.

Referenced by restoreLinks(), and saveLinks().


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