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