source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/src/sector.cc @ 472

Last change on this file since 472 was 472, checked in by garnier, 11 years ago

Modification pour remettre en marche le Run. Desormais Transport passe, mais aucun test ne permet de dire si c est bon

File size: 1.8 KB
Line 
1//
2//  sector.cpp
3//  PSPA
4//
5//  Created by Garnier Laurent on 10/12/13.
6//  Copyright (c) 2013 Garnier Laurent. All rights reserved.
7//
8
9#include "sector.h"
10
11#include "sectionToExecute.h"
12#include "dataManager.h"
13
14sector::sector(dataManager* data, std::string name):
15reflected_(false),
16duplicatedFrom_(NULL),
17repetitionNumber_(1),
18currentBeam_(NULL),
19name_(name),
20dataManager_(data),
21sectorParam_(this)
22{
23 
24}
25
26sector::~sector()  {
27}
28
29void sector::addElementAfter(abstractElement* currentElement ,abstractElement* previousElement){
30// if the previous element is NULL, it will try to add at the beginning of the first section
31 
32  if (previousElement == NULL) {
33    if (sectionToExecute_.size() == 0) {
34      sectionToExecute_.push_back(new sectionToExecute(currentElement,NULL,dataManager_));
35    } else {
36        sectionToExecute* section = sectionToExecute_.front();
37      section->insertAtFirst(currentElement);
38    }
39  } else {
40 
41    for (unsigned int i=0; i<sectionToExecute_.size(); i++) {
42      sectionToExecute* section = sectionToExecute_[i];
43      if (section->insertAfter(previousElement,currentElement)) {
44        return;
45      }
46    }
47  }
48}
49
50void sector::clearSectionToExecute()
51{
52  unsigned k;
53  for(k = 0; k < sectionToExecute_.size(); k++)
54  {
55    if ( sectionToExecute_[k] != NULL ) clearSectionToExecute(k);
56  }
57  sectionToExecute_.clear();
58}
59
60void sector::clearSectionToExecute(int a)
61{
62  cout << " dataManager::clearSectionToExecute : effacement de la section d'index = " << a << endl;
63  if (a < 0) return;
64  if (a >= (int)sectionToExecute_.size()) return;
65 
66  // lors de la creation de la section on a fait un 'new' d'un
67  // softwareXXXX : on fait ici le 'delete'
68 
69  const abstractSoftware* soft = sectionToExecute_.at(a)->getSoftware();
70  if ( soft != NULL ) delete soft;
71  sectionToExecute_.erase (sectionToExecute_.begin()+a);
72}
Note: See TracBrowser for help on using the repository browser.