Version: 8.3.0
YACS::ENGINE::DeploymentTreeOnHeap Class Reference

#include <DeploymentTree.hxx>

Collaboration diagram for YACS::ENGINE::DeploymentTreeOnHeap:

Public Member Functions

 DeploymentTreeOnHeap ()
 
 ~DeploymentTreeOnHeap ()
 
bool decrRef ()
 
void incrRef () const
 
unsigned char appendTask (Task *task, Scheduler *cloner)
 
unsigned getNumberOfCTDefContainer () const
 
unsigned getNumberOfRTODefContainer () const
 
unsigned getNumberOfCTDefComponentInstances () const
 
unsigned getNumberOfRTODefComponentInstances () const
 
std::vector< Container * > getAllContainers () const
 
std::vector< Container * > getAllCTDefContainers () const
 
std::vector< Container * > getAllRTODefContainers () const
 
std::vector< Task * > getTasksLinkedToComponent (ComponentInstance *comp) const
 
std::vector< Task * > getTasksLinkedToContainer (Container *cont) const
 
std::vector< ComponentInstance * > getComponentsLinkedToContainer (Container *cont) const
 
bool presenceOfDefaultContainer () const
 
std::vector< Task * > getFreeDeployableTasks () const
 

Private Attributes

int _cnt
 
std::vector< std::pair< Task
*, Scheduler * > > 
_freePlacableTasks
 
std::vector< std::vector
< std::vector< std::pair< Task
*, Scheduler * > > > > 
_tree
 internal representation of tree. Scheduler is the duplicating Task, if it exists, on runtime unpredictable times on compil-time More...
 

Detailed Description

Definition at line 36 of file DeploymentTree.hxx.

Constructor & Destructor Documentation

DeploymentTreeOnHeap::DeploymentTreeOnHeap ( )

Definition at line 32 of file DeploymentTree.cxx.

32  :_cnt(1)
33 {
34 }
DeploymentTreeOnHeap::~DeploymentTreeOnHeap ( )

Definition at line 36 of file DeploymentTree.cxx.

37 {
38 }

Member Function Documentation

unsigned char DeploymentTreeOnHeap::appendTask ( Task task,
Scheduler cloner 
)

Definition at line 53 of file DeploymentTree.cxx.

References _freePlacableTasks, _tree, YACS::ENGINE::DeploymentTree::ALREADY_IN_TREE, YACS::ENGINE::DeploymentTree::APPEND_OK, DEBTRACE, YACS::ENGINE::DeploymentTree::DEPLOYABLE_BUT_NOT_SPECIFIED, YACS::ENGINE::Task::getComponent(), YACS::ENGINE::Task::getContainer(), YACS::ENGINE::Task::isDeployable(), YACS::ENGINE::DeploymentTree::NOT_DEPLOYABLE_TASK, and YACS::ENGINE::DeploymentTree::NULL_TASK.

Referenced by YACS::ENGINE::DeploymentTree::appendTask().

54 {
55  DEBTRACE( "DeploymentTreeOnHeap::appendTask: " << task );
56  if(!task)
58  if(!task->isDeployable())//Task not needed to be placed.
60  ComponentInstance *ci=task->getComponent();
61  Container *cont=task->getContainer();
62  DEBTRACE( "DeploymentTreeOnHeap::appendTask component: " << ci );
63  DEBTRACE( "DeploymentTreeOnHeap::appendTask container: " << cont );
64  if(!ci && !cont)//Task is not attached to a Component or a Container -> not needed to be placed.
65  {
66  _freePlacableTasks.push_back(pair<Task *,Scheduler *>(task,cloner));
68  }
69  DEBTRACE( "DeploymentTreeOnHeap::appendTask container: " << cont );
70 
71  // an iterator for Container level
72  vector< vector< vector< pair<Task *, Scheduler *> > > >::iterator iter1;
73  // an iterator for Component instance level
74  vector< vector< pair<Task *, Scheduler * > > >::iterator iter2;
75  // an iterator for a vector of tasks with same container and component instance
76  vector< pair<Task *, Scheduler *> >::iterator iter3;
77 
78  // search an existing vector of tasks with container == cont
79  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
80  {
81  Task* task=(*iter1)[0][0].first;
82  if(task->getContainer() == cont)
83  break;
84  }
85  if(iter1==_tree.end())
86  {
87  // the vector does not exist : create it
88  DEBTRACE("create a vector of vector of tasks for container " << cont);
89  _tree.push_back(vector< vector< pair< Task *, Scheduler *> > >());
90  iter1=_tree.end();
91  iter1--;
92  }
93 
94  // search a vector of tasks with component instance == ci
95  for(iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
96  if(((*iter2)[0]).first->getComponent()==ci)
97  break;
98  if(iter2==(*iter1).end())
99  {
100  // the vector does not exist : create it
101  DEBTRACE("create a vector of tasks for component instance " << ci);
102  (*iter1).push_back(vector< pair< Task *, Scheduler *> >());
103  iter2=(*iter1).end();
104  iter2--;
105  }
106 
107  // search the task in the vector. If it exists return
108  for(iter3=(*iter2).begin();iter3!=(*iter2).end();iter3++)
109  if((*iter3).first==task)
111 
112  DEBTRACE("add task to vector of tasks " << task);
113  (*iter2).push_back(pair<Task *,Scheduler *>(task,cloner));
115 }
bool DeploymentTreeOnHeap::decrRef ( )

Definition at line 40 of file DeploymentTree.cxx.

References _cnt, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::operator=(), and YACS::ENGINE::DeploymentTree::~DeploymentTree().

41 {
42  bool ret=(--_cnt==0);
43  if(ret)
44  delete this;
45  return ret;
46 }
std::vector< Container * > DeploymentTreeOnHeap::getAllContainers ( ) const

Definition at line 235 of file DeploymentTree.cxx.

References _tree, YACS::ENGINE::Task::getContainer(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getAllContainers().

236 {
237  vector<Container *> ret;
238  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
239  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
240  {
241  Task* task=(*iter1)[0][0].first;
242  ret.push_back(task->getContainer());
243  }
244  return ret;
245 }
std::vector< Container * > DeploymentTreeOnHeap::getAllCTDefContainers ( ) const

Definition at line 247 of file DeploymentTree.cxx.

References _tree, DEBTRACE, YACS::ENGINE::Container::isAttachedOnCloning(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getAllCTDefContainers().

248 {
249  DEBTRACE("getAllCTDefContainers");
250  vector<Container *> ret;
251  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
252  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
253  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
254  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
255  {
256  bool isCTDefSurely1=true;
257  for(iter2=(*iter1).begin();iter2!=(*iter1).end() && isCTDefSurely1;iter2++)
258  {
259  bool isCTDefSurely2=true;
260  for(iter3=(*iter2).begin();iter3!=(*iter2).end() && isCTDefSurely2;iter3++)
261  if((*iter3).second!=0)
262  isCTDefSurely2=false;
263  if(isCTDefSurely2)
264  isCTDefSurely1=true;
265  else if(((*iter2)[0].first)->getComponent())
266  isCTDefSurely1=(((*iter2)[0].first)->getComponent()->isAttachedOnCloning());
267  else
268  isCTDefSurely1=false;
269  }
270  Container *cont=((*iter1)[0][0].first)->getContainer();
271  if(isCTDefSurely1)
272  {
273  if(cont)
274  ret.push_back(cont);
275  }
276  else
277  if(cont)
278  if(cont->isAttachedOnCloning())
279  ret.push_back(cont);
280  }
281  return ret;
282 }
std::vector< Container * > DeploymentTreeOnHeap::getAllRTODefContainers ( ) const

Definition at line 284 of file DeploymentTree.cxx.

References _tree, DEBTRACE, YACS::ENGINE::Container::isAttachedOnCloning(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getAllRTODefContainers().

285 {
286  DEBTRACE("getAllRTODefContainers");
287  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
288  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
289  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
290  vector<Container *> ret;
291  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
292  {
293  bool isRTODefSurely1=true;
294  for(iter2=(*iter1).begin();iter2!=(*iter1).end() && isRTODefSurely1;iter2++)
295  {
296  bool isRTODefSurely2=true;
297  for(iter3=(*iter2).begin();iter3!=(*iter2).end() && isRTODefSurely2;iter3++)
298  if((*iter3).second==0)
299  isRTODefSurely2=false;
300  if(isRTODefSurely2)
301  {
302  if(((*iter2)[0].first)->getComponent())
303  isRTODefSurely1=!(((*iter2)[0].first)->getComponent()->isAttachedOnCloning());
304  else
305  isRTODefSurely1=false;
306  }
307  else
308  isRTODefSurely1=false;
309  }
310  if(isRTODefSurely1)
311  {
312  Container* cont= (*iter1)[0][0].first->getContainer();
313  if(cont)
314  if(!cont->isAttachedOnCloning())
315  ret.push_back(cont);
316  }
317  }
318  return ret;
319 }
std::vector< ComponentInstance * > DeploymentTreeOnHeap::getComponentsLinkedToContainer ( Container cont) const

Definition at line 354 of file DeploymentTree.cxx.

References _tree, DEBTRACE, YACS::ENGINE::ComponentInstance::getContainer(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getComponentsLinkedToContainer().

355 {
356  DEBTRACE("DeploymentTreeOnHeap::getComponentsLinkedToContainer ");
357  vector<ComponentInstance *> ret;
358  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
359  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
360  //iterate on containers
361  for(iter1=_tree.begin();iter1!=_tree.end();++iter1)
362  {
363  //iterate on components
364  for(iter2=(*iter1).begin();iter2!=(*iter1).end();++iter2)
365  {
366  ComponentInstance *compo=(*iter2)[0].first->getComponent();
367  if(compo)
368  {
369  //it's a real component, add it if its container is the right one
370  if(compo->getContainer()==cont)
371  ret.push_back(compo);
372  else
373  break;
374  }
375  }
376  }
377 
378  return ret;
379 }
std::vector< Task * > DeploymentTreeOnHeap::getFreeDeployableTasks ( ) const

Definition at line 391 of file DeploymentTree.cxx.

References _freePlacableTasks, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getFreeDeployableTasks().

392 {
393  vector<Task *> ret;
394  for(vector< pair<Task *,Scheduler *> >::const_iterator iter=_freePlacableTasks.begin();iter!=_freePlacableTasks.end();iter++)
395  ret.push_back((*iter).first);
396  return ret;
397 }
unsigned DeploymentTreeOnHeap::getNumberOfCTDefComponentInstances ( ) const

Definition at line 192 of file DeploymentTree.cxx.

References _tree, DEBTRACE, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getNumberOfCTDefComponentInstances().

193 {
194  DEBTRACE("getNumberOfCTDefComponentInstances");
195  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
196  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
197  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
198  unsigned ret=0;
199  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
200  for(iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
201  {
202  bool isCTDefSurely=true;
203  for(iter3=(*iter2).begin();iter3!=(*iter2).end() && isCTDefSurely;iter3++)
204  if((*iter3).second!=0)
205  isCTDefSurely=false;
206  if(isCTDefSurely)
207  ret++;
208  else
209  if(((*iter2)[0].first)->getComponent() && ((*iter2)[0].first)->getComponent()->isAttachedOnCloning())
210  ret++;
211  }
212  return ret;
213 }
unsigned DeploymentTreeOnHeap::getNumberOfCTDefContainer ( ) const

Definition at line 117 of file DeploymentTree.cxx.

References _tree, DEBTRACE, YACS::ENGINE::Container::isAttachedOnCloning(), and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getNumberOfCTDefContainer().

118 {
119  DEBTRACE("getNumberOfCTDefContainer ");
120  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
121  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
122  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
123  unsigned ret=0;
124  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
125  {
126  bool isCTDefSurely1=true;
127  for(iter2=(*iter1).begin();iter2!=(*iter1).end() && isCTDefSurely1;iter2++)
128  {
129  bool isCTDefSurely2=true;
130  for(iter3=(*iter2).begin();iter3!=(*iter2).end() && isCTDefSurely2;iter3++)
131  if((*iter3).second!=0)
132  isCTDefSurely2=false;
133  if(isCTDefSurely2)
134  isCTDefSurely1=true;
135  else if(((*iter2)[0].first)->getComponent())
136  isCTDefSurely1=(((*iter2)[0].first)->getComponent()->isAttachedOnCloning());
137  else
138  isCTDefSurely1=false;
139  }
140  Container *cont=((*iter1)[0][0].first)->getContainer();
141  if(isCTDefSurely1)
142  {
143  if(cont)
144  ret++;
145  }
146  else
147  if(cont)
148  if(cont->isAttachedOnCloning())
149  ret++;
150  else
151  {
152  unsigned val;
153  if((*iter1)[0][0].second->isMultiplicitySpecified(val))
154  ret+=val;
155  }
156  }
157  return ret;
158 }
unsigned DeploymentTreeOnHeap::getNumberOfRTODefComponentInstances ( ) const

Definition at line 215 of file DeploymentTree.cxx.

References _tree, DEBTRACE, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getNumberOfRTODefComponentInstances().

216 {
217  DEBTRACE("getNumberOfRTODefComponentInstances");
218  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
219  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
220  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
221  unsigned ret=0;
222  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
223  for(iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
224  {
225  bool isRTODef=false;
226  for(iter3=(*iter2).begin();iter3!=(*iter2).end() && !isRTODef;iter3++)
227  if((*iter3).second!=0)
228  isRTODef=true;
229  if(isRTODef && ((*iter2)[0].first)->getComponent() && !((*iter2)[0].first)->getComponent()->isAttachedOnCloning())
230  ret++;
231  }
232  return ret;
233 }
unsigned DeploymentTreeOnHeap::getNumberOfRTODefContainer ( ) const

Definition at line 160 of file DeploymentTree.cxx.

References _tree, DEBTRACE, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getNumberOfRTODefContainer().

161 {
162  DEBTRACE("getNumberOfRTODefContainer");
163  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
164  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
165  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
166  unsigned ret=0;
167  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
168  {
169  bool isRTODefSurely1=true;
170  for(iter2=(*iter1).begin();iter2!=(*iter1).end() && isRTODefSurely1;iter2++)
171  {
172  bool isRTODefSurely2=true;
173  for(iter3=(*iter2).begin();iter3!=(*iter2).end() && isRTODefSurely2;iter3++)
174  if((*iter3).second==0)
175  isRTODefSurely2=false;
176  if(isRTODefSurely2)
177  if(((*iter2)[0].first)->getComponent())
178  isRTODefSurely1=!(((*iter2)[0].first)->getComponent()->isAttachedOnCloning());
179  else
180  isRTODefSurely1=false;
181  else
182  isRTODefSurely1=false;
183  }
184  if(isRTODefSurely1)
185  if(((*iter1)[0][0].first)->getContainer())
186  if(!((*iter1)[0][0].first)->getContainer()->isAttachedOnCloning())
187  ret++;
188  }
189  return ret;
190 }
std::vector< Task * > DeploymentTreeOnHeap::getTasksLinkedToComponent ( ComponentInstance comp) const

Definition at line 339 of file DeploymentTree.cxx.

References _tree, CORBAEngineTest::comp, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getTasksLinkedToComponent().

340 {
341  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
342  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
343  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
344 
345  std::vector<Task *> ret;
346  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
347  for(iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
348  if(((*iter2)[0].first)->getComponent()==comp)
349  for(iter3=(*iter2).begin();iter3!=(*iter2).end();iter3++)
350  ret.push_back((*iter3).first);
351  return ret;
352 }
std::vector< Task * > DeploymentTreeOnHeap::getTasksLinkedToContainer ( Container cont) const

Definition at line 321 of file DeploymentTree.cxx.

References _tree, and PMMLBasicsTestLauncher::ret.

Referenced by YACS::ENGINE::DeploymentTree::getTasksLinkedToContainer().

322 {
323  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
324  vector< vector< pair<Task *, Scheduler * > > >::const_iterator iter2;
325  vector< pair<Task *, Scheduler *> >::const_iterator iter3;
326 
327  std::vector<Task *> ret;
328  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
329  {
330  if(((*iter1)[0][0].first)->getContainer()==cont)
331  for(iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
332  if(((*iter2)[0].first)->getComponent()==0)
333  for(iter3=(*iter2).begin();iter3!=(*iter2).end();iter3++)
334  ret.push_back((*iter3).first);
335  }
336  return ret;
337 }
void DeploymentTreeOnHeap::incrRef ( ) const

Definition at line 48 of file DeploymentTree.cxx.

References _cnt.

Referenced by YACS::ENGINE::DeploymentTree::DeploymentTree(), and YACS::ENGINE::DeploymentTree::operator=().

49 {
50  _cnt++;
51 }
bool DeploymentTreeOnHeap::presenceOfDefaultContainer ( ) const

Definition at line 381 of file DeploymentTree.cxx.

References _tree, and DEBTRACE.

Referenced by YACS::ENGINE::DeploymentTree::presenceOfDefaultContainer().

382 {
383  DEBTRACE("presenceOfDefaultContainer");
384  vector< vector< vector< pair<Task *, Scheduler *> > > >::const_iterator iter1;
385  for(iter1=_tree.begin();iter1!=_tree.end();iter1++)
386  if(!((*iter1)[0][0].first)->getContainer())
387  return true;
388  return false;
389 }

Member Data Documentation

int YACS::ENGINE::DeploymentTreeOnHeap::_cnt
mutableprivate

Definition at line 61 of file DeploymentTree.hxx.

Referenced by decrRef(), and incrRef().

std::vector< std::pair<Task *,Scheduler *> > YACS::ENGINE::DeploymentTreeOnHeap::_freePlacableTasks
private

Definition at line 62 of file DeploymentTree.hxx.

Referenced by appendTask(), and getFreeDeployableTasks().

std::vector< std::vector< std::vector< std::pair<Task *, Scheduler * > > > > YACS::ENGINE::DeploymentTreeOnHeap::_tree
private

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