Version: 8.3.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 ~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)
 
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 ()
 

Private Member Functions

int edGetNumberOfOutLinks () const
 
std::set< InPort * > edSetInPort () const
 
bool isAlreadyLinkedWith (InPort *withp) const
 
std::string getNameOfTypeOfCurrentInstance () const
 
void edRemoveAllLinksLinkedWithMe () throw (Exception)
 
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) throw (Exception)
 
int removeInPort (InPort *inPort, bool forward) throw (Exception)
 
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) throw (Exception)
 

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 Attributes inherited from YACS::ENGINE::DataPort
TypeCode_type
 
std::string _name
 
- 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::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 111 of file Switch.cxx.

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

111  :OutPort("",master,port->edGetType()),
112  DataPort("",master,port->edGetType()),
113  Port(master),
114  _consumer(port),_currentProducer(0)
115 {
116  _name="Representant_of_"; _name+=master->getName(); _name+="_for_inport_"; _name+=master->getRootNode()->getInPortName(_consumer);
117 }
CollectorSwOutPort::CollectorSwOutPort ( const CollectorSwOutPort other,
Switch master 
)
private

Definition at line 119 of file Switch.cxx.

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

119  :OutPort("",master,other.edGetType()),
120  DataPort("",master,other.edGetType()),
121  Port(master),
123 {
124  _name=other._name;
125  Switch *othSw=(Switch *)other._node;
126  for(map<int, OutPort *>::const_iterator iter=other._potentialProducers.begin();iter!=other._potentialProducers.end();iter++)
127  {
128  string name=othSw->getOutPortName((*iter).second);
129  _potentialProducers[(*iter).first]=master->getOutPort(name);
130  }
131 }

Member Function Documentation

bool CollectorSwOutPort::addInPort ( InPort inPort) throw (Exception)
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 83 of file Switch.cxx.

References PMMLBasicsTestLauncher::ret.

84 {
86  {//a specific link is beeing done
87  bool ret=_currentProducer->addInPort(inPort);
89  return ret;
90  }
91  else//global links asked
92  for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
93  (*iter).second->addInPort(inPort);
94 }
void CollectorSwOutPort::addPotentialProducerForMaster ( OutPort port)
private

Definition at line 133 of file Switch.cxx.

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 CORBAEngineTest::i.

134 {
135  int i=((Switch *)_node)->getRankOfNode(port->getNode());
136  map<int, OutPort *>::iterator pt=_potentialProducers.find(i);
137  if(pt==_potentialProducers.end())
138  {
139  _potentialProducers[i]=port;
140  _currentProducer=port;
141  }
142  else
143  {
144  _currentProducer=(*pt).second;
145  if(_currentProducer!=port)
146  {
147  string what("CollectorSwOutPort::addPotentialProducerForMaster : In switch node "); what+=_node->getName();
148  what+=" for input named \'"; what+=_consumer->getName(); what+="\' the output "; what+=_currentProducer->getName();
149  what+=" already got out for case of label ";
150  what+=Switch::getRepresentationOfCase((*pt).first);
151  throw Exception(what);
152  }
153  }
155 }
void CollectorSwOutPort::checkConsistency ( LinkInfo info) const
privatevirtual

Called by Switch::checkCFLinks.

Reimplemented from YACS::ENGINE::OutPort.

Definition at line 197 of file Switch.cxx.

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

198 {
199  if(((Switch *)_node)->getNbOfCases()!=_potentialProducers.size())
200  info.pushErrSwitch((CollectorSwOutPort *)this);
201  for(map<int, OutPort *>::const_iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
202  (*iter).second->checkConsistency(info);
203 }
bool CollectorSwOutPort::checkManagementOfPort ( OutPort port) throw (Exception)
private

Definition at line 183 of file Switch.cxx.

184 {
185  for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
186  if((*iter).second==port)
187  {
188  _currentProducer=port;
189  return _potentialProducers.size()==1;
190  }
191  throw Exception("CollectorSwOutPort::checkManagementOfPort : unexported port");
192 }
int CollectorSwOutPort::edGetNumberOfOutLinks ( ) const
privatevirtual

Reimplemented from YACS::ENGINE::OutPort.

Definition at line 38 of file Switch.cxx.

39 {
40  return 1;
41 }
void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe ( ) throw (Exception)
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 }
std::set< InPort * > CollectorSwOutPort::edSetInPort ( ) const
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 43 of file Switch.cxx.

References PMMLBasicsTestLauncher::ret.

44 {
45  set<InPort *> ret;
46  if(_consumer)
47  ret.insert(_consumer);
48  return ret;
49 }
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 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 209 of file Switch.cxx.

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

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

Reimplemented from YACS::ENGINE::DataPort.

Definition at line 58 of file Switch.cxx.

59 {
60  return _className;
61 }
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 }
bool CollectorSwOutPort::isAlreadyLinkedWith ( InPort withp) const
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 51 of file Switch.cxx.

References YACS::ENGINE::InPort::getAllRepresentants().

52 {
53  set<InPort *> s;
54  with->getAllRepresentants(s);
55  return s.find(_consumer)!=s.end();
56 }
int CollectorSwOutPort::removeInPort ( InPort inPort,
bool  forward 
) throw (Exception)
privatevirtual

Implements YACS::ENGINE::OutPort.

Definition at line 96 of file Switch.cxx.

97 {
99  {
100  return _currentProducer->removeInPort(inPort,forward);
101  }
102  else
103  throw Exception("CollectorSwOutputPort::edRemoveInputPort : internal error on link removal.");
105 }
bool CollectorSwOutPort::removePotentialProducerForMaster ( )
private

Definition at line 157 of file Switch.cxx.

References _currentProducer, _potentialProducers, and CORBAEngineTest::i.

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

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

Friends And Related Function Documentation

friend class Switch
friend

Definition at line 39 of file Switch.hxx.

Member Data Documentation

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

Definition at line 61 of file Switch.hxx.

Referenced by addPotentialProducerForMaster().

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

Definition at line 62 of file Switch.hxx.

Referenced by addPotentialProducerForMaster(), and removePotentialProducerForMaster().

std::map<int, OutPort *> YACS::ENGINE::CollectorSwOutPort::_potentialProducers
private

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