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