Version: 9.12.0
YACS::ENGINE::InPort Class Reference

#include <InPort.hxx>

Inheritance diagram for YACS::ENGINE::InPort:
Collaboration diagram for YACS::ENGINE::InPort:

Public Member Functions

virtual InPortgetPublicRepresentant ()
 
virtual int edGetNumberOfLinks () const
 Returns number of physical backlinks NOT number of user backlinks. More...
 
virtual std::set< OutPort * > edSetOutPort () const
 Returns physical backlinks NOT user backlinks. More...
 
bool canSafelySqueezeMemory () const
 
bool isBackLinked () const
 
virtual ~InPort ()
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::DataPort
TypeCodeedGetType () const
 
void edSetType (TypeCode *type)
 
std::string getName () const
 
void setName (std::string theName)
 
std::string getNameOfTypeOfCurrentInstance () const
 
virtual TypeOfChannel getTypeOfChannel () const =0
 returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM. More...
 
bool isDifferentTypeOf (const DataPort *other) const
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
- Public Member Functions inherited from YACS::ENGINE::Port
virtual ~Port ()
 
NodegetNode () const
 
int getNumId () const
 
void modified ()
 

Protected Member Functions

 InPort (const InPort &other, Node *newHelder)
 
 InPort (const std::string &name, Node *node, TypeCode *type)
 
void edRemoveAllLinksLinkedWithMe ()
 
virtual void edNotifyReferencedBy (OutPort *fromPort, bool isLoopProof=true)
 
virtual void edNotifyDereferencedBy (OutPort *fromPort)
 
virtual void getAllRepresentants (std::set< InPort * > &repr) const
 
- Protected Member Functions inherited from YACS::ENGINE::DataPort
virtual ~DataPort ()
 
 DataPort (const DataPort &other, Node *newHelder)
 
 DataPort (const std::string &name, Node *node, TypeCode *type)
 
- Protected Member Functions inherited from YACS::ENGINE::Port
 Port (Node *node)
 
 Port (const Port &other, Node *newHelder)
 

Protected Attributes

std::set< std::pair< OutPort *, bool > > _backLinks
 
- Protected Attributes inherited from YACS::ENGINE::DataPort
TypeCode_type
 
std::string _name
 
- Protected Attributes inherited from YACS::ENGINE::Port
Node_node
 
int _id
 

Friends

class Loop
 
class OutPort
 
class ProxyPort
 
class OutputPort
 
class DynParaLoop
 
class ForEachLoop
 
class SplitterNode
 
class ComposedNode
 
class OptimizerLoop
 
class NbBranches
 
class ElementaryNode
 
class CollectorSwOutPort
 
class OutputDataStreamPort
 
class InterceptorInputPort
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::DataPort
static DataPortisCrossingType (const std::vector< DataPort * > &historyOfLink)
 
- Static Public Attributes inherited from YACS::ENGINE::DataPort
static const char NAME [] ="DataPort"
 
- Static Protected Attributes inherited from YACS::ENGINE::Port
static int _total = 0
 
static const char NAME [] ="Port"
 

Detailed Description

Definition at line 46 of file InPort.hxx.

Constructor & Destructor Documentation

◆ ~InPort()

InPort::~InPort ( )
virtual

Definition at line 40 of file InPort.cxx.

41 {
42 }

◆ InPort() [1/2]

InPort::InPort ( const InPort other,
Node newHelder 
)
protected

Definition at line 30 of file InPort.cxx.

30  :
31  DataPort(other,newHelder),Port(other,newHelder)
32 {
33 }
DataPort(const DataPort &other, Node *newHelder)
Definition: DataPort.cxx:41
Port(Node *node)
Definition: Port.cxx:34

◆ InPort() [2/2]

InPort::InPort ( const std::string &  name,
Node node,
TypeCode type 
)
protected

Definition at line 35 of file InPort.cxx.

35  :
36  DataPort(name,node,type),Port(node)
37 {
38 }

Member Function Documentation

◆ canSafelySqueezeMemory()

bool InPort::canSafelySqueezeMemory ( ) const

Definition at line 73 of file InPort.cxx.

74 {
75  if(!isBackLinked())
76  return false;
77  for(auto bl : _backLinks)
78  {
79  if(!bl.second)
80  return false;
81  }
82  return true;
83 }
bool isBackLinked() const
Definition: InPort.hxx:67
std::set< std::pair< OutPort *, bool > > _backLinks
Definition: InPort.hxx:78

References _backLinks, and isBackLinked().

Referenced by YACS::ENGINE::ForEachLoopGen::exUpdateState(), YACS::ENGINE::PythonNode::squeezeMemory(), and YACS::ENGINE::PythonNode::squeezeMemoryRemote().

◆ edGetNumberOfLinks()

int InPort::edGetNumberOfLinks ( ) const
virtual

◆ edNotifyDereferencedBy()

void InPort::edNotifyDereferencedBy ( OutPort fromPort)
protectedvirtual

Reimplemented in YACS::ENGINE::ProxyPort, and YACS::ENGINE::ConditionInputPort.

Definition at line 102 of file InPort.cxx.

103 {
104  auto it(std::find_if(_backLinks.begin(),_backLinks.end(),[fromPort](const std::pair<OutPort *,bool>& p){ return p.first==fromPort; }));
105  if(it!=_backLinks.end())
106  _backLinks.erase(it);
107  modified();
108 }
void modified()
Definition: Port.cxx:53
Proc * p
Definition: driver.cxx:216

References _backLinks, YACS::ENGINE::Port::modified(), and p.

Referenced by YACS::ENGINE::ConditionInputPort::edNotifyDereferencedBy(), YACS::ENGINE::ProxyPort::edNotifyDereferencedBy(), and YACS::ENGINE::ComposedNode::edRemoveLink().

◆ edNotifyReferencedBy()

void InPort::edNotifyReferencedBy ( OutPort fromPort,
bool  isLoopProof = true 
)
protectedvirtual
Parameters
[in]isLoopProof- Tells if the data coming from fromPort will be send again in case of this is initialized. This value is important if this is an InPort of a Node contained directly or not inside a Loop, ForEachLoop, OptimizerLoop. In this case, to optimize memory consumption (see squeezeMemory method), we need to know if data coming from fromPort will be generated again in case. If true (the default) it means that for that link is a link loop proof so no need to take care. If false, the link is not loop proof so event in the context of agressive memory management the data can't be safely released.

Reimplemented in YACS::ENGINE::ProxyPort, and YACS::ENGINE::ConditionInputPort.

Definition at line 93 of file InPort.cxx.

94 {
95  auto it(std::find_if(_backLinks.begin(),_backLinks.end(),[fromPort](const std::pair<OutPort *,bool>& p){ return p.first==fromPort; }));
96  if(it!=_backLinks.end())
97  _backLinks.erase(it);
98  _backLinks.insert(std::pair<OutPort *,bool>(fromPort,isLoopProof));
99  modified();
100 }

References _backLinks, YACS::ENGINE::Port::modified(), and p.

Referenced by YACS::ENGINE::ComposedNode::edAddLink(), YACS::ENGINE::ConditionInputPort::edNotifyReferencedBy(), YACS::ENGINE::ProxyPort::edNotifyReferencedBy(), YACS::ENGINE::DynParaLoop::prepareInputsFromOutOfScope(), and YACS::ENGINE::DynParaLoop::putValueOnBranch().

◆ edRemoveAllLinksLinkedWithMe()

void InPort::edRemoveAllLinksLinkedWithMe ( )
protectedvirtual

Implements YACS::ENGINE::DataPort.

Reimplemented in YACS::ENGINE::ProxyPort.

Definition at line 50 of file InPort.cxx.

51 {
52  set< std::pair<OutPort *,bool> > temp(_backLinks);//edRemoveLink called after causes invalidation of set iterator.
53  for(auto iter : temp)
54  {
55  set<OutPort *> trueBackOutputs;
56  iter.first->getAllRepresented(trueBackOutputs);
57  for( auto iter2 : trueBackOutputs )
58  _node->getRootNode()->edRemoveLink(iter2,this);
59  }
60  _backLinks.clear();
61  modified();
62 }
void edRemoveLink(OutPort *start, InPort *end)
Remove a dataflow link.
virtual ComposedNode * getRootNode() const
Definition: Node.cxx:430
Node * _node
Definition: Port.hxx:55

References _backLinks, YACS::ENGINE::Port::_node, YACS::ENGINE::ComposedNode::edRemoveLink(), YACS::ENGINE::Node::getRootNode(), and YACS::ENGINE::Port::modified().

Referenced by YACS::ENGINE::ProxyPort::edRemoveAllLinksLinkedWithMe(), and YACS::ENGINE::NbBranches::forceMultiplicity().

◆ edSetOutPort()

std::set< OutPort * > InPort::edSetOutPort ( ) const
virtual

Returns physical backlinks NOT user backlinks.

Reimplemented in YACS::ENGINE::ProxyPort.

Definition at line 65 of file InPort.cxx.

66 {
67  std::set<OutPort *> ret;
68  for( auto iter : _backLinks )
69  ret.insert(iter.first);
70  return ret;
71 }

References _backLinks.

Referenced by YACS::ENGINE::ProxyPort::edSetOutPort(), YACS::ENGINE::ElementaryNode::ensureLoading(), YACS::ENGINE::Switch::getAllInPortsComingFromOutsideOfCurrentScope(), YACS::ENGINE::OutputPort4DS2DF::getAllRepresented(), YACS::ENGINE::OptimizerLoop::initInterceptors(), and YACS::ENGINE::OptimizerLoop::OptimizerLoop().

◆ getAllRepresentants()

◆ getPublicRepresentant()

virtual InPort* YACS::ENGINE::InPort::getPublicRepresentant ( )
inlinevirtual

Reimplemented in YACS::ENGINE::ProxyPort, YACS::ENGINE::InputPort, and YACS::ENGINE::InPropertyPort.

Definition at line 63 of file InPort.hxx.

63 { return this; }

Referenced by YACS::ENGINE::OutputPort::isAlreadyLinkedWith().

◆ isBackLinked()

bool YACS::ENGINE::InPort::isBackLinked ( ) const
inline

Definition at line 67 of file InPort.hxx.

67 { return !_backLinks.empty(); }

Referenced by canSafelySqueezeMemory().

◆ typeName()

Friends And Related Function Documentation

◆ CollectorSwOutPort

friend class CollectorSwOutPort
friend

Definition at line 59 of file InPort.hxx.

◆ ComposedNode

friend class ComposedNode
friend

Definition at line 55 of file InPort.hxx.

◆ DynParaLoop

friend class DynParaLoop
friend

Definition at line 52 of file InPort.hxx.

◆ ElementaryNode

friend class ElementaryNode
friend

Definition at line 58 of file InPort.hxx.

◆ ForEachLoop

friend class ForEachLoop
friend

Definition at line 53 of file InPort.hxx.

◆ InterceptorInputPort

friend class InterceptorInputPort
friend

Definition at line 61 of file InPort.hxx.

Referenced by YACS::ENGINE::InterceptorInputPort::clone().

◆ Loop

friend class Loop
friend

Definition at line 48 of file InPort.hxx.

◆ NbBranches

friend class NbBranches
friend

Definition at line 57 of file InPort.hxx.

◆ OptimizerLoop

friend class OptimizerLoop
friend

Definition at line 56 of file InPort.hxx.

◆ OutPort

friend class OutPort
friend

Definition at line 49 of file InPort.hxx.

◆ OutputDataStreamPort

friend class OutputDataStreamPort
friend

Definition at line 60 of file InPort.hxx.

◆ OutputPort

friend class OutputPort
friend

Definition at line 51 of file InPort.hxx.

◆ ProxyPort

friend class ProxyPort
friend

Definition at line 50 of file InPort.hxx.

◆ SplitterNode

friend class SplitterNode
friend

Definition at line 54 of file InPort.hxx.

Member Data Documentation

◆ _backLinks


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