EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_ausgab_object.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ ausgab object
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:
27 #
28 ###############################################################################
29 */
30 
31 
40 #include "egs_ausgab_object.h"
41 #include "egs_input.h"
42 
44 ausgab_object_creator(string("egs++/dso/")+CONFIG_NAME,"EGS_AusgabObject");
45 
47  ausgab_object_creator.createObjects(i,"ausgab object definition",
48  "ausgab object","__no__key__","createAusgabObject",true);
49 }
50 
52  EGS_Object *o = ausgab_object_creator.getObject(Name);
53  if (!o) {
54  return 0;
55  }
56  EGS_AusgabObject *s = dynamic_cast<EGS_AusgabObject *>(o);
57  if (s) {
58  return s;
59  }
60  egsWarning("EGS_AusgabObject::getAusgabObject(): dynamic cast failed?\n"
61  " Object named %s is of type %s. Trying simple cast\n",
62  Name.c_str(),o->getObjectType().c_str());
63  return (EGS_AusgabObject *)o;
64 }
65 
67  if (o) egsInformation("Adding known ausgab object of type %s\n",
68  o->getObjectType().c_str());
69  ausgab_object_creator.addKnownObject(o);
70 }
71 
72 void EGS_AusgabObject::addKnownTypeId(const char *tid) {
73  ausgab_object_creator.addKnownTypeId(tid);
74 }
75 
77  return ausgab_object_creator.nObjects();
78 }
79 
81  return (EGS_AusgabObject *) ausgab_object_creator.getObject(j);
82 }
Base egspp object.
static int nObjects()
Returns the number of ausgab objects in the internal list.
EGS_AusgabObject interface class header file.
static EGS_AusgabObject * getObject(int j)
Returns the j&#39;th ausgab object in the internal list.
EGS_Input class header file.
A typed object factory.
static EGS_AusgabObject * getAusgabObject(const string &Name)
Get a pointer to the ausgab object named Name.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
static void createAusgabObjects(EGS_Input *)
Create ausgab objects from the information pointed to by input.
const string & getObjectType() const
Get the object type.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
static void addKnownTypeId(const char *name)
Add a known ausgab object typeid to the ausgab object factory.
static void addKnownAusgabObject(EGS_AusgabObject *o)
Add a known ausgab object to the ausgab object factory.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.