1 | // |
---|
2 | // GWt_abstractElementFactory.cc |
---|
3 | // PSPA |
---|
4 | // |
---|
5 | // Created by Garnier Laurent on 28/01/13. |
---|
6 | // Copyright (c) 2013 Garnier Laurent. All rights reserved. |
---|
7 | // |
---|
8 | |
---|
9 | #include "GWt_abstractElementFactory.h" |
---|
10 | |
---|
11 | GWt_abstractElementFactory::GWt_abstractElementFactory() |
---|
12 | :isDriftElementEnable(false), |
---|
13 | isRFGunElementEnable(false), |
---|
14 | isCellElementEnable(false), |
---|
15 | isBendElementEnable(false), |
---|
16 | isSolenoElementEnable(false), |
---|
17 | isBeamElementEnable(false), |
---|
18 | isFitElementEnable(false), |
---|
19 | isSnapshotElementEnable(false), |
---|
20 | isMPoleElementEnable(false) |
---|
21 | {} |
---|
22 | |
---|
23 | GWt_abstractElementFactory::~GWt_abstractElementFactory() |
---|
24 | { |
---|
25 | isDriftElementEnable = false; |
---|
26 | isRFGunElementEnable = false; |
---|
27 | isCellElementEnable = false; |
---|
28 | isBendElementEnable = false; |
---|
29 | isSolenoElementEnable = false; |
---|
30 | isBeamElementEnable = false; |
---|
31 | isFitElementEnable = false; |
---|
32 | isSnapshotElementEnable = false; |
---|
33 | isMPoleElementEnable = false; |
---|
34 | } |
---|
35 | |
---|
36 | GWt_elementDrift* GWt_abstractElementFactory::createDriftElement() |
---|
37 | { |
---|
38 | if (isDriftElementEnable) { |
---|
39 | return new GWt_elementDrift(); |
---|
40 | } |
---|
41 | return NULL; |
---|
42 | } |
---|
43 | |
---|
44 | GWt_elementRfgun* GWt_abstractElementFactory::createRFGunElement() |
---|
45 | { |
---|
46 | if (isRFGunElementEnable) { |
---|
47 | return new GWt_elementRfgun(); |
---|
48 | } |
---|
49 | return NULL; |
---|
50 | } |
---|
51 | |
---|
52 | GWt_elementCell* GWt_abstractElementFactory::createCellElement() |
---|
53 | { |
---|
54 | if (isCellElementEnable) { |
---|
55 | return new GWt_elementCell(); |
---|
56 | } |
---|
57 | return NULL; |
---|
58 | } |
---|
59 | |
---|
60 | GWt_elementBend* GWt_abstractElementFactory::createBendElement() |
---|
61 | { |
---|
62 | if (isBendElementEnable) { |
---|
63 | return new GWt_elementBend(); |
---|
64 | } |
---|
65 | return NULL; |
---|
66 | } |
---|
67 | |
---|
68 | GWt_elementSoleno* GWt_abstractElementFactory::createSolenoElement() |
---|
69 | { |
---|
70 | if (isSolenoElementEnable) { |
---|
71 | return new GWt_elementSoleno(); |
---|
72 | } |
---|
73 | return NULL; |
---|
74 | } |
---|
75 | |
---|
76 | GWt_elementBeam* GWt_abstractElementFactory::createBeamElement() |
---|
77 | { |
---|
78 | if (isBeamElementEnable) { |
---|
79 | return new GWt_elementBeam(); |
---|
80 | } |
---|
81 | return NULL; |
---|
82 | } |
---|
83 | |
---|
84 | GWt_elementFit* GWt_abstractElementFactory::createFitElement() |
---|
85 | { |
---|
86 | if (isFitElementEnable) { |
---|
87 | return new GWt_elementFit(); |
---|
88 | } |
---|
89 | return NULL; |
---|
90 | } |
---|
91 | |
---|
92 | GWt_elementSnapshot* GWt_abstractElementFactory::createSnapshotElement() |
---|
93 | { |
---|
94 | if (isSnapshotElementEnable) { |
---|
95 | return new GWt_elementSnapshot(); |
---|
96 | } |
---|
97 | return NULL; |
---|
98 | } |
---|
99 | |
---|
100 | GWt_elementMpole* GWt_abstractElementFactory::createMPoleElement() |
---|
101 | { |
---|
102 | if (isMPoleElementEnable) { |
---|
103 | return new GWt_elementMpole(); |
---|
104 | } |
---|
105 | return NULL; |
---|
106 | } |
---|
107 | |
---|
108 | vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements() |
---|
109 | { |
---|
110 | vector <GWt_abstractElement*> elems; |
---|
111 | if (isRFGunElementEnable) { |
---|
112 | elems.push_back(new GWt_elementRfgun()); |
---|
113 | } |
---|
114 | if (isBeamElementEnable) { |
---|
115 | elems.push_back(new GWt_elementBeam()); |
---|
116 | } |
---|
117 | if (isDriftElementEnable) { |
---|
118 | elems.push_back(new GWt_elementDrift()); |
---|
119 | } |
---|
120 | if (isBendElementEnable) { |
---|
121 | elems.push_back(new GWt_elementBend()); |
---|
122 | } |
---|
123 | if (isCellElementEnable) { |
---|
124 | elems.push_back(new GWt_elementCell()); |
---|
125 | } |
---|
126 | if (isSolenoElementEnable) { |
---|
127 | elems.push_back(new GWt_elementSoleno()); |
---|
128 | } |
---|
129 | if (isFitElementEnable) { |
---|
130 | elems.push_back(new GWt_elementFit()); |
---|
131 | } |
---|
132 | if (isSnapshotElementEnable) { |
---|
133 | elems.push_back(new GWt_elementSnapshot()); |
---|
134 | } |
---|
135 | if (isMPoleElementEnable) { |
---|
136 | elems.push_back(new GWt_elementMpole()); |
---|
137 | } |
---|
138 | |
---|
139 | return elems; |
---|
140 | } |
---|