1 | |
---|
2 | #include <iostream> |
---|
3 | #include <algorithm> // std::find |
---|
4 | |
---|
5 | #include "abstractElement.h" |
---|
6 | |
---|
7 | abstractElement::abstractElement() |
---|
8 | : abstractSoftware_(NULL) |
---|
9 | { |
---|
10 | setDefaultValues(); |
---|
11 | setDefaults(); |
---|
12 | stepmaxcm_ = 1000000; |
---|
13 | } |
---|
14 | |
---|
15 | abstractElement::abstractElement(string lab) |
---|
16 | { |
---|
17 | label_ = lab; |
---|
18 | setDefaultValues(); |
---|
19 | setDefaults(); |
---|
20 | stepmaxcm_ = 1000000; |
---|
21 | } |
---|
22 | |
---|
23 | abstractElement::~abstractElement() |
---|
24 | { |
---|
25 | if (parametersString_ != NULL) delete [] parametersString_ ; |
---|
26 | } |
---|
27 | |
---|
28 | void abstractElement::setDefaultValues() |
---|
29 | { |
---|
30 | defaultLabel_ = string("XXXXXX"); |
---|
31 | defaultLength_ = 0.0; |
---|
32 | defaultAperture_ = 1.e+6; |
---|
33 | phaseStepMax_ = 10.; |
---|
34 | } |
---|
35 | |
---|
36 | void abstractElement::setDefaults() |
---|
37 | { |
---|
38 | label_ = defaultLabel_; |
---|
39 | nbParam_ = 2; |
---|
40 | lenghtElem_ = defaultLength_; |
---|
41 | aperture_ = defaultAperture_; |
---|
42 | } |
---|
43 | |
---|
44 | void abstractElement::setPhaseStep(double) { |
---|
45 | cout << " setPhaseStep : ce n'est pas celui la qu'il faut ! " ; |
---|
46 | return; |
---|
47 | } |
---|
48 | |
---|
49 | void abstractElement::setParameters(double ll, double aper) |
---|
50 | { |
---|
51 | lenghtElem_ = ll; |
---|
52 | aperture_ = aper; |
---|
53 | } |
---|
54 | |
---|
55 | void abstractElement::setLabel(string lab) |
---|
56 | { |
---|
57 | label_= lab; |
---|
58 | } |
---|
59 | |
---|
60 | string abstractElement::getLabel() const |
---|
61 | { |
---|
62 | return label_; |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | nomdElements abstractElement::getNomdElement() const |
---|
67 | { |
---|
68 | return elementName_; |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | double abstractElement::getLenghtOfElement() const { |
---|
74 | return lenghtElem_; |
---|
75 | } |
---|
76 | |
---|
77 | int abstractElement::getNbParams() const { |
---|
78 | return nbParam_; |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | trivaluedBool 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 | |
---|
99 | double abstractElement::getInitialKineticEnergy() const { |
---|
100 | return 0.0; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | string abstractElement::generatorOutputFlow() const { |
---|
105 | return ""; |
---|
106 | } |
---|
107 | |
---|
108 | trivaluedBool 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 | |
---|
139 | void 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 | } |
---|