EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_functions.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ functions 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, 2005
25 #
26 # Contributors: Ernesto Mainegra-Hing
27 #
28 ###############################################################################
29 */
30 
31 
32 #ifndef EGS_FUNCTIONS_
33 #define EGS_FUNCTIONS_
34 
35 #include "egs_libconfig.h"
36 
37 #include <iostream>
38 #include <string>
39 using namespace std;
40 
58 #ifdef SINGLE
59  const EGS_Float epsilon = 1.0/(1<<21);
60 #else
61  const EGS_Float epsilon = 1.0/(1ULL<<50);
62 #endif
63 
82 #ifdef SINGLE
83  const EGS_Float distanceEpsilon = 1.0/(1<<21);
84 #else
85  const EGS_Float distanceEpsilon = 1.0/(1ULL<<32);
86 #endif
87 
95 const EGS_I64 loopMax = 1e10;
96 
104 const EGS_Float veryFar = 1e30;
105 
116 bool EGS_EXPORT egsStoreI64(ostream &data, EGS_I64 n);
117 
128 bool EGS_EXPORT egsGetI64(istream &data, EGS_I64 &n);
129 
133 typedef void (*EGS_InfoFunction)(const char *,...);
134 
149 
160 
171 
172 enum EGS_InfoType { Information, Warning, Fatal };
173 
183 egsSetInfoFunction(EGS_InfoType t, EGS_InfoFunction func);
184 
190 
198 string EGS_EXPORT egsSimplifyCVSKey(const string &key);
199 
205 void EGS_EXPORT egsSwapBytes(int *);
206 
212 void EGS_EXPORT egsSwapBytes(short *);
213 
219 void EGS_EXPORT egsSwapBytes(float *);
220 
226 string EGS_EXPORT egsJoinPath(const string &first, const string &second);
227 
232 string EGS_EXPORT egsStripPath(const string &fname);
233 
242 string EGS_EXPORT egsExpandPath(const string &fname);
243 
248 string EGS_EXPORT egsHostName();
249 
254 int EGS_EXPORT egsGetPid();
255 
263 
268 bool EGS_EXPORT egsIsAbsolutePath(const string &path);
269 
270 bool EGS_EXPORT egsEquivStr(const string &a, const string &b);
271 
272 #endif
#define EGS_EXPORT
Export symbols from the egspp library.
Definition: egs_libconfig.h:90
string egsStripPath(const string &aname)
Strip the path from a file name and return the result.
const EGS_I64 loopMax
The maximum number of iterations for near-infinite loops.
Definition: egs_functions.h:95
bool EGS_EXPORT egsGetI64(istream &data, EGS_I64 &n)
Reads a 64 bit integer from the stream data and assigns it to n. Returns true on success, false on failure.
int egsGetPid()
Get the process id.
bool egsIsAbsolutePath(const string &path)
Does the string path represent an absolute path name?
const EGS_Float distanceEpsilon
The distanceEpsilon constant for physical distance comparisons.
Definition: egs_functions.h:85
bool EGS_EXPORT egsStoreI64(ostream &data, EGS_I64 n)
Writes the 64 bit integer n to the output stream data and returns true on success, false on failure.
string egsJoinPath(const string &first, const string &second)
Join two path variables (or a path and a file name) using the platform specific directory separator a...
EGS_InfoFunction egsSetInfoFunction(EGS_InfoType t, EGS_InfoFunction func)
Set a function to be used for outputing information, warning messages or reporting fatal errors...
void egsSetDefaultIOFunctions()
Reset I/O functions to their defaults.
const EGS_Float veryFar
A very large float.
void egsSwapBytes(int *n)
Swap the bytes of 32 bit integers.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
string egsExpandPath(const string &aname)
Expands first environment variable found in a file name.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
int egsGetEndian()
Get the endianess of the machine.
string egsSimplifyCVSKey(const string &key)
Remove the $&#39;s from a CVS key.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
Definition: egs_functions.h:61
Defines the EGS_EXPORT and EGS_LOCAL macros.
void(* EGS_InfoFunction)(const char *,...)
Defines a function printf-like prototype for functions to be used to report info, warnings...
string egsHostName()
Get the name of the host the program is running on.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.