Version: 9.15.0
YACS::ENGINE::ForEachLoopPassedData Class Reference

#include <ForEachLoop.hxx>

Collaboration diagram for YACS::ENGINE::ForEachLoopPassedData:

Public Member Functions

 ForEachLoopPassedData (const std::vector< unsigned int > &passedIds, const std::vector< SequenceAny * > &passedOutputs, const std::vector< std::string > &nameOfOutputs)
 
 ForEachLoopPassedData (const ForEachLoopPassedData &copy)
 
 ~ForEachLoopPassedData ()
 
void init ()
 
void checkCompatibilyWithNb (int nbOfElts) const
 
void checkLevel2 (const std::vector< AnyInputPort * > &ports) const
 
int getNumberOfEltsAlreadyDone () const
 
int toAbsId (int localId) const
 
int toAbsIdNot (int localId) const
 
int getNumberOfElementsToDo () const
 
void assignAlreadyDone (const std::vector< SequenceAny * > &execVals) const
 
const std::vector< unsigned int > & getIds () const
 
const std::vector< SequenceAny * > & getOutputs () const
 
const std::vector< std::string > & getOutputNames () const
 

Private Attributes

std::vector< unsigned int > _passedIds
 
std::vector< SequenceAny * > _passedOutputs
 
std::vector< std::string > _nameOfOutputs
 
std::vector< bool > _flagsIds
 

Detailed Description

Definition at line 126 of file ForEachLoop.hxx.

Constructor & Destructor Documentation

◆ ForEachLoopPassedData() [1/2]

ForEachLoopPassedData::ForEachLoopPassedData ( const std::vector< unsigned int > &  passedIds,
const std::vector< SequenceAny * > &  passedOutputs,
const std::vector< std::string > &  nameOfOutputs 
)

Definition at line 306 of file ForEachLoop.cxx.

306  :_passedIds(passedIds),_passedOutputs(passedOutputs),_nameOfOutputs(nameOfOutputs)
307 {
308  std::size_t sz(_passedIds.size()),sz1(passedOutputs.size()),sz2(nameOfOutputs.size());
309  if(sz1!=sz2)
310  throw YACS::Exception("ForEachLoopPassedData::ForEachLoopPassedData : nameOfOutputs and passedOutputs must have the same size !");
311  for(std::vector<SequenceAny *>::iterator it=_passedOutputs.begin();it!=_passedOutputs.end();it++)
312  {
313  const SequenceAny *elt(*it);
314  if(elt)
315  if(sz!=(std::size_t)elt->size())
316  throw YACS::Exception("ForEachLoopPassedData::ForEachLoopPassedData : incoherent input of passed data !");
317  }
318  for(std::vector<SequenceAny *>::iterator it=_passedOutputs.begin();it!=_passedOutputs.end();it++)
319  {
320  SequenceAny *elt(*it);
321  if(elt)
322  elt->incrRef();
323  }
324 }
std::vector< SequenceAny * > _passedOutputs
std::vector< std::string > _nameOfOutputs
std::vector< unsigned int > _passedIds

References _passedIds, _passedOutputs, YACS::ENGINE::RefCounter::incrRef(), and YACS::ENGINE::SequenceAny::size().

◆ ForEachLoopPassedData() [2/2]

ForEachLoopPassedData::ForEachLoopPassedData ( const ForEachLoopPassedData copy)

Definition at line 326 of file ForEachLoop.cxx.

327 : _passedIds(copy._passedIds),
330  _flagsIds(copy._flagsIds)
331 {
332 }

◆ ~ForEachLoopPassedData()

ForEachLoopPassedData::~ForEachLoopPassedData ( )

Definition at line 334 of file ForEachLoop.cxx.

335 {
336  for(std::vector<SequenceAny *>::iterator it=_passedOutputs.begin();it!=_passedOutputs.end();it++)
337  {
338  SequenceAny *elt(*it);
339  if(elt)
340  elt->decrRef();
341  }
342 }

References _passedOutputs, and YACS::ENGINE::RefCounter::decrRef().

Member Function Documentation

◆ assignAlreadyDone()

void ForEachLoopPassedData::assignAlreadyDone ( const std::vector< SequenceAny * > &  execVals) const

Definition at line 448 of file ForEachLoop.cxx.

449 {
450  std::size_t sz(execVals.size());
451  if(_passedOutputs.size()!=sz)
452  throw YACS::Exception("ForEachLoopPassedData::assignedAlreadyDone : mismatch of size of vectors !");
453  for(std::size_t i=0;i<sz;i++)
454  {
456  SequenceAny *eltDestination(execVals[i]);
457  if(!elt)
458  throw YACS::Exception("ForEachLoopPassedData::assignedAlreadyDone : presence of null elt !");
459  unsigned int szOfElt(elt->size());
460  for(unsigned int j=0;j<szOfElt;j++)
461  {
462  AnyPtr elt1((*elt)[j]);
463  int jAbs(toAbsIdNot(j));
464  eltDestination->setEltAtRank(jAbs,elt1);
465  }
466  }
467 }
: Allow to manage memory of instances of T. The only constraint on T is to have method incrRef and De...
Definition: SharedPtr.hxx:30
int toAbsIdNot(int localId) const

References _passedOutputs, yacsorb.CORBAEngineTest::i, YACS::ENGINE::SequenceAny::setEltAtRank(), YACS::ENGINE::SequenceAny::size(), and toAbsIdNot().

Referenced by YACS::ENGINE::ForEachLoopGen::exUpdateState().

◆ checkCompatibilyWithNb()

void ForEachLoopPassedData::checkCompatibilyWithNb ( int  nbOfElts) const

Definition at line 349 of file ForEachLoop.cxx.

350 {
351  if(nbOfElts<0)
352  throw YACS::Exception("ForEachLoopPassedData::checkCompatibilyWithNb : nb of elts is expected to be > 0 !");
353  std::size_t sizeExp(_passedIds.size()),nbOfElts2(nbOfElts);
354  if(nbOfElts2<sizeExp)
355  throw YACS::Exception("ForEachLoopPassedData::checkCompatibilyWithNb : Invalid nb of elemts in input seq regarding passed data set !");
356  for(std::vector<unsigned int>::const_iterator it=_passedIds.begin();it!=_passedIds.end();it++)
357  {
358  if((*it)>=nbOfElts2)
359  throw YACS::Exception("ForEachLoopPassedData::checkCompatibilyWithNb : Invalid nb of elemts in input seq regarding passed data set 2 !");
360  }
361  _flagsIds.resize(nbOfElts);
362  std::fill(_flagsIds.begin(),_flagsIds.end(),false);
363  for(std::vector<unsigned int>::const_iterator it=_passedIds.begin();it!=_passedIds.end();it++)
364  {
365  if(*it<nbOfElts)
366  {
367  if(!_flagsIds[*it])
368  _flagsIds[*it]=true;
369  else
370  {
371  std::ostringstream oss; oss << "ForEachLoopPassedData::checkCompatibilyWithNb : id " << *it << " in list of ids appears more than once !";
372  throw YACS::Exception(oss.str());
373  }
374  }
375  else
376  {
377  std::ostringstream oss; oss << "ForEachLoopPassedData::checkCompatibilyWithNb : Presence of id " << *it << " in list of ids ! Must be in [0," << nbOfElts << ") !";
378  throw YACS::Exception(oss.str());
379  }
380  }
381 }

References _flagsIds, and _passedIds.

Referenced by YACS::ENGINE::ForEachLoopGen::exUpdateState().

◆ checkLevel2()

void ForEachLoopPassedData::checkLevel2 ( const std::vector< AnyInputPort * > &  ports) const

Definition at line 383 of file ForEachLoop.cxx.

384 {
385  std::size_t sz(_nameOfOutputs.size());
386  if(sz!=ports.size())
387  throw YACS::Exception("ForEachLoopPassedData::checkLevel2 : mismatch of size of vectors !");
388  for(std::size_t i=0;i<sz;i++)
389  {
390  AnyInputPort *elt(ports[i]);
391  if(!elt)
392  throw YACS::Exception("ForEachLoopPassedData::checkLevel2 : presence of null instance !");
393  if(_nameOfOutputs[i]!=elt->getName())
394  {
395  std::ostringstream oss; oss << "ForEachLoopPassedData::checkLevel2 : At pos #" << i << " the name is not OK !";
396  throw YACS::Exception(oss.str());
397  }
398  }
399 }

References _nameOfOutputs, YACS::ENGINE::DataPort::getName(), and yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::ForEachLoopGen::exUpdateState().

◆ getIds()

const std::vector<unsigned int>& YACS::ENGINE::ForEachLoopPassedData::getIds ( ) const
inline

Definition at line 140 of file ForEachLoop.hxx.

140 {return _passedIds;}

Referenced by YACS::ENGINE::VisitorSalomeSaveState::visitForEachLoop().

◆ getNumberOfElementsToDo()

int ForEachLoopPassedData::getNumberOfElementsToDo ( ) const

Definition at line 441 of file ForEachLoop.cxx.

442 {
443  std::size_t nbAllElts(_flagsIds.size());
444  std::size_t ret(nbAllElts-_passedIds.size());
445  return ret;
446 }

References _flagsIds, and _passedIds.

Referenced by YACS::ENGINE::ForEachLoopGen::getFinishedId().

◆ getNumberOfEltsAlreadyDone()

int YACS::ENGINE::ForEachLoopPassedData::getNumberOfEltsAlreadyDone ( ) const
inline

Definition at line 135 of file ForEachLoop.hxx.

135 { return (int)_passedIds.size(); }

Referenced by YACS::ENGINE::ForEachLoopGen::exUpdateState().

◆ getOutputNames()

const std::vector<std::string>& YACS::ENGINE::ForEachLoopPassedData::getOutputNames ( ) const
inline

Definition at line 142 of file ForEachLoop.hxx.

142 {return _nameOfOutputs;}

Referenced by YACS::ENGINE::VisitorSalomeSaveState::visitForEachLoop().

◆ getOutputs()

const std::vector<SequenceAny *>& YACS::ENGINE::ForEachLoopPassedData::getOutputs ( ) const
inline

Definition at line 141 of file ForEachLoop.hxx.

141 {return _passedOutputs;}

Referenced by YACS::ENGINE::VisitorSalomeSaveState::visitForEachLoop().

◆ init()

void ForEachLoopPassedData::init ( )

Definition at line 344 of file ForEachLoop.cxx.

345 {
346  _flagsIds.clear();
347 }

References _flagsIds.

Referenced by YACS::ENGINE::ForEachLoopGen::init().

◆ toAbsId()

int ForEachLoopPassedData::toAbsId ( int  localId) const

performs local to abs id. Input localId refers to an id in all jobs to perform. Returned id refers to pos in whole output sequences.

Definition at line 404 of file ForEachLoop.cxx.

405 {
406  if(localId<0)
407  throw YACS::Exception("ForEachLoopPassedData::toAbsId : local pos must be >= 0 !");
408  int ret(0),curLocId(0);
409  for(std::vector<bool>::const_iterator it=_flagsIds.begin();it!=_flagsIds.end();it++,ret++)
410  {
411  if(!*it)
412  {
413  if(localId==curLocId)
414  return ret;
415  curLocId++;
416  }
417  }
418  throw YACS::Exception("ForEachLoopPassedData::toAbsId : not referenced Id !");
419 }

References _flagsIds.

Referenced by YACS::ENGINE::ForEachLoopGen::exUpdateState(), and YACS::ENGINE::ForEachLoopGen::updateStateForWorkNodeOnFinishedEventFrom().

◆ toAbsIdNot()

int ForEachLoopPassedData::toAbsIdNot ( int  localId) const

Equivalent to toAbsId except that only ON are considered here.

Definition at line 424 of file ForEachLoop.cxx.

425 {
426  if(localId<0)
427  throw YACS::Exception("ForEachLoopPassedData::toAbsIdNot : local pos must be >= 0 !");
428  int ret(0),curLocId(0);
429  for(std::vector<bool>::const_iterator it=_flagsIds.begin();it!=_flagsIds.end();it++,ret++)
430  {
431  if(*it)//<- diff is here !
432  {
433  if(localId==curLocId)
434  return ret;
435  curLocId++;
436  }
437  }
438  throw YACS::Exception("ForEachLoopPassedData::toAbsIdNot : not referenced Id !");
439 }

References _flagsIds.

Referenced by assignAlreadyDone().

Member Data Documentation

◆ _flagsIds

std::vector<bool> YACS::ENGINE::ForEachLoopPassedData::_flagsIds
mutableprivate

◆ _nameOfOutputs

std::vector<std::string> YACS::ENGINE::ForEachLoopPassedData::_nameOfOutputs
private

Definition at line 147 of file ForEachLoop.hxx.

Referenced by checkLevel2().

◆ _passedIds

std::vector<unsigned int> YACS::ENGINE::ForEachLoopPassedData::_passedIds
private

◆ _passedOutputs

std::vector<SequenceAny *> YACS::ENGINE::ForEachLoopPassedData::_passedOutputs
private

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