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

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

grosse modification pour intégrer les sections

File size: 1.9 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#include "softwareParmela.h"
11#include "softwareTransport.h"
12#include "softwareGenerator.h"
13#include "softwareGenerator.h"
14#include "softwareUsersprogram.h"
15#include "softwareTest.h"
16#include "softwareMadx.h" //xx
17#include "softwareUnknown.h" //xx
18
19#include "sectionToExecute.h"
20#include "dataManager.h"
21
22sector::sector(dataManager* data, std::string name):
23reflected_(false),
24duplicatedFrom_(NULL),
25repetitionNumber_(1),
26name_(name),
27dataManager_(data),
28sectorParam_(this)
29{
30 
31}
32
33sector::~sector()  {
34}
35
36void sector::addElementAfter(abstractElement* currentElement ,abstractElement* previousElement){
37  if (previousElement == NULL) {
38    if (sectionToExecute_.size() == 0) {
39      sectionToExecute_.push_back(new sectionToExecute(currentElement));
40    } else {
41      sectionToExecute_.insert ( sectionToExecute_.begin() , new sectionToExecute(currentElement) );
42    }
43  } else {
44 
45    for (unsigned int i=0; i<sectionToExecute_.size(); i++) {
46      sectionToExecute* section = sectionToExecute_[i];
47      if (section->insertAfter(previousElement,currentElement)) {
48        return;
49      }
50    }
51  }
52}
53
54void sector::clearSectionToExecute()
55{
56  unsigned k;
57  for(k = 0; k < sectionToExecute_.size(); k++)
58  {
59    if ( sectionToExecute_[k] != NULL ) clearSectionToExecute(k);
60  }
61  sectionToExecute_.clear();
62}
63
64void sector::clearSectionToExecute(int a)
65{
66  cout << " dataManager::clearSectionToExecute : effacement de la section d'index = " << a << endl;
67  if (a < 0) return;
68  if (a >= (int)sectionToExecute_.size()) return;
69 
70  // lors de la creation de la section on a fait un 'new' d'un
71  // softwareXXXX : on fait ici le 'delete'
72 
73  const abstractSoftware* soft = sectionToExecute_.at(a)->getSoftware();
74  if ( soft != NULL ) delete soft;
75  sectionToExecute_.erase (sectionToExecute_.begin()+a);
76}
Note: See TracBrowser for help on using the repository browser.