EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_input_struct.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ input struct headers
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Reid Townson, 2019
25 #
26 # Contributors:
27 #
28 # An application has one global scope input struct object. Input blocks are
29 # then added to contain geometries or sources. Input blocks may contain single
30 # inputs.
31 #
32 ###############################################################################
33 */
34 
35 
42 #ifndef EGS_INPUT_STRUCT_
43 #define EGS_INPUT_STRUCT_
44 
45 #include <vector>
46 #include <string>
47 #include "egs_libconfig.h"
48 #include <memory>
49 
50 using namespace std;
51 
52 class EGS_BlockInput;
53 
61 
62 public:
64 
69  EGS_SingleInput(string inputTag, bool isReq, const string desc, const vector<string> vals);
70  ~EGS_SingleInput();
71 
73  string getTag();
74 
76  bool getRequired();
77 
82  void addDependency(shared_ptr<EGS_SingleInput> inp, string val = "", bool isAntiDependency = false);
83 
85  void addDependency(shared_ptr<EGS_BlockInput> block, bool isAntiDependency = false);
86 
88  vector<shared_ptr<EGS_SingleInput>> getDependencyInp();
89 
91  vector<string> getDependencyVal();
92 
94  vector<bool> getDependencyAnti();
95 
97  shared_ptr<EGS_BlockInput> getDependencyBlock();
98 
100  bool getDependencyBlockAnti();
101 
103  const vector<string> getValues();
104 
106  void setValues(const vector<string> vals);
107 
109  string getDescription();
110 
111 private:
112 
113  vector<string> requirements;
114  string tag;
115  bool isRequired;
116  string description;
117  vector<string> values;
118  vector<shared_ptr<EGS_SingleInput>> dependencyInp;
119  vector<string> dependencyVal;
120  vector<bool> dependencyAnti;
121  shared_ptr<EGS_BlockInput> dependencyBlock;
122  bool dependencyBlockAnti;
123 };
124 
132  : public std::enable_shared_from_this<EGS_BlockInput> {
133 public:
134  EGS_BlockInput();
135 
140  EGS_BlockInput(string blockTit, bool isReq = false, shared_ptr<EGS_BlockInput> par = nullptr);
141  ~EGS_BlockInput();
142 
144  void setTitle(string blockTit);
145 
147  string getTitle();
148 
150  void setAppName(string appName);
151 
153  string getAppName();
154 
156  shared_ptr<EGS_SingleInput> addSingleInput(string inputTag, bool isReq, const string desc, const vector<string> vals = vector<string>());
157 
159  shared_ptr<EGS_BlockInput> addBlockInput(string blockTit, bool isReq = false);
160 
162  shared_ptr<EGS_BlockInput> addBlockInput(shared_ptr<EGS_BlockInput> block);
163 
165  vector<shared_ptr<EGS_SingleInput>> getSingleInputs();
166 
168  vector<shared_ptr<EGS_SingleInput>> getSingleInputs(string title);
169 
171  vector<shared_ptr<EGS_BlockInput>> getBlockInputs();
172 
174  vector<shared_ptr<EGS_BlockInput>> getBlockInputs(string title);
175 
177  shared_ptr<EGS_SingleInput> getSingleInput(string inputTag);
178 
180  shared_ptr<EGS_SingleInput> getSingleInput(string inputTag, string title);
181 
183  shared_ptr<EGS_BlockInput> getBlockInput(string title);
184 
186  void setParent(shared_ptr<EGS_BlockInput> par);
187 
189  shared_ptr<EGS_BlockInput> getParent();
190 
192  shared_ptr<EGS_BlockInput> getLibraryBlock(string blockTitle, string libraryName);
193 
195  bool contains(string inputTag);
196 
198  void addDependency(shared_ptr<EGS_SingleInput> inp, string val = "", bool isAntiDependency = false);
199 
201  void addDependency(shared_ptr<EGS_BlockInput> block, bool isAntiDependency = false);
202 
204  vector<shared_ptr<EGS_SingleInput>> getDependencyInp();
205 
207  vector<string> getDependencyVal();
208 
210  vector<bool> getDependencyAnti();
211 
213  shared_ptr<EGS_BlockInput> getDependencyBlock();
214 
216  bool getDependencyBlockAnti();
217 
218 
219 private:
220 
221  vector<shared_ptr<EGS_SingleInput>> singleInputs;
222  vector<shared_ptr<EGS_BlockInput>> blockInputs;
223  shared_ptr<EGS_BlockInput> parent;
224  string blockTitle;
225  bool isRequired;
226  string application;
227  const string desc;
228  vector<shared_ptr<EGS_SingleInput>> dependencyInp;
229  vector<string> dependencyVal;
230  vector<bool> dependencyAnti;
231  shared_ptr<EGS_BlockInput> dependencyBlock;
232  bool dependencyBlockAnti;
233 };
234 
271 public:
272  EGS_InputStruct();
273  ~EGS_InputStruct();
274 
276  shared_ptr<EGS_BlockInput> addBlockInput(string blockTit, bool isReq = false);
277 
279  shared_ptr<EGS_BlockInput> addBlockInput(shared_ptr<EGS_BlockInput> block);
280 
282  void addBlockInputs(vector<shared_ptr<EGS_BlockInput>> blocks);
283 
285  void removeBlockInput(string blockTitle);
286 
288  void removeBlockInputByApp(string appName);
289 
291  vector<shared_ptr<EGS_BlockInput>> getBlockInputs();
292 
294  shared_ptr<EGS_BlockInput> getBlockInput(string title, string parentTitle = "");
295 
297  shared_ptr<EGS_BlockInput> getLibraryBlock(string blockTitle, string libraryName);
298 
300  vector<string> getLibraryOptions(string blockTitle);
301 
302 private:
303 
304  vector<shared_ptr<EGS_BlockInput>> blockInputs;
305  vector<shared_ptr<EGS_BlockInput>> generalBlocks;
306 };
307 
308 
309 #endif
A class to represent an egsinp input block.
A class to represent an egsinp input structure.
A class to represent an egsinp single line input.
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
Definition: egs_libconfig.h:90