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 # Reid Townson
28 #
29 ###############################################################################
30 */
31 
32 
33 #ifndef EGS_FUNCTIONS_
34 #define EGS_FUNCTIONS_
35 
36 #include "egs_libconfig.h"
37 
38 #include <iostream>
39 #include <string>
40 using namespace std;
41 
59 #ifdef SINGLE
60  const EGS_Float epsilon = 1.0/(1<<21);
61 #else
62  const EGS_Float epsilon = 1.0/(1ULL<<50);
63 #endif
64 
83 #ifdef SINGLE
84  const EGS_Float distanceEpsilon = 1.0/(1<<21);
85 #else
86  const EGS_Float distanceEpsilon = 1.0/(1ULL<<32);
87 #endif
88 
96 const EGS_I64 loopMax = 1e10;
97 
105 const EGS_Float veryFar = 1e30;
106 
117 bool EGS_EXPORT egsStoreI64(ostream &data, EGS_I64 n);
118 
129 bool EGS_EXPORT egsGetI64(istream &data, EGS_I64 &n);
130 
134 typedef void (*EGS_InfoFunction)(const char *,...);
135 
150 
161 
172 
173 enum EGS_InfoType { Information, Warning, Fatal };
174 
184 egsSetInfoFunction(EGS_InfoType t, EGS_InfoFunction func);
185 
191 
199 string EGS_EXPORT egsSimplifyCVSKey(const string &key);
200 
206 void EGS_EXPORT egsSwapBytes(int *);
207 
213 void EGS_EXPORT egsSwapBytes(short *);
214 
220 void EGS_EXPORT egsSwapBytes(float *);
221 
227 string EGS_EXPORT egsJoinPath(const string &first, const string &second);
228 
233 string EGS_EXPORT egsStripPath(const string &fname);
234 
243 string EGS_EXPORT egsExpandPath(const string &fname);
244 
249 string EGS_EXPORT egsHostName();
250 
255 int EGS_EXPORT egsGetPid();
256 
264 
269 bool EGS_EXPORT egsIsAbsolutePath(const string &path);
270 
271 bool EGS_EXPORT egsEquivStr(const string &a, const string &b);
272 
273 #endif
void(* EGS_InfoFunction)(const char *,...)
Defines a function printf-like prototype for functions to be used to report info, warnings,...
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
Definition: egs_libconfig.h:90
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,...
string EGS_EXPORT egsHostName()
Get the name of the host the program is running on.
int EGS_EXPORT egsGetPid()
Get the process id.
int EGS_EXPORT egsGetEndian()
Get the endianess of the machine.
EGS_EXPORT EGS_InfoFunction egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_EXPORT EGS_InfoFunction egsFatal
Always use this function for reporting fatal errors.
EGS_InfoFunction EGS_EXPORT egsSetInfoFunction(EGS_InfoType t, EGS_InfoFunction func)
Set a function to be used for outputing information, warning messages or reporting fatal errors.
bool EGS_EXPORT egsIsAbsolutePath(const string &path)
Does the string path represent an absolute path name?
string EGS_EXPORT egsExpandPath(const string &fname)
Expands first environment variable found in a file name.
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,...
string EGS_EXPORT egsSimplifyCVSKey(const string &key)
Remove the $'s from a CVS key.
const EGS_Float distanceEpsilon
The distanceEpsilon constant for physical distance comparisons.
Definition: egs_functions.h:86
const EGS_I64 loopMax
The maximum number of iterations for near-infinite loops.
Definition: egs_functions.h:96
void EGS_EXPORT egsSetDefaultIOFunctions()
Reset I/O functions to their defaults.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
Definition: egs_functions.h:62
string EGS_EXPORT 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...
void EGS_EXPORT egsSwapBytes(int *)
Swap the bytes of 32 bit integers.
EGS_EXPORT EGS_InfoFunction egsWarning
Always use this function for reporting warnings.
const EGS_Float veryFar
A very large float.
string EGS_EXPORT egsStripPath(const string &fname)
Strip the path from a file name and return the result.