Version: 9.16.0
YACS::ENGINE::CollectorSwOutPort Class Reference

#include <Switch.hxx>

Inheritance diagram for YACS::ENGINE::CollectorSwOutPort:
Collaboration diagram for YACS::ENGINE::CollectorSwOutPort:

Public Member Functions

void getHumanReprOfIncompleteCases (std::ostream &stream) const
 
- Public Member Functions inherited from YACS::ENGINE::OutPort
virtual void checkConsistency (LinkInfo &info) const
 
virtual int edGetNumberOfOutLinks () const
 
virtual std::set< InPort * > edSetInPort () const =0
 
virtual bool isAlreadyLinkedWith (InPort *withp) const =0
 
virtual void getAllRepresented (std::set< OutPort * > &represented) const
 
virtual bool addInPort (InPort *inPort)=0
 
virtual int removeInPort (InPort *inPort, bool forward)=0
 
virtual ~OutPort ()
 
std::vector< DataPort * > calculateHistoryOfLinkWith (InPort *end)
 
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 void edRemoveAllLinksLinkedWithMe ()=0
 
virtual std::string typeName ()
 
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
 
virtual std::string getNameOfTypeOfCurrentInstance () const
 
int getNumId () const
 
virtual std::string typeName ()
 
void modified ()
 

Private Member Functions

int edGetNumberOfOutLinks () const
 
std::set< InPort * > edSetInPort () const
 
bool isAlreadyLinkedWith (InPort *withp) const
 
std::string getNameOfTypeOfCurrentInstance () const
 
void edRemoveAllLinksLinkedWithMe ()
 
TypeOfChannel getTypeOfChannel () const
 returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM. More...
 
void getAllRepresented (std::set< OutPort * > &represented) const
 
bool addInPort (InPort *inPort)
 
int removeInPort (InPort *inPort, bool forward)
 
bool removePotentialProducerForMaster ()
 
void checkConsistency (LinkInfo &info) const
 
 CollectorSwOutPort (Switch *master, InPort *port)
 
 CollectorSwOutPort (const CollectorSwOutPort &other, Switch *master)
 
void addPotentialProducerForMaster (OutPort *port)
 
bool checkManagementOfPort (OutPort *port)
 

Private Attributes

InPort_consumer
 
std::string _className
 
OutPort_currentProducer
 
std::map< int, OutPort * > _potentialProducers
 

Friends

class Switch
 

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"
 
- Protected Member Functions inherited from YACS::ENGINE::OutPort
 OutPort (const OutPort &other, Node *newHelder)
 
 OutPort (const std::string &name, Node *node, TypeCode *type)
 
- 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 inherited from YACS::ENGINE::DataPort
TypeCode_type
 
std::string _name
 
- Protected Attributes inherited from YACS::ENGINE::Port
Node_node
 
int _id
 
- Static Protected Attributes inherited from YACS::ENGINE::Port
static int _total = 0
 
static const char NAME [] ="Port"
 

Detailed Description

Definition at line 37 of file Switch.hxx.

Constructor & Destructor Documentation

◆ CollectorSwOutPort() [1/2]

CollectorSwOutPort::CollectorSwOutPort ( Switch master,
InPort port 
)
private
Note
: 'master' specifies the instance of Switch of which 'this' collects all of these direct or indirect outports going to the same port 'port' (which is out of scope of 'master').

Definition at line 112 of file Switch.cxx.

112 :OutPort("",master,port->edGetType()),
113 DataPort("",master,port->edGetType()),
114 Port(master),
116{
117 _name="Representant_of_";
118 _name+=master->getName();
119 _name+="_for_inport_";
120 _name+=port->getName();
121}
std::string getName() const
TypeCode * edGetType() const
Definition: DataPort.hxx:53
DataPort(const DataPort &other, Node *newHelder)
Definition: DataPort.cxx:41
std::string getName() const
Definition: DataPort.hxx:55
OutPort(const OutPort &other, Node *newHelder)
Definition: OutPort.cxx:29
Port(Node *node)
Definition: Port.cxx:34

References YACS::ENGINE::DataPort::_name, YACS::ENGINE::ComposedNode::getName(), and YACS::ENGINE::DataPort::getName().

◆ CollectorSwOutPort() [2/2]

CollectorSwOutPort::CollectorSwOutPort ( const CollectorSwOutPort other,
Switch master 
)
private

Definition at line 123 of file Switch.cxx.

123 :OutPort("",master,other.edGetType()),
124 DataPort("",master,other.edGetType()),
125 Port(master),
127{
128 _name=other._name;
129 Switch *othSw=(Switch *)other._node;
130 for(map<int, OutPort *>::const_iterator iter=other._potentialProducers.begin();iter!=other._potentialProducers.end();iter++)
131 {
132 string name=othSw->getOutPortName((*iter).second);
133 _potentialProducers[(*iter).first]=master->getOutPort(name);
134 }
135}
std::map< int, OutPort * > _potentialProducers
Definition: Switch.hxx:63
std::string getOutPortName(const OutPort *) const
Node * _node
Definition: Port.hxx:55
Control node that emulates the C switch.
Definition: Switch.hxx:85
OutPort * getOutPort(const std::string &name) const
Definition: Switch.cxx:459

References YACS::ENGINE::DataPort::_name, YACS::ENGINE::Port::_node, _potentialProducers, YACS::ENGINE::Switch::getOutPort(), and YACS::ENGINE::ComposedNode::getOutPortName().

Member Function Documentation

◆ addInPort()

bool CollectorSwOutPort::addInPort ( InPort inPort)
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 83 of file Switch.cxx.

84{
85 bool ret = false;
87 {//a specific link is beeing done
88 ret=_currentProducer->addInPort(inPort);
90 }
91 else//global links asked
92 for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
93 ret |= (*iter).second->addInPort(inPort);
94 return ret;
95}
virtual bool addInPort(InPort *inPort)=0

References _currentProducer, _potentialProducers, and YACS::ENGINE::OutPort::addInPort().

◆ addPotentialProducerForMaster()

void CollectorSwOutPort::addPotentialProducerForMaster ( OutPort port)
private

Definition at line 137 of file Switch.cxx.

138{
139 int i=((Switch *)_node)->getRankOfNode(port->getNode());
140 map<int, OutPort *>::iterator pt=_potentialProducers.find(i);
141 if(pt==_potentialProducers.end())
142 {
144 _currentProducer=port;
145 }
146 else
147 {
148 _currentProducer=(*pt).second;
149 if(_currentProducer!=port)
150 {
151 string what("CollectorSwOutPort::addPotentialProducerForMaster : In switch node "); what+=_node->getName();
152 what+=" for input named \'"; what+=_consumer->getName(); what+="\' the output "; what+=_currentProducer->getName();
153 what+=" already got out for case of label ";
154 what+=Switch::getRepresentationOfCase((*pt).first);
155 throw Exception(what);
156 }
157 }
159}
std::string getNameOfTypeOfCurrentInstance() const
Definition: DataPort.cxx:56
const std::string & getName() const
Definition: Node.hxx:125
Node * getNode() const
Definition: Port.hxx:46
static std::string getRepresentationOfCase(int i)
Definition: Switch.cxx:761

References _className, _consumer, _currentProducer, YACS::ENGINE::Port::_node, _potentialProducers, YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::DataPort::getNameOfTypeOfCurrentInstance(), YACS::ENGINE::Port::getNode(), YACS::ENGINE::Switch::getRepresentationOfCase(), and yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::Switch::buildDelegateOf().

◆ checkConsistency()

void CollectorSwOutPort::checkConsistency ( LinkInfo info) const
privatevirtual

Called by Switch::checkCFLinks.

Reimplemented from YACS::ENGINE::OutPort.

Definition at line 201 of file Switch.cxx.

202{
203 if(((Switch *)_node)->getNbOfCases()!=_potentialProducers.size())
204 info.pushErrSwitch((CollectorSwOutPort *)this);
205 for(map<int, OutPort *>::const_iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
206 (*iter).second->checkConsistency(info);
207}
void pushErrSwitch(CollectorSwOutPort *collector)
Definition: LinkInfo.cxx:99

References YACS::ENGINE::Port::_node, _potentialProducers, and YACS::ENGINE::LinkInfo::pushErrSwitch().

◆ checkManagementOfPort()

bool CollectorSwOutPort::checkManagementOfPort ( OutPort port)
private

Definition at line 187 of file Switch.cxx.

188{
189 for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
190 if((*iter).second==port)
191 {
192 _currentProducer=port;
193 return _potentialProducers.size()==1;
194 }
195 throw Exception("CollectorSwOutPort::checkManagementOfPort : unexported port");
196}

References _currentProducer, and _potentialProducers.

◆ edGetNumberOfOutLinks()

int CollectorSwOutPort::edGetNumberOfOutLinks ( ) const
privatevirtual

Reimplemented from YACS::ENGINE::OutPort.

Definition at line 38 of file Switch.cxx.

39{
40 return 1;
41}

◆ edRemoveAllLinksLinkedWithMe()

void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe ( )
privatevirtual

Implements YACS::ENGINE::DataPort.

Definition at line 63 of file Switch.cxx.

64{
65 map<int, OutPort *>::iterator pt;
66 if(_consumer)
67 for(pt=_potentialProducers.begin();pt!=_potentialProducers.end();pt++)
68 ((*pt).second)->removeInPort(_consumer,true);
69}
int removeInPort(InPort *inPort, bool forward)
Definition: Switch.cxx:97

References _consumer, _potentialProducers, and removeInPort().

◆ edSetInPort()

std::set< InPort * > CollectorSwOutPort::edSetInPort ( ) const
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 43 of file Switch.cxx.

44{
45 set<InPort *> ret;
46 if(_consumer)
47 ret.insert(_consumer);
48 return ret;
49}

References _consumer.

◆ getAllRepresented()

void CollectorSwOutPort::getAllRepresented ( std::set< OutPort * > &  represented) const
privatevirtual

Reimplemented from YACS::ENGINE::OutPort.

Definition at line 76 of file Switch.cxx.

77{
78 map<int, OutPort *>::const_iterator pt;
79 for(pt=_potentialProducers.begin();pt!=_potentialProducers.end();pt++)
80 ((*pt).second)->getAllRepresented(represented);
81}
void getAllRepresented(std::set< OutPort * > &represented) const
Definition: Switch.cxx:76

References _potentialProducers, and getAllRepresented().

Referenced by getAllRepresented().

◆ getHumanReprOfIncompleteCases()

void CollectorSwOutPort::getHumanReprOfIncompleteCases ( std::ostream &  stream) const

Called by LinkInfo::getErrRepr to have a comprehensible message on throw. When called, typically checkCompletenessOfCases has detected that some potential producers were laking...

Definition at line 213 of file Switch.cxx.

214{
215 set<int> lackingCases;
216 for(map< int ,Node * >::const_iterator iter=((Switch *)_node)->_mapOfNode.begin();iter!=((Switch *)_node)->_mapOfNode.end();iter++)
217 {
218 if(_potentialProducers.find((*iter).first)==_potentialProducers.end())
219 lackingCases.insert((*iter).first);
220 }
221 ostringstream streamForExc;
222 stream << "For link to " << _consumer->getName() << " of node " << _consumer->getNode()->getName()
223 << " the cases of switch node named " << _node->getName()
224 << " do not define links for following cases ids :";
225 for(set<int>::iterator iter=lackingCases.begin();iter!=lackingCases.end();iter++)
226 stream << Switch::getRepresentationOfCase(*iter) << " ";
227 stream << endl;
228}

References _consumer, YACS::ENGINE::Port::_node, _potentialProducers, YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::Port::getNode(), and YACS::ENGINE::Switch::getRepresentationOfCase().

◆ getNameOfTypeOfCurrentInstance()

std::string CollectorSwOutPort::getNameOfTypeOfCurrentInstance ( ) const
privatevirtual

Reimplemented from YACS::ENGINE::DataPort.

Definition at line 58 of file Switch.cxx.

59{
60 return _className;
61}

References _className.

◆ getTypeOfChannel()

TypeOfChannel CollectorSwOutPort::getTypeOfChannel ( ) const
privatevirtual

returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM.

Implements YACS::ENGINE::DataPort.

Definition at line 71 of file Switch.cxx.

72{
73 return (*(_potentialProducers.begin())).second->getTypeOfChannel();
74}

References _potentialProducers.

◆ isAlreadyLinkedWith()

bool CollectorSwOutPort::isAlreadyLinkedWith ( InPort withp) const
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 51 of file Switch.cxx.

52{
53 set<InPort *> s;
54 with->getAllRepresentants(s);
55 return s.find(_consumer)!=s.end();
56}

References _consumer, and YACS::ENGINE::InPort::getAllRepresentants().

◆ removeInPort()

int CollectorSwOutPort::removeInPort ( InPort inPort,
bool  forward 
)
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 97 of file Switch.cxx.

98{
100 {
101 return _currentProducer->removeInPort(inPort,forward);
102 }
103 else
104 throw Exception("CollectorSwOutputPort::edRemoveInputPort : internal error on link removal.");
106}
virtual int removeInPort(InPort *inPort, bool forward)=0

References _currentProducer, and YACS::ENGINE::OutPort::removeInPort().

Referenced by edRemoveAllLinksLinkedWithMe().

◆ removePotentialProducerForMaster()

bool CollectorSwOutPort::removePotentialProducerForMaster ( )
private

Definition at line 161 of file Switch.cxx.

162{
163 int i;
164 map<int, OutPort *>::iterator result;
165 for(result=_potentialProducers.begin();result!=_potentialProducers.end();result++)
166 if((*result).second==_currentProducer)
167 {
168 i=(*result).first;
169 break;
170 }
171 if(result==_potentialProducers.end())
172 {
173 ostringstream stream; stream << "CollectorSwOutPort::removePotentialProducerForMaster : link from the branch whith id ";
174 stream << i << " not defined";
175 throw Exception(stream.str());
176 }
177 if((*result).second!=_currentProducer)
178 {
179 ostringstream stream; stream << "CollectorSwOutPort::removePotentialProducerForMaster : link from the branch whith id ";
180 stream << i << " defined but the output specified is not compatible";
181 throw Exception(stream.str());
182 }
183 _potentialProducers.erase(result);
184 return _potentialProducers.empty();
185}

References _currentProducer, _potentialProducers, and yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::Switch::releaseDelegateOf().

Friends And Related Function Documentation

◆ Switch

friend class Switch
friend

Definition at line 39 of file Switch.hxx.

Member Data Documentation

◆ _className

std::string YACS::ENGINE::CollectorSwOutPort::_className
private

Definition at line 61 of file Switch.hxx.

Referenced by addPotentialProducerForMaster(), and getNameOfTypeOfCurrentInstance().

◆ _consumer

InPort* YACS::ENGINE::CollectorSwOutPort::_consumer
private

◆ _currentProducer

OutPort* YACS::ENGINE::CollectorSwOutPort::_currentProducer
private

◆ _potentialProducers


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