EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_ausgab_object.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ ausgab object 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: Iwan Kawrakow, 2009
25 #
26 # Contributors: Reid Townson
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_AUSGAB_OBJECT_
38 #define EGS_AUSGAB_OBJECT_
39 
40 #include "egs_application.h"
41 #include "egs_object_factory.h"
42 #include "egs_input_struct.h"
43 
44 #include <string>
45 #include <iostream>
46 using namespace std;
47 
62 class EGS_Input;
63 class EGS_Application;
64 
65 static shared_ptr<EGS_BlockInput> ausBlockInput = make_shared<EGS_BlockInput>("ausgab object");
66 inline void setBaseAusgabObjectInputs() {
67  ausBlockInput->addSingleInput("library", true, "The type of ausgab object, loaded by shared library in egs++/dso.");
68  ausBlockInput->addSingleInput("name", true, "The user-declared unique name of this ausgab object. This is the name you may refer to elsewhere in the input file.");
69 }
70 
72 
73 public:
74 
76  EGS_AusgabObject(const string &Name="", EGS_ObjectFactory *f = 0) : EGS_Object(Name,f), app(0) {};
77 
87  EGS_AusgabObject(EGS_Input *input, EGS_ObjectFactory *f = 0) : EGS_Object(input,f), app(0) {};
88 
89  virtual ~EGS_AusgabObject() {};
90 
98  virtual int processEvent(EGS_Application::AusgabCall iarg, int ir) {
99  (void)iarg; // Explicitly silence the "unused parameter" compiler warning
100  (void)ir;
101  return 0;
102  };
103 
109  virtual bool needsCall(EGS_Application::AusgabCall iarg) const {
110  (void)iarg;
111  return false;
112  };
113 
115  virtual void setApplication(EGS_Application *App) {
116  app = App;
117  };
118 
120  virtual void setCurrentCase(EGS_I64 ncase) {
121  (void)ncase;
122  };
123 
129  const char *getObjectDescription() const {
130  return description.c_str();
131  };
132 
141  virtual bool storeState(ostream &data_out) const {
142  (void)data_out;
143  return true;
144  };
145 
155  virtual bool setState(istream &data_in) {
156  (void)data_in;
157  return true;
158  };
159 
168  virtual bool addState(istream &data_in) {
169  (void)data_in;
170  return true;
171  };
172 
184  virtual void resetCounter() {};
185 
192  virtual void reportResults() {};
193 
213  static void createAusgabObjects(EGS_Input *);
214 
223  static EGS_AusgabObject *getAusgabObject(const string &Name);
224 
232  static void addKnownAusgabObject(EGS_AusgabObject *o);
233 
242  static void addKnownTypeId(const char *name);
243 
245  static int nObjects();
246 
248  static EGS_AusgabObject *getObject(size_t j);
249 
250 protected:
251 
257  string description;
258 
261 
262 };
263 
264 #endif
Base class for advanced EGSnrc C++ applications.
AusgabCall
Possible calls to the user scoring function ausgab().
virtual void resetCounter()
Reset the ausgab object state.
const char * getObjectDescription() const
Get a short description of this ausgab object.
virtual void setApplication(EGS_Application *App)
Set the application this object belongs to.
virtual int processEvent(EGS_Application::AusgabCall iarg)=0
Process an ausgab call for event iarg.
virtual bool setState(istream &data_in)
Set the ausgab object state based on data from the stream data_in.
virtual void reportResults()
Report results.
string description
A short ausgab object description.
EGS_AusgabObject(EGS_Input *input, EGS_ObjectFactory *f=0)
Construct an ausgab object from the input pointed to by inp.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
virtual void setCurrentCase(EGS_I64 ncase)
Set the current event.
virtual bool addState(istream &data_in)
Add data from the stream data_in to the ausgab object state.
EGS_AusgabObject(const string &Name="", EGS_ObjectFactory *f=0)
Construct an ausgab object named Name.
EGS_Application * app
The application this object belongs to.
virtual bool needsCall(EGS_Application::AusgabCall iarg) const
Is the ausgab call iarg relevant for this object?
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
An object factory.
Base egspp object.
EGS_Application class header file.
The input struct header file.
#define EGS_EXPORT
Export symbols from the egspp library.
Definition: egs_libconfig.h:90
EGS_Object and EGS_ObjectFactory class header file.