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 | |
---|
14 | sector::sector(dataManager* data, std::string name): |
---|
15 | reflected_(false), |
---|
16 | duplicatedFrom_(NULL), |
---|
17 | repetitionNumber_(1), |
---|
18 | currentBeam_(NULL), |
---|
19 | name_(name), |
---|
20 | dataManager_(data), |
---|
21 | sectorParam_(this) |
---|
22 | { |
---|
23 | |
---|
24 | } |
---|
25 | |
---|
26 | sector::~sector() { |
---|
27 | } |
---|
28 | |
---|
29 | void 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 | |
---|
50 | void 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 | |
---|
60 | void 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 | } |
---|