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 | {} |
---|
21 | |
---|
22 | GWt_abstractElementFactory::~GWt_abstractElementFactory() |
---|
23 | { |
---|
24 | isDriftElementEnable = false; |
---|
25 | isRFGunElementEnable = false; |
---|
26 | isCellElementEnable = false; |
---|
27 | isBendElementEnable = false; |
---|
28 | isSolenoElementEnable = false; |
---|
29 | isBeamElementEnable = false; |
---|
30 | isFitElementEnable = false; |
---|
31 | isSnapshotElementEnable = false; |
---|
32 | } |
---|
33 | |
---|
34 | GWt_drift* GWt_abstractElementFactory::createDriftElement() |
---|
35 | { |
---|
36 | if (isDriftElementEnable) { |
---|
37 | return new GWt_drift(); |
---|
38 | } |
---|
39 | return NULL; |
---|
40 | } |
---|
41 | |
---|
42 | GWt_rfgun* GWt_abstractElementFactory::createRFGunElement() |
---|
43 | { |
---|
44 | if (isRFGunElementEnable) { |
---|
45 | return new GWt_rfgun(); |
---|
46 | } |
---|
47 | return NULL; |
---|
48 | } |
---|
49 | |
---|
50 | GWt_cell* GWt_abstractElementFactory::createCellElement() |
---|
51 | { |
---|
52 | if (isCellElementEnable) { |
---|
53 | return new GWt_cell(); |
---|
54 | } |
---|
55 | return NULL; |
---|
56 | } |
---|
57 | |
---|
58 | GWt_bend* GWt_abstractElementFactory::createBendElement() |
---|
59 | { |
---|
60 | if (isBendElementEnable) { |
---|
61 | return new GWt_bend(); |
---|
62 | } |
---|
63 | return NULL; |
---|
64 | } |
---|
65 | |
---|
66 | GWt_soleno* GWt_abstractElementFactory::createSolenoElement() |
---|
67 | { |
---|
68 | if (isSolenoElementEnable) { |
---|
69 | return new GWt_soleno(); |
---|
70 | } |
---|
71 | return NULL; |
---|
72 | } |
---|
73 | |
---|
74 | GWt_beam* GWt_abstractElementFactory::createBeamElement() |
---|
75 | { |
---|
76 | if (isBeamElementEnable) { |
---|
77 | return new GWt_beam(); |
---|
78 | } |
---|
79 | return NULL; |
---|
80 | } |
---|
81 | |
---|
82 | GWt_fit* GWt_abstractElementFactory::createFitElement() |
---|
83 | { |
---|
84 | if (isFitElementEnable) { |
---|
85 | return new GWt_fit(); |
---|
86 | } |
---|
87 | return NULL; |
---|
88 | } |
---|
89 | |
---|
90 | GWt_snapshot* GWt_abstractElementFactory::createSnapshotElement() |
---|
91 | { |
---|
92 | if (isSnapshotElementEnable) { |
---|
93 | return new GWt_snapshot(); |
---|
94 | } |
---|
95 | return NULL; |
---|
96 | } |
---|
97 | |
---|
98 | vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements() |
---|
99 | { |
---|
100 | vector <GWt_abstractElement*> elems; |
---|
101 | if (isRFGunElementEnable) { |
---|
102 | elems.push_back(new GWt_rfgun()); |
---|
103 | } |
---|
104 | if (isBeamElementEnable) { |
---|
105 | elems.push_back(new GWt_beam()); |
---|
106 | } |
---|
107 | if (isDriftElementEnable) { |
---|
108 | elems.push_back(new GWt_drift()); |
---|
109 | } |
---|
110 | if (isBendElementEnable) { |
---|
111 | elems.push_back(new GWt_bend()); |
---|
112 | } |
---|
113 | if (isCellElementEnable) { |
---|
114 | elems.push_back(new GWt_cell()); |
---|
115 | } |
---|
116 | if (isSolenoElementEnable) { |
---|
117 | elems.push_back(new GWt_soleno()); |
---|
118 | } |
---|
119 | if (isFitElementEnable) { |
---|
120 | elems.push_back(new GWt_fit()); |
---|
121 | } |
---|
122 | if (isSnapshotElementEnable) { |
---|
123 | elems.push_back(new GWt_snapshot()); |
---|
124 | } |
---|
125 | |
---|
126 | return elems; |
---|
127 | } |
---|