source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc @ 371

Last change on this file since 371 was 371, checked in by touze, 11 years ago

nvx histos

File size: 3.2 KB
Line 
1
2#include <iostream>
3#include <algorithm>    // std::find
4
5#include "abstractElement.h"
6
7abstractElement::abstractElement() 
8: abstractSoftware_(NULL)
9{
10  setDefaultValues();
11  setDefaults();
12  stepmaxcm_ = 1000000;
13}
14
15abstractElement::abstractElement(string lab)
16{
17  label_ = lab;
18  setDefaultValues();
19  setDefaults();
20  stepmaxcm_ = 1000000;
21}
22
23abstractElement::~abstractElement() 
24{
25  if (parametersString_ != NULL) delete [] parametersString_ ;
26}
27
28void abstractElement::setDefaultValues() 
29{
30  defaultLabel_ = string("XXXXXX");
31  defaultLength_ = 0.0;
32  defaultAperture_ = 1.e+6;
33  phaseStepMax_ = 10.;
34}
35
36void abstractElement::setDefaults() 
37{
38  label_ = defaultLabel_;
39  nbParam_ = 2;
40  lenghtElem_ = defaultLength_;
41  aperture_ = defaultAperture_;
42}
43
44void abstractElement::setPhaseStep(double) { 
45  cout << " setPhaseStep : ce n'est pas celui la qu'il faut ! " ; 
46  return;
47}
48
49void abstractElement::setParameters(double ll, double aper) 
50{
51  lenghtElem_ = ll;
52  aperture_ = aper;
53}
54
55void abstractElement::setLabel(string lab)
56{
57  label_= lab;
58}
59
60string abstractElement::getLabel() const
61{
62  return label_;
63}
64
65
66nomdElements abstractElement::getNomdElement() const 
67{
68  return elementName_;
69}
70
71
72
73double abstractElement::getLenghtOfElement() const { 
74  return lenghtElem_;
75}
76
77int abstractElement::getNbParams() const {
78  return nbParam_;
79}
80
81
82trivaluedBool abstractElement::is_accepted_by_software(nomDeLogiciel prog) {
83    if (acceptableSoftware_.size() == 0) {
84        return TBoolError;
85    }
86
87    if ( std::find(acceptableSoftware_.begin(), acceptableSoftware_.end(), prog) != acceptableSoftware_.end()) {
88        return TBoolOk;
89    } else if ( std::find(ignoreSoftware_.begin(), ignoreSoftware_.end(), prog) != ignoreSoftware_.end()) {
90        return TBoolIgnore;
91    } else {
92        return TBoolError;
93    }
94
95    return TBoolOk;
96}
97
98
99double abstractElement::getInitialKineticEnergy() const {
100  return 0.0;
101}
102
103
104string abstractElement::generatorOutputFlow() const {
105  return "";
106}
107
108trivaluedBool abstractElement::setSoftware(nomDeLogiciel prog) {
109    if (acceptableSoftware_.size() == 0) {
110        return TBoolError;
111    }
112   
113    trivaluedBool tb = TBoolError;
114    if ( std::find(acceptableSoftware_.begin(), acceptableSoftware_.end(), prog) != acceptableSoftware_.end()) {
115        tb = TBoolOk;
116    } else if ( std::find(ignoreSoftware_.begin(), ignoreSoftware_.end(), prog) != ignoreSoftware_.end()) {
117        tb =TBoolIgnore;
118    } else {
119        tb = TBoolError;
120    }
121
122    if ((tb == TBoolOk) || (tb == TBoolIgnore)) {
123      if (prog == nomDeLogiciel::parmela) {
124        abstractSoftware_ = new softwareParmela();
125      } else if (prog == nomDeLogiciel::transport) {
126        abstractSoftware_ = new softwareTransport();
127      } else if (prog == nomDeLogiciel::generator) {
128        abstractSoftware_ = new softwareGenerator();
129      } else if (prog == nomDeLogiciel::test) {
130        abstractSoftware_ = new softwareTest();
131      } else if (prog == nomDeLogiciel::unknownSoftware) {
132        abstractSoftware_ = NULL;
133      }
134    }
135    return tb;
136}
137
138
139void abstractElement::registerAcceptableSoftware(nomDeLogiciel abs,trivaluedBool b) {
140    if (b == TBoolIgnore) {
141        ignoreSoftware_.push_back(abs);
142    } else if (b == TBoolOk){
143        acceptableSoftware_.push_back(abs);
144    }
145}
Note: See TracBrowser for help on using the repository browser.