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

Last change on this file since 469 was 469, checked in by garnier, 10 years ago

Désormais il est de nouveau possible d'ajouter des sections et dy affecter des softwares (ne marche pour le moment quavec la 1ere sectionToExecute. Autres améliorations et renommages

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),
18name_(name),
19dataManager_(data),
20sectorParam_(this)
21{
22 
23}
24
25sector::~sector()  {
26}
27
28void sector::addElementAfter(abstractElement* currentElement ,abstractElement* previousElement){
29// if the previous element is NULL, it will try to add at the beginning of the first section
30 
31  if (previousElement == NULL) {
32    if (sectionToExecute_.size() == 0) {
33      sectionToExecute_.push_back(new sectionToExecute(currentElement,NULL));
34    } else {
35        sectionToExecute* section = sectionToExecute_.front();
36      section->insertAtFirst(currentElement);
37    }
38  } else {
39 
40    for (unsigned int i=0; i<sectionToExecute_.size(); i++) {
41      sectionToExecute* section = sectionToExecute_[i];
42      if (section->insertAfter(previousElement,currentElement)) {
43        return;
44      }
45    }
46  }
47}
48
49void sector::clearSectionToExecute()
50{
51  unsigned k;
52  for(k = 0; k < sectionToExecute_.size(); k++)
53  {
54    if ( sectionToExecute_[k] != NULL ) clearSectionToExecute(k);
55  }
56  sectionToExecute_.clear();
57}
58
59void sector::clearSectionToExecute(int a)
60{
61  cout << " dataManager::clearSectionToExecute : effacement de la section d'index = " << a << endl;
62  if (a < 0) return;
63  if (a >= (int)sectionToExecute_.size()) return;
64 
65  // lors de la creation de la section on a fait un 'new' d'un
66  // softwareXXXX : on fait ici le 'delete'
67 
68  const abstractSoftware* soft = sectionToExecute_.at(a)->getSoftware();
69  if ( soft != NULL ) delete soft;
70  sectionToExecute_.erase (sectionToExecute_.begin()+a);
71}
Note: See TracBrowser for help on using the repository browser.