Version: 9.15.0
YACS::ENGINE::BagPoint Class Reference

#include <BagPoint.hxx>

Inheritance diagram for YACS::ENGINE::BagPoint:
Collaboration diagram for YACS::ENGINE::BagPoint:

Public Member Functions

 BagPoint ()=default
 
 BagPoint (const std::list< AbstractPoint * > &nodes, AbstractPoint *father)
 
AbstractPointdeepCopy (AbstractPoint *father) const override
 
NodegetFirstNode () override
 
NodegetLastNode () override
 
int getMaxLevelOfParallelism () const
 
void getWeightRegardingDPL (ComplexWeight *weight)
 
void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap) const
 
std::string getRepr () const
 
void accept (PointVisitor *pv) override
 
AbstractPointexpandNonSimpleCaseOn (NotSimpleCasePoint *pathologicalPt, const std::set< Node * > &uncatchedNodes) override
 
int size () const
 
void replaceInMe (BlocPoint *aSet)
 
void deal1 (bool &somethingDone)
 
void deal2 (bool &somethingDone)
 
void deal2Bis (bool &somethingDone)
 
void deal2Ter (bool &somethingDone)
 
void deal2Quatro (bool &somethingDone)
 
void dealNotSimpleCase (bool &somethingDone)
 
void expandNonSimpleCase ()
 
- Public Member Functions inherited from YACS::ENGINE::BlocPoint
 BlocPoint ()=default
 
 BlocPoint (const std::list< AbstractPoint * > &nodes, AbstractPoint *father)
 
void deepCopyFrom (const BlocPoint &other)
 
AbstractPointfindPointWithNode (Node *node)
 
AbstractPointgetNodeAfter (Node *node)
 
AbstractPointgetNodeB4 (Node *node)
 
bool contains (Node *node) const override
 
bool anyOf (const std::set< Node * > &nodes) const override
 
int getNumberOfNodes () const
 
const std::list< AbstractPoint * > & getListOfPoints () const
 
virtual ~BlocPoint ()
 
bool internalContinueForSimplify () const
 
bool presenceOfNonSimpleCase () const
 
AbstractPointgetUnique ()
 
const AbstractPointgetUnique () const
 
AbstractPointgetUniqueAndReleaseIt ()
 
- Public Member Functions inherited from YACS::ENGINE::AbstractPoint
 AbstractPoint ()=default
 
 AbstractPoint (AbstractPoint *father)
 
AbstractPointgetFather () const
 
AbstractPointgetGodFather ()
 
bool amIGod ()
 
void setFather (AbstractPoint *father)
 
bool isBegin ()
 
bool isLast ()
 
bool isSimplyLinkedBeforeAfter (BlocPoint *sop)
 
bool isSimplyLinkedAfterNullBefore (BlocPoint *sop)
 
bool isSimplyLinkedBeforeNullAfter (BlocPoint *sop)
 
bool isNullBeforeNullAfter (BlocPoint *sop)
 
LinkedBlocPointtryAsLink (BlocPoint *sop)
 
ForkBlocPointtryAsFork (BlocPoint *sop)
 
ForkBlocPointtryAsForkBis (BlocPoint *sop)
 
ForkBlocPointtryAsForkTer (BlocPoint *sop)
 
ForkBlocPointtryAsForkQuatro (BlocPoint *sop)
 
virtual ~AbstractPoint ()
 
bool isSimplyLinkedAfter (BlocPoint *sop, Node *node)
 
bool isSimplyLinkedBefore (BlocPoint *sop, Node *node)
 

Private Member Functions

void expandNonSimpleCaseOn (AbstractPoint *pathologicalPt)
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::AbstractPoint
static void TryAsNotSimpleCase (AbstractPoint *father, const std::vector< AbstractPoint * > &ptsToKill, std::list< AbstractPoint * > &nodes, bool &somethingDone)
 
static bool IsGatherB4Ext (Node *node)
 
static bool IsSimplyLinkedAfterExt (Node *node)
 
static bool IsScatterAfterExt (Node *node)
 
static bool IsSimplyLinkedBeforeExt (Node *node)
 
static bool IsNoLinksBefore (Node *node)
 
static bool IsNoLinksAfter (Node *node)
 
static NodeGetNodeB4 (Node *node)
 
static NodeGetNodeAfter (Node *node)
 
static AbstractPointGetDirectSonOf (AbstractPoint *refFather, AbstractPoint *sonOrLittleSon)
 
static bool IsCommonDirectSonOf (AbstractPoint *refFather, const std::list< OutGate * > &outgs, AbstractPoint *&ret)
 
static bool IsCommonDirectSonOf (AbstractPoint *refFather, const std::list< InGate * > &ings, AbstractPoint *&ret)
 
static void FeedData (AbstractPoint *ptToBeRewired, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr< Bloc > > > *m)
 
static void FeedData (const std::list< AbstractPoint * > &ptsToBeRewired, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr< Bloc > > > *m)
 
static void Rewire (const std::vector< AbstractPoint * > &ptsToKill, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr< Bloc > > > *m)
 
static void UnRewire (std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr< Bloc > > > &m)
 
static void Display (std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr< Bloc > > > *m)
 
- Protected Member Functions inherited from YACS::ENGINE::BlocPoint
void getOutPoint (AbstractPoint *node)
 
- Protected Attributes inherited from YACS::ENGINE::BlocPoint
std::list< AbstractPoint * > _nodes
 
- Protected Attributes inherited from YACS::ENGINE::AbstractPoint
AbstractPoint_father = nullptr
 

Detailed Description

Definition at line 32 of file BagPoint.hxx.

Constructor & Destructor Documentation

◆ BagPoint() [1/2]

YACS::ENGINE::BagPoint::BagPoint ( )
default

◆ BagPoint() [2/2]

BagPoint::BagPoint ( const std::list< AbstractPoint * > &  nodes,
AbstractPoint father 
)

Definition at line 34 of file BagPoint.cxx.

34  :BlocPoint(nodes,father)
35 {
36 }

Member Function Documentation

◆ accept()

void BagPoint::accept ( PointVisitor pv)
overridevirtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 38 of file BagPoint.cxx.

39 {
40  for(auto it : _nodes)
41  {
42  if(!it)
43  throw YACS::Exception("BagPoint::accept : Ooops !");
44  it->accept(pv);
45  }
46 }
std::list< AbstractPoint * > _nodes
Definition: BlocPoint.hxx:35

References YACS::ENGINE::BlocPoint::_nodes.

Referenced by YACS::ENGINE::SetOfPoints::accept().

◆ deal1()

void BagPoint::deal1 ( bool &  somethingDone)

Definition at line 109 of file BagPoint.cxx.

110 {
111  somethingDone=false;
112  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
113  {
114  if(!(*it)->isSimplyLinkedBeforeAfter(this))
115  if(!(*it)->isSimplyLinkedAfterNullBefore(this) && !(*it)->isSimplyLinkedBeforeNullAfter(this))
116  continue;
117  LinkedBlocPoint *try0((*it)->tryAsLink(this));
118  if(try0)
119  {
120  replaceInMe(try0);
121  somethingDone=true;
122  break;
123  }
124  }
125 }
void replaceInMe(BlocPoint *aSet)
Definition: BagPoint.cxx:96

References YACS::ENGINE::BlocPoint::_nodes, and replaceInMe().

Referenced by YACS::ENGINE::SetOfPoints::basicSimplify(), and YACS::ENGINE::SetOfPoints::simplify().

◆ deal2()

void BagPoint::deal2 ( bool &  somethingDone)

Definition at line 127 of file BagPoint.cxx.

128 {
129  somethingDone=false;
130  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
131  {
132  if(!(*it)->isSimplyLinkedBeforeAfter(this))
133  continue;
134  ForkBlocPoint *try1((*it)->tryAsFork(this));
135  if(try1)
136  {
137  replaceInMe(try1);
138  somethingDone=true;
139  break;
140  }
141  }
142 }

References YACS::ENGINE::BlocPoint::_nodes, and replaceInMe().

Referenced by YACS::ENGINE::SetOfPoints::basicSimplify(), and YACS::ENGINE::SetOfPoints::simplify().

◆ deal2Bis()

void BagPoint::deal2Bis ( bool &  somethingDone)

Definition at line 144 of file BagPoint.cxx.

145 {
146  somethingDone=false;
147  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
148  {
149  if(!(*it)->isSimplyLinkedAfterNullBefore(this))
150  continue;
151  ForkBlocPoint *try1((*it)->tryAsForkBis(this));
152  if(try1)
153  {
154  replaceInMe(try1);
155  somethingDone=true;
156  break;
157  }
158  }
159 }

References YACS::ENGINE::BlocPoint::_nodes, and replaceInMe().

Referenced by YACS::ENGINE::SetOfPoints::basicSimplify(), and YACS::ENGINE::SetOfPoints::simplify().

◆ deal2Quatro()

void BagPoint::deal2Quatro ( bool &  somethingDone)

Definition at line 178 of file BagPoint.cxx.

179 {
180  somethingDone=false;
181  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
182  {
183  if(!(*it)->isNullBeforeNullAfter(this))
184  continue;
185  ForkBlocPoint *try1((*it)->tryAsForkQuatro(this));
186  if(try1)
187  {
188  replaceInMe(try1);
189  somethingDone=true;
190  break;
191  }
192  }
193 }

References YACS::ENGINE::BlocPoint::_nodes, and replaceInMe().

Referenced by YACS::ENGINE::SetOfPoints::basicSimplify(), and YACS::ENGINE::SetOfPoints::simplify().

◆ deal2Ter()

void BagPoint::deal2Ter ( bool &  somethingDone)

Definition at line 161 of file BagPoint.cxx.

162 {
163  somethingDone=false;
164  for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
165  {
166  if(!(*it)->isSimplyLinkedBeforeNullAfter(this))
167  continue;
168  ForkBlocPoint *try1((*it)->tryAsForkTer(this));
169  if(try1)
170  {
171  replaceInMe(try1);
172  somethingDone=true;
173  break;
174  }
175  }
176 }

References YACS::ENGINE::BlocPoint::_nodes, and replaceInMe().

Referenced by YACS::ENGINE::SetOfPoints::basicSimplify(), and YACS::ENGINE::SetOfPoints::simplify().

◆ dealNotSimpleCase()

void BagPoint::dealNotSimpleCase ( bool &  somethingDone)

This method remove 1, 2 or 3 points from this by flagging them as pathological nodes. By doing so, we hope to simplify enough to have a standart case.

Definition at line 199 of file BagPoint.cxx.

200 {
201  somethingDone=false;
202  for(auto it=_nodes.begin();it!=_nodes.end();it++)
203  {
204  std::vector<AbstractPoint *> v{*it};
205  AbstractPoint::TryAsNotSimpleCase((*it)->getFather(),v,_nodes,somethingDone);
206  if(somethingDone)
207  break;
208  }
209  if(somethingDone)
210  return ;
211  //
212  for(auto it=_nodes.cbegin();it!=_nodes.cend();it++)
213  {
214  auto it2(it); it2++;
215  for(;it2!=_nodes.cend();it2++)
216  {
217  std::vector<AbstractPoint *> v{*it,*it2};
218  AbstractPoint::TryAsNotSimpleCase((*it)->getFather(),v,_nodes,somethingDone);
219  if(somethingDone)
220  return;
221  }
222  }
223  if(somethingDone)
224  return ;
225  //
226  for(auto it=_nodes.cbegin();it!=_nodes.cend();it++)
227  {
228  auto it2(it); it2++;
229  for(;it2!=_nodes.cend();it2++)
230  {
231  auto it3(it2); it3++;
232  for(;it3!=_nodes.cend();it3++)
233  {
234  std::vector<AbstractPoint *> v{*it,*it2,*it3};
235  AbstractPoint::TryAsNotSimpleCase((*it)->getFather(),v,_nodes,somethingDone);
236  if(somethingDone)
237  return;
238  }
239  }
240  }
241 }
static void TryAsNotSimpleCase(AbstractPoint *father, const std::vector< AbstractPoint * > &ptsToKill, std::list< AbstractPoint * > &nodes, bool &somethingDone)

References YACS::ENGINE::BlocPoint::_nodes, and YACS::ENGINE::AbstractPoint::TryAsNotSimpleCase().

Referenced by YACS::ENGINE::SetOfPoints::simplify().

◆ deepCopy()

AbstractPoint * BagPoint::deepCopy ( AbstractPoint father) const
overridevirtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 53 of file BagPoint.cxx.

54 {
55  BagPoint *ret(new BagPoint);
56  ret->deepCopyFrom(*this);
57  ret->setFather(father);
58  return ret;
59 }

References YACS::ENGINE::BlocPoint::deepCopyFrom(), and YACS::ENGINE::AbstractPoint::setFather().

◆ expandNonSimpleCase()

void BagPoint::expandNonSimpleCase ( )

All NotSimpleCasePoint instances in this->_nodes are going to be scanned recursively accross this->_nodes. To do that NotSimpleCasePoint instance are added incrementaly.

Definition at line 297 of file BagPoint.cxx.

298 {
299  std::vector<AbstractPoint *> pathologicalPt;
300  std::for_each(_nodes.begin(),_nodes.end(),[&pathologicalPt](AbstractPoint *elt) { if(dynamic_cast<NotSimpleCasePoint *>(elt)) pathologicalPt.push_back(elt); });
301  if(pathologicalPt.empty())
302  throw YACS::Exception("BagPoint::expandNonSimpleCase : Not found any pathological case !");
303  for(auto it : pathologicalPt)
304  this->expandNonSimpleCaseOn(it);
305 
306 }
AbstractPoint * expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set< Node * > &uncatchedNodes) override
Definition: BagPoint.cxx:48

References YACS::ENGINE::BlocPoint::_nodes, and expandNonSimpleCaseOn().

Referenced by YACS::ENGINE::SetOfPoints::simplify().

◆ expandNonSimpleCaseOn() [1/2]

void BagPoint::expandNonSimpleCaseOn ( AbstractPoint pathologicalPt)
private

Append a single pathologicalPt point instance to AbstractPoint instances contained in this. To do that we start to locate in graph dependancy in this with ENGINE::Node cannot run in parallel with pathologicalPt. These nodes stored in nodesBeforeAfter.

By walking across Points in this if a Point has no intersection with nodesBeforeAfter this Point is converted to a ForkBlocPoint.

Definition at line 249 of file BagPoint.cxx.

250 {
251  NotSimpleCasePoint *pathologicalPt2(dynamic_cast<NotSimpleCasePoint *>(pathologicalPt));
252  if(!pathologicalPt2)
253  throw YACS::Exception("BagPoint::expandNonSimpleCaseOn : pathologicalPt is expected to be a NotSimpleCasePoint !");
254  std::list<AbstractPoint *> nodes2;
255  std::for_each(_nodes.begin(),_nodes.end(),[&nodes2](AbstractPoint *elt) { if(!dynamic_cast<NotSimpleCasePoint *>(elt)) nodes2.push_back(elt); });
256  if(nodes2.size()!=1)
257  throw YACS::Exception("BagPoint::expandNonSimpleCaseOn : Internal error only one AbstractPoint is expected !");
258 
259  Node *firstNode(pathologicalPt->getFirstNode()),*lastNode(pathologicalPt->getLastNode());
260  //
261  ComposedNode *parent(firstNode->getFather());
262  Bloc *parentc(dynamic_cast<Bloc *>(parent));
263  if(!parentc)
264  throw YACS::Exception("BagPoint::expandNonSimpleCaseOn : internal error, Bloc expected");
265  //
266  std::set<Node *> nodesBefore, nodesAfter;
267  {
268  std::map<Node *, std::set<Node *> > accelStr;
269  LinkInfo info(E_ALL);
270  parentc->findAllNodesStartingFrom<false>(firstNode,nodesBefore,accelStr,info);
271  }
272  {
273  std::map<Node *, std::set<Node *> > accelStr;
274  LinkInfo info(E_ALL);
275  parentc->findAllNodesStartingFrom<true>(lastNode,nodesAfter,accelStr,info);
276  }
277  //
278  std::set<Node *> nodesBeforeAfter(nodesBefore.begin(),nodesBefore.end());
279  nodesBeforeAfter.insert(nodesAfter.begin(),nodesAfter.end());
280  //std::for_each(nodesBeforeAfter.begin(),nodesBeforeAfter.end(),[](Node *elt) { std::cerr << elt->getName() << " "; }); std::cerr << std::endl;
281  //
282  AbstractPoint *onlyOne(*nodes2.begin());
283  AbstractPoint *res(onlyOne->expandNonSimpleCaseOn(pathologicalPt2,nodesBeforeAfter));
284  if(res!=onlyOne)
285  throw YACS::Exception("BagPoint::expandNonSimpleCaseOn : unexpected situation !");// impossible because by construction pathologicalPt cannot be merged to this. If it were possible, algo in simplify would be simply it !
286  {// remove delete pathologicalPt and remove it from this->_nodes
287  std::list<AbstractPoint *> nodes3;
288  std::for_each(_nodes.begin(),_nodes.end(),[&nodes3,pathologicalPt](AbstractPoint *elt) { if(elt!=pathologicalPt) nodes3.push_back(elt); else delete elt; });
289  _nodes = nodes3;
290  }
291 }
virtual Node * getLastNode()=0
virtual Node * getFirstNode()=0
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36
Base class for all composed nodes.
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83
Base class for all nodes.
Definition: Node.hxx:70

References YACS::ENGINE::BlocPoint::_nodes, YACS::ENGINE::E_ALL, YACS::ENGINE::AbstractPoint::expandNonSimpleCaseOn(), YACS::ENGINE::Bloc::findAllNodesStartingFrom(), YACS::ENGINE::AbstractPoint::getFirstNode(), and YACS::ENGINE::AbstractPoint::getLastNode().

◆ expandNonSimpleCaseOn() [2/2]

AbstractPoint * BagPoint::expandNonSimpleCaseOn ( NotSimpleCasePoint pathologicalPt,
const std::set< Node * > &  uncatchedNodes 
)
overridevirtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 48 of file BagPoint.cxx.

49 {
50  throw YACS::Exception("BagPoint::expandNonSimpleCaseOn : Ooops !");
51 }

Referenced by expandNonSimpleCase().

◆ getFirstNode()

Node * BagPoint::getFirstNode ( )
overridevirtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 61 of file BagPoint.cxx.

62 {
63  return getUnique()->getFirstNode();
64 }
AbstractPoint * getUnique()
Definition: BlocPoint.cxx:111

References YACS::ENGINE::AbstractPoint::getFirstNode(), and YACS::ENGINE::BlocPoint::getUnique().

◆ getLastNode()

Node * BagPoint::getLastNode ( )
overridevirtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 66 of file BagPoint.cxx.

67 {
68  return getUnique()->getLastNode();
69 }

References YACS::ENGINE::AbstractPoint::getLastNode(), and YACS::ENGINE::BlocPoint::getUnique().

◆ getMaxLevelOfParallelism()

int BagPoint::getMaxLevelOfParallelism ( ) const
virtual

◆ getRepr()

std::string BagPoint::getRepr ( ) const
virtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 86 of file BagPoint.cxx.

87 {
88  std::ostringstream oss;
89  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
90  oss << (*it)->getRepr() << " - ";
91  return oss.str();
92 }

References YACS::ENGINE::BlocPoint::_nodes.

Referenced by YACS::ENGINE::SetOfPoints::getRepr().

◆ getWeightRegardingDPL()

void BagPoint::getWeightRegardingDPL ( ComplexWeight weight)
virtual

◆ partitionRegardingDPL()

void BagPoint::partitionRegardingDPL ( const PartDefinition pd,
std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &  zeMap 
) const
virtual

Implements YACS::ENGINE::AbstractPoint.

Definition at line 81 of file BagPoint.cxx.

82 {
83  getUnique()->partitionRegardingDPL(pd,zeMap);
84 }
virtual void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap) const =0

References YACS::ENGINE::BlocPoint::getUnique(), and YACS::ENGINE::AbstractPoint::partitionRegardingDPL().

Referenced by YACS::ENGINE::SetOfPoints::partitionRegardingDPL().

◆ replaceInMe()

void BagPoint::replaceInMe ( BlocPoint aSet)

Definition at line 96 of file BagPoint.cxx.

97 {
98  const std::list<AbstractPoint *>& pts(aSet->getListOfPoints());
99  for(std::list<AbstractPoint *>::const_iterator it0=pts.begin();it0!=pts.end();it0++)
100  {
101  std::list<AbstractPoint *>::iterator it1(std::find(_nodes.begin(),_nodes.end(),*it0));
102  if(it1==_nodes.end())
103  throw Exception("SetOfPoints::replaceInMe : internal error !");
104  _nodes.erase(it1);
105  }
106  _nodes.push_back(aSet);
107 }
const std::list< AbstractPoint * > & getListOfPoints() const
Definition: BlocPoint.hxx:46

References YACS::ENGINE::BlocPoint::_nodes, and YACS::ENGINE::BlocPoint::getListOfPoints().

Referenced by deal1(), deal2(), deal2Bis(), deal2Quatro(), and deal2Ter().

◆ size()

int YACS::ENGINE::BagPoint::size ( ) const
inline

Definition at line 48 of file BagPoint.hxx.

48 { return (int)_nodes.size(); }

Referenced by YACS::ENGINE::SetOfPoints::basicSimplify().


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