Version: 8.3.0
YACS::HMI::SubjectDataPort Class Reference

#include <guiObservers.hxx>

Inheritance diagram for YACS::HMI::SubjectDataPort:
Collaboration diagram for YACS::HMI::SubjectDataPort:

Public Member Functions

 SubjectDataPort (YACS::ENGINE::DataPort *port, Subject *parent)
 
virtual ~SubjectDataPort ()
 
virtual std::string getName ()
 
virtual bool setName (std::string name)
 
virtual YACS::ENGINE::DataPortgetPort ()
 
virtual void clean (Command *command=0)
 
void localclean (Command *command=0)
 
void addSubjectLink (SubjectLink *subject)
 
void removeSubjectLink (SubjectLink *subject)
 
std::list< SubjectLink * > getListOfSubjectLink ()
 
virtual bool setValue (std::string value)
 
void setExecValue (std::string value)
 
std::string getExecValue ()
 
void registerUndoDestroy ()
 
- 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 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)
 
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 ~Observer ()
 

Static Public Member Functions

static bool tryCreateLink (SubjectDataPort *subOutport, SubjectDataPort *subInport, bool control=true)
 
- Static Public Member Functions inherited from YACS::HMI::Subject
static void erase (Subject *sub, Command *command=0, bool post=false)
 

Protected Attributes

YACS::ENGINE::DataPort_dataPort
 
std::list< SubjectLink * > _listSubjectLink
 
std::string _execValue
 
- Protected Attributes inherited from YACS::HMI::Subject
std::set< GuiObserver * > _setObs
 
Subject_parent
 
bool _destructible
 
bool _askRegisterUndo
 
std::string _progress
 

Detailed Description

Definition at line 202 of file guiObservers.hxx.

Constructor & Destructor Documentation

SubjectDataPort::SubjectDataPort ( YACS::ENGINE::DataPort port,
Subject parent 
)

Definition at line 3506 of file guiObservers.cxx.

References _execValue, and _listSubjectLink.

3507  : Subject(parent), _dataPort(port)
3508 {
3509  _listSubjectLink.clear();
3510  _execValue = "";
3511 }
SubjectDataPort::~SubjectDataPort ( )
virtual

Definition at line 3513 of file guiObservers.cxx.

References _dataPort, DEBTRACE, YACS::ENGINE::ElementaryNode::edRemovePort(), getName(), YACS::ENGINE::Port::getNode(), YACS::HMI::Subject::isDestructible(), YACS::Exception::what(), and YASSERT.

3514 {
3515  DEBTRACE("SubjectDataPort::~SubjectDataPort " << getName());
3516  if (isDestructible())
3517  {
3518  Node* node = _dataPort->getNode();
3519  YASSERT(node);
3520  ElementaryNode * father = dynamic_cast<ElementaryNode*>(node);
3521  if (father)
3522  {
3523  DEBTRACE("father->edRemovePort(_dataPort)");
3524  try
3525  {
3526  father->edRemovePort(_dataPort);
3527  }
3528  catch (YACS::Exception &e)
3529  {
3530  DEBTRACE("------------------------------------------------------------------------------");
3531  DEBTRACE("SubjectDataPort::~SubjectDataPort: father->edRemovePort: YACS exception " << e.what());
3532  DEBTRACE("------------------------------------------------------------------------------");
3533  }
3534  }
3535  }
3536 }

Member Function Documentation

void YACS::HMI::SubjectDataPort::addSubjectLink ( SubjectLink subject)
inline

Definition at line 213 of file guiObservers.hxx.

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

213 { _listSubjectLink.push_back(subject); };
void SubjectDataPort::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::Subject.

Reimplemented in YACS::HMI::SubjectOutputDataStreamPort, YACS::HMI::SubjectInputDataStreamPort, YACS::HMI::SubjectOutputPort, and YACS::HMI::SubjectInputPort.

Definition at line 3538 of file guiObservers.cxx.

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

Referenced by YACS::HMI::SubjectInputPort::clean(), YACS::HMI::SubjectOutputPort::clean(), YACS::HMI::SubjectInputDataStreamPort::clean(), and YACS::HMI::SubjectOutputDataStreamPort::clean().

3539 {
3540  if (_askRegisterUndo)
3541  {
3542  _askRegisterUndo = false;
3544  }
3545  localclean(command);
3546  Subject::clean(command);
3547 }
std::string SubjectDataPort::getExecValue ( )

Definition at line 3650 of file guiObservers.cxx.

References _execValue.

Referenced by YACS::HMI::SchemaInPortItem::update(), YACS::HMI::SchemaOutPortItem::update(), and YACS::HMI::EditionLoop::update().

3651 {
3652  return _execValue;
3653 }
std::list<SubjectLink*> YACS::HMI::SubjectDataPort::getListOfSubjectLink ( )
inline

Definition at line 215 of file guiObservers.hxx.

Referenced by YACS::HMI::GenericGui::emphasizePortLink(), localclean(), and registerUndoDestroy().

215 { return _listSubjectLink; };
void SubjectDataPort::localclean ( Command command = 0)

Definition at line 3549 of file guiObservers.cxx.

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

Referenced by clean().

3550 {
3551  DEBTRACE("SubjectDataPort::localClean ");
3552  list<SubjectLink*> lsl = getListOfSubjectLink();
3553  for (list<SubjectLink*>::iterator it = lsl.begin(); it != lsl.end(); ++it)
3554  erase(*it);
3555 }
void SubjectDataPort::registerUndoDestroy ( )

Definition at line 3655 of file guiObservers.cxx.

References YACS::ENGINE::Catalog::_typeMap, YACS::HMI::Invocator::add(), DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), getListOfSubjectLink(), getName(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::Subject::getParent(), getPort(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::ElementaryNode::getSetOfInputPort(), YACS::ENGINE::ElementaryNode::getSetOfOutputPort(), YACS::HMI::Subject::getType(), YACS::HMI::Invocator::getUndoCata(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::ENGINE::TypeCode::name(), YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, and YASSERT.

Referenced by clean(), YACS::HMI::SubjectInputPort::clean(), YACS::HMI::SubjectOutputPort::clean(), YACS::HMI::SubjectInputDataStreamPort::registerUndoDestroy(), and YACS::HMI::SubjectOutputDataStreamPort::registerUndoDestroy().

3656 {
3657  DEBTRACE("SubjectDataPort::registerUndoDestroy");
3658  Proc *proc = GuiContext::getCurrent()->getProc();
3659  SubjectNode *sno = dynamic_cast<SubjectNode*>(getParent());
3660  YASSERT(sno);
3661  Node *node = sno->getNode();
3662  string nodeName = proc->getChildName(node);
3663  string portName = getName();
3664  ElementaryNode* father = dynamic_cast<ElementaryNode*>(node);
3665  YASSERT(father);
3666 
3667  DataPort *port = getPort();
3668  TypeCode *dtyp = port->edGetType();
3669  string typeName = dtyp->name();
3670  Catalog *undoCata = GuiContext::getCurrent()->getInvoc()->getUndoCata();
3671  undoCata->_typeMap[typeName] = dtyp;
3672 
3673  Command *command = 0;
3674  Command *comm2 =0;
3675  TypeOfElem elemType = getType();
3676  switch (elemType)
3677  {
3678  case INPUTPORT:
3679  command = new CommandAddInputPortFromCatalog(undoCata, typeName, nodeName, portName);
3680  {
3681  int rang = 1;
3682  int nbUp = 0;
3683  list<InputPort*> plist = father->getSetOfInputPort();
3684  list<InputPort*>::iterator pos = plist.begin();
3685  for (; (*pos) != port; pos++)
3686  rang++;
3687  nbUp = plist.size() -rang;
3688  if (nbUp)
3689  comm2 = new CommandOrderInputPorts(nodeName, portName, nbUp);
3690  }
3691  break;
3692  case OUTPUTPORT:
3693  command = new CommandAddOutputPortFromCatalog(undoCata, typeName, nodeName, portName);
3694  {
3695  int rang = 1;
3696  int nbUp = 0;
3697  list<OutputPort*> plist = father->getSetOfOutputPort();
3698  list<OutputPort*>::iterator pos = plist.begin();
3699  for (; (*pos) != port; pos++)
3700  rang++;
3701  nbUp = plist.size() -rang;
3702  if (nbUp)
3703  comm2 = new CommandOrderOutputPorts(nodeName, portName, nbUp);
3704  }
3705  break;
3706  case INPUTDATASTREAMPORT:
3707  command = new CommandAddIDSPortFromCatalog(undoCata, typeName, nodeName, portName);
3708  break;
3709  case OUTPUTDATASTREAMPORT:
3710  command = new CommandAddODSPortFromCatalog(undoCata, typeName, nodeName, portName);
3711  break;
3712  }
3713  if (command)
3714  GuiContext::getCurrent()->getInvoc()->add(command);
3715  if (comm2)
3716  GuiContext::getCurrent()->getInvoc()->add(comm2);
3717  //save links
3718  list<SubjectLink*> lsl = getListOfSubjectLink();
3719  for (list<SubjectLink*>::iterator it = lsl.begin(); it != lsl.end(); ++it)
3720  {
3721  (*it)->registerUndoDestroy();
3722  }
3723 }
void YACS::HMI::SubjectDataPort::removeSubjectLink ( SubjectLink subject)
inline

Definition at line 214 of file guiObservers.hxx.

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

214 { _listSubjectLink.remove(subject); };
void SubjectDataPort::setExecValue ( std::string  value)

Definition at line 3645 of file guiObservers.cxx.

References _execValue.

Referenced by YACS::HMI::GuiExecutor::event(), and YACS::HMI::GuiExecutor::updateSchema().

3646 {
3647  _execValue = value;
3648 }
bool SubjectDataPort::setName ( std::string  name)
virtual

Reimplemented from YACS::HMI::Subject.

Definition at line 3562 of file guiObservers.cxx.

References _dataPort, YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Port::getNode(), getPort(), YACS::HMI::GuiContext::getProc(), and YACS::HMI::Subject::getType().

Referenced by YACS::HMI::SubjectNode::addSubjectIDSPort(), YACS::HMI::SubjectNode::addSubjectInputPort(), YACS::HMI::SubjectNode::addSubjectODSPort(), YACS::HMI::SubjectNode::addSubjectOutputPort(), YACS::HMI::EditionElementaryNode::onCommitData(), and YACS::HMI::TreeView::onCommitData().

3563 {
3564  DEBTRACE("SubjectDataPort::setName " << name);
3565  Proc *proc = GuiContext::getCurrent()->getProc();
3566  string position = "";
3567  Node *node = getPort()->getNode();
3568  if (proc != dynamic_cast<Proc*>(node))
3569  position = proc->getChildName(node);
3570  else
3571  position = node->getName();
3572 
3573  Command *command = 0;
3574  bool isIn = dynamic_cast<InPort*>(_dataPort);
3575  if (isIn)
3576  command = new CommandRenameInDataPort(position, _dataPort->getName(),name, getType());
3577  else
3578  command = new CommandRenameOutDataPort(position, _dataPort->getName(),name, getType());
3579 
3580  if (command->execute())
3581  {
3582  GuiContext::getCurrent()->getInvoc()->add(command);
3583  return true;
3584  }
3585  else delete command;
3586  return false;
3587 }
bool SubjectDataPort::setValue ( std::string  value)
virtual
bool SubjectDataPort::tryCreateLink ( SubjectDataPort subOutport,
SubjectDataPort subInport,
bool  control = true 
)
static

Definition at line 3594 of file guiObservers.cxx.

References YACS::HMI::GuiContext::_lastErrorMessage, YACS::HMI::Invocator::add(), DEBTRACE, YACS::HMI::Command::execute(), YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getInvoc(), getName(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::Subject::getParent(), getPort(), YACS::HMI::GuiContext::getProc(), YACS::HMI::Subject::getType(), YACS::ENGINE::OutPort::isAlreadyLinkedWith(), and YASSERT.

Referenced by YACS::HMI::SceneInPortItem::dropEvent(), and YACS::HMI::SchemaInPortItem::dropMimeData().

3595 {
3596  DEBTRACE("SubjectDataPort::tryCreateLink");
3597 
3598  InPort *inp = dynamic_cast<InPort*>(subInport->getPort());
3599  OutPort *outp = dynamic_cast<OutPort*>(subOutport->getPort());
3600  if (outp && outp->isAlreadyLinkedWith(inp))
3601  {
3602  DEBTRACE("isAlreadyLinkedWith");
3603  GuiContext::getCurrent()->_lastErrorMessage = "Ports are already linked";
3604  return false;
3605  }
3606 
3607  Proc *proc = GuiContext::getCurrent()->getProc();
3608 
3609  string outNodePos = "";
3610  SubjectNode *sno = dynamic_cast<SubjectNode*>(subOutport->getParent());
3611  YASSERT(sno);
3612  Node *outNode = sno->getNode();
3613  outNodePos = proc->getChildName(outNode);
3614  string outportName = subOutport->getName();
3615 
3616  string inNodePos = "";
3617  SubjectNode *sni = dynamic_cast<SubjectNode*>(subInport->getParent());
3618  YASSERT(sni);
3619  Node *inNode = sni->getNode();
3620  inNodePos = proc->getChildName(inNode);
3621  string inportName = subInport->getName();
3622 
3623  CommandAddLink *command = new CommandAddLink(outNodePos, outportName, subOutport->getType(),
3624  inNodePos, inportName, subInport->getType(), control);
3625  if (command->execute())
3626  {
3627  GuiContext::getCurrent()->getInvoc()->add(command);
3628  return true;
3629  }
3630  else
3631  {
3632  delete command;
3633  return false;
3634  }
3635 }

Member Data Documentation

YACS::ENGINE::DataPort* YACS::HMI::SubjectDataPort::_dataPort
protected

Definition at line 221 of file guiObservers.hxx.

Referenced by getName(), getPort(), setName(), and ~SubjectDataPort().

std::string YACS::HMI::SubjectDataPort::_execValue
protected

Definition at line 223 of file guiObservers.hxx.

Referenced by getExecValue(), setExecValue(), and SubjectDataPort().

std::list<SubjectLink*> YACS::HMI::SubjectDataPort::_listSubjectLink
protected

Definition at line 222 of file guiObservers.hxx.

Referenced by SubjectDataPort().


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