EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Design of the EGSnrc C++ class library

The EGSnrc C++ class library is organized as a main library file (libegspp.so for Linux/Unix, egspp.dll for Windows, and libegspp.dylib for Mac OSX) and a series of small dynamic shared objects (DSO, also known as DLL in the Windows world), one for each geometry and source type. EGSnrc applications written in C++ link against the main library. Geometry and source DSOs are loaded dynamically as needed at run time using the EGS_Library class. In order this to work, each geometry DSO must provide a C-style function createGeometry(), which, given a definition of a geometry stored in an EGS_Input object, creates an instance of the geometry class. In a similar way each particle source DSO must provide a C-style function createSource() that can create instances of the particle source class provided by the DSO. The geometry and source of a simulation are specified in an input file. The input file is read in by an instance of the EGS_Input class and results in a tree-like structure of key-value pairs (for elementary properties) or keys and an arbitrary number of subkey-value pairs (for compound properties). The geometry information is stored in a compound property named geometry definition, the source information in a property named source definition. This input tree is then passed to a geometry factory, which, based on the values stored in certain sub-keys, loads the corresponding geometry DSO dynamically into memory and passes the necessary information to the geometry creation function of the library. In a similar way the information related to particle source is given to a source factory. The syntax of the input file is therefore an important part of the process of specifying a simulation geometry and/or particle source and is described more detail in the EGS_Input class documentation

There are several motivations behind this design: