Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Allocator.hh 71573 2013-06-18 10:26:21Z gcosmo $
// $Id: G4Allocator.hh 88444 2015-02-20 13:43:16Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -46,6 +46,7 @@
#define G4Allocator_h 1
#include <cstddef>
#include <typeinfo>
#include "G4AllocatorPool.hh"
@@ -59,6 +60,7 @@ class G4AllocatorBase
virtual int GetNoPages() const=0;
virtual size_t GetPageSize() const=0;
virtual void IncreasePageSize( unsigned int sz )=0;
virtual const char* GetPoolType() const=0;
};
template <class Type>
@@ -88,6 +90,9 @@ class G4Allocator : public G4AllocatorBase
inline void IncreasePageSize( unsigned int sz );
// Resets allocator and increases default page size of a given factor
inline const char* GetPoolType() const;
// Returns the type_info Id of the allocated type in the pool
public: // without description
// This public section includes standard methods and types
@@ -154,6 +159,11 @@ class G4Allocator : public G4AllocatorBase
G4AllocatorPool mem;
// Pool of elements of sizeof(Type)
private:
const char* tname;
// Type name identifier
};
// ------------------------------------------------------------
@@ -172,6 +182,7 @@ template <class Type>
G4Allocator<Type>::G4Allocator() throw()
: mem(sizeof(Type))
{
tname = typeid(Type).name();
}
// ************************************************************
@@ -258,6 +269,16 @@ void G4Allocator<Type>::IncreasePageSize( unsigned int sz )
mem.GrowPageSize(sz);
}
// ************************************************************
// GetPoolType
// ************************************************************
//
template <class Type>
const char* G4Allocator<Type>::GetPoolType() const
{
return tname;
}
// ************************************************************
// operator==
// ************************************************************
+32 -3
View File
@@ -105,6 +105,9 @@ public:
inline value_type Pop();
// Gets copy of cached value
G4Cache(const G4Cache& rhs);
G4Cache& operator=(const G4Cache& rhs);
protected:
const int& GetId() const { return id; }
private:
@@ -119,9 +122,6 @@ private:
return theCache.GetCache(id);
}
//Disable copy constructor
G4Cache(const G4Cache& rhs);
G4Cache& operator=(const G4Cache& rhs);
};
@@ -222,6 +222,35 @@ G4Cache<V>::G4Cache()
#endif
}
template<class V>
G4Cache<V>::G4Cache(const G4Cache<V>& rhs)
{
//Copy is special, we need to copy the content
//of the cache, not the cache object
if ( this == &rhs ) return;
G4AutoLock l(&gMutex);
id = instancesctr++;
//Force copy of cached data
V aCopy = rhs.GetCache();
Put( aCopy );
#ifdef g4cdebug
cout<<"Copy constructor with id: "<<id<<endl;
#endif
}
template<class V>
G4Cache<V>& G4Cache<V>::operator=(const G4Cache<V>& rhs)
{
if (this == &rhs) return *this;
//Force copy of cached data
V aCopy = rhs.GetCache();
Put(aCopy);
#ifdef g4cdebug
cout<<"Assignement operator with id: "<<id<<endl;
#endif
return *this;
}
template<class V>
G4Cache<V>::G4Cache(const V& v)
{
@@ -63,6 +63,7 @@
#include <vector>
#include "G4Threading.hh"
#include "globals.hh"
#ifdef g4cdebug
#include <iostream>
@@ -159,7 +160,14 @@ void G4CacheReference<V>::Destroy( unsigned int id, G4bool last )
#ifdef g4cdebug
cout<<"Destroying element"<<id<<" is last?"<<last<<endl;
#endif
if ( cache->size() <id && (*cache)[id] ) {
if ( cache->size() < id ) {
G4ExceptionDescription msg;
msg<<"Internal fatal error. Invalid G4Cache size (requested id: "<<id<<" but cache has size: "<<cache->size();
msg<<" Possibly client created G4Cache object in a thread and tried to delete it from another thread!";
G4Exception("G4CacheReference<V>::Destroy","Cache001",FatalException,msg);
return;
}
if ( cache->size() > id && (*cache)[id] ) {
delete (*cache)[id];
(*cache)[id]=0;
}
@@ -202,7 +210,14 @@ inline void G4CacheReference<V*>::Destroy( unsigned int id , G4bool last)
#ifdef g4cdebug
cout<<"Destroying element"<<id<<" is last?"<<last<<"-Pointer template specialization-"<<endl;
#endif
if ( cache->size() <id && (*cache)[id] ) {
if ( cache->size() < id ) {
G4ExceptionDescription msg;
msg<<"Internal fatal error. Invalid G4Cache size (requested id: "<<id<<" but cache has size: "<<cache->size();
msg<<" Possibly client created G4Cache object in a thread and tried to delete it from another thread!";
G4Exception("G4CacheReference<V*>::Destroy","Cache001",FatalException,msg);
return;
}
if ( cache->size() > id && (*cache)[id] ) {
//Ownership is for client
//delete (*cache)[id];
(*cache)[id]=0;
@@ -235,7 +250,11 @@ void G4CacheReference<G4double>::Initialize( unsigned int id )
cache->resize(id+1,static_cast<G4double>(0));
}
#ifdef g4cdebug
void G4CacheReference<G4double>::Destroy( unsigned int id , G4bool last) {
#else
void G4CacheReference<G4double>::Destroy( unsigned int /*id*/ , G4bool last) {
#endif
if ( cache && last ) {
#ifdef g4cdebug
cout<<"Destroying element"<<id<<" is last?"<<last<<"-Pointer template specialization-"<<endl;
+1 -1
View File
@@ -231,7 +231,7 @@ inline G4float G4Expf(G4float initial_x)
{
G4float x = initial_x;
G4float z = G4ExpConsts::fpfloor( G4ExpConsts::LOG2EF * x +0.5f ); /* floor() truncates toward -infinity. */
G4float z = G4ExpConsts::fpfloor( G4ExpConsts::LOG2EF * x +0.5f ); /* std::floor() truncates toward -infinity. */
x -= z * G4ExpConsts::C1F;
x -= z * G4ExpConsts::C2F;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GeometryTolerance.hh 70333 2013-05-29 08:56:45Z gcosmo $
// $Id: G4GeometryTolerance.hh 92328 2015-08-28 07:44:26Z gcosmo $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
@@ -72,7 +72,7 @@ class G4GeometryTolerance
protected:
static void SetSurfaceTolerance(G4double worldExtent);
// Sets the Cartesian surface tolerance to a value computed
// Sets the Cartesian and Radial surface tolerance to a value computed
// from the maximum extent of the world volume. This method
// can be called only once, and is done only through the
// G4GeometryManager class.
@@ -64,7 +64,7 @@ class G4Physics2DVector
public: // with description
G4Physics2DVector();
G4Physics2DVector(size_t nx, size_t ny);
explicit G4Physics2DVector(size_t nx, size_t ny);
// constructors
G4Physics2DVector(const G4Physics2DVector&);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.hh 74256 2013-10-02 14:24:02Z gcosmo $
// $Id: G4PhysicsOrderedFreeVector.hh 93409 2015-10-21 13:26:27Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Definition
@@ -86,17 +86,15 @@ class G4PhysicsOrderedFreeVector : public G4PhysicsVector
void InsertValues(G4double energy, G4double value);
//G4double GetLowEdgeEnergy(size_t binNumber) const;
G4double GetMaxValue();
G4double GetMinValue();
G4double GetEnergy(G4double aValue);
inline G4double GetMaxValue();
G4double GetMaxLowEdgeEnergy();
inline G4double GetMinValue();
inline G4double GetMaxLowEdgeEnergy();
G4double GetMinLowEdgeEnergy();
inline G4double GetMinLowEdgeEnergy();
void DumpValues();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.icc 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4PhysicsOrderedFreeVector.icc 93409 2015-10-21 13:26:27Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Inline Functions Definitions
@@ -68,11 +68,3 @@ G4double G4PhysicsOrderedFreeVector::GetMinLowEdgeEnergy()
return binVector.front();
}
inline
void G4PhysicsOrderedFreeVector::DumpValues()
{
for (size_t i = 0; i < numberOfNodes; i++)
{
G4cout << binVector[i] << "\t" << dataVector[i] << G4endl;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.hh 83009 2014-07-24 14:51:29Z gcosmo $
// $Id: G4PhysicsVector.hh 93409 2015-10-21 13:26:27Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -68,7 +68,6 @@
#include "globals.hh"
#include "G4ios.hh"
//#include "G4Allocator.hh"
#include "G4PhysicsVectorType.hh"
#include "G4Log.hh"
@@ -91,9 +90,6 @@ class G4PhysicsVector
virtual ~G4PhysicsVector();
// destructor
//inline void* operator new(size_t);
// inline void operator delete(void*);
G4double Value(G4double theEnergy, size_t& lastidx) const;
// Get the cross-section/energy-loss value corresponding to the
// given energy. An appropriate interpolation is used to calculate
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.icc 83009 2014-07-24 14:51:29Z gcosmo $
// $Id: G4PhysicsVector.icc 93409 2015-10-21 13:26:27Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -41,27 +41,6 @@
//
//---------------------------------------------------------------
//extern G4GLOB_DLL G4ThreadLocal G4Allocator<G4PhysicsVector> *fpPVAllocator;
//---------------------------------------------------------------
/*
inline
void* G4PhysicsVector::operator new(size_t)
{
if (!fpPVAllocator) fpPVAllocator = new G4Allocator<G4PhysicsVector>;
return (void*)fpPVAllocator->MallocSingle();
}
//---------------------------------------------------------------
inline
void G4PhysicsVector::operator delete(void* aVector)
{
fpPVAllocator->FreeSingle((G4PhysicsVector*)aVector);
}
*/
//---------------------------------------------------------------
inline
G4double G4PhysicsVector::operator[](const size_t binNumber) const
{
@@ -231,36 +210,18 @@ size_t G4PhysicsVector::FindBinLocation(G4double theEnergy) const
size_t bin;
if(type == T_G4PhysicsLogVector) {
bin = size_t(G4Log(theEnergy)/dBin - baseBin);
if(bin + 2 > numberOfNodes) { bin = numberOfNodes - 2; }
else if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(bin + 2 < numberOfNodes && theEnergy > binVector[bin+1])
{ ++bin; }
if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(theEnergy > binVector[bin+1]) { ++bin; }
} else if(type == T_G4PhysicsLinearVector) {
bin = size_t( theEnergy/dBin - baseBin );
if(bin + 2 > numberOfNodes) { bin = numberOfNodes - 2; }
else if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(bin + 2 < numberOfNodes && theEnergy > binVector[bin+1])
{ ++bin; }
if(bin > 0 && theEnergy < binVector[bin]) { --bin; }
else if(theEnergy > binVector[bin+1]) { ++bin; }
} else {
bin = 0;
size_t bin2;
size_t bin3 = numberOfNodes - 1;
while (bin != bin3 - 1) {
bin2 = bin + (bin3 - bin + 1)/2;
if (theEnergy > binVector[bin2]) { bin = bin2; }
else { bin3 = bin2; }
}
/*
// Bin location proposed by K.Genser (FNAL)
// V.I. Usage of this algorithm provides identical results
// no CPU advantage is observed in EM tests
// if new validation information will be known this code may be used
G4PVDataVector::const_iterator it =
std::lower_bound(binVector.begin(), binVector.end(), theEnergy);
bin = it - binVector.begin() - 1;
*/
// Bin location proposed by K.Genser (FNAL)
bin = std::lower_bound(binVector.begin(), binVector.end(), theEnergy)
- binVector.begin() - 1;
}
return bin;
return std::min(bin, numberOfNodes-2);
}
//---------------------------------------------------------------
+20 -22
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Pow.hh 83383 2014-08-21 14:20:37Z gcosmo $
// $Id: G4Pow.hh 93311 2015-10-16 10:16:37Z gcosmo $
//
//
// -------------------------------------------------------------------
@@ -131,19 +131,22 @@ inline G4double G4Pow::Z13(G4int Z) const
inline G4double G4Pow::A13(G4double A) const
{
G4double res;
G4double a = A;
if(1.0 > A) { a = 1.0/A; }
if(a <= maxA)
G4double res = 0.0;
if(A > 0.0)
{
G4int i = G4int(a + 0.5);
G4double x = (a/G4double(i) - 1.0)*onethird;
res = pz13[i]*(1.0 + x - x*x*(1.0 - 1.66666666*x));
if(1.0 > A) { res = 1.0/res; }
}
else
{
res = std::pow(A, onethird);
G4double a = (1.0 <= A) ? A : 1.0/A;
if(1.0 > A) { a = 1.0/A; }
if(a <= maxA)
{
G4int i = G4int(a + 0.5);
G4double x = (a/G4double(i) - 1.0)*onethird;
res = pz13[i]*(1.0 + x - x*x*(1.0 - 1.66666666*x));
if(1.0 > A) { res = 1.0/res; }
}
else
{
res = std::pow(A, onethird);
}
}
return res;
}
@@ -190,17 +193,13 @@ inline G4double G4Pow::logBase(G4double a) const
inline G4double G4Pow::logA(G4double A) const
{
G4double res;
if(1.0 <= A) { res = logBase(A); }
else { res = -logBase(1./A); }
return res;
return (1.0 <= A ? logBase(A) : -logBase(1./A));
}
inline G4double G4Pow::logX(G4double x) const
{
G4double res = 0.0;
G4double a = x;
if(1.0 > x) { a = 1.0/x; }
G4double a = (1.0 <= x) ? x : 1.0/x;
if(a <= maxA)
{
@@ -236,8 +235,7 @@ inline G4double G4Pow::log10A(G4double A) const
inline G4double G4Pow::expA(G4double A) const
{
G4double res;
G4double a = A;
if(0.0 > A) { a = -A; }
G4double a = (0.0 <= A) ? A : -A;
if(a <= maxAexp)
{
@@ -260,7 +258,7 @@ inline G4double G4Pow::powZ(G4int Z, G4double y) const
inline G4double G4Pow::powA(G4double A, G4double y) const
{
return expA(y*logX(A));
return (0.0 == A ? 0.0 : expA(y*logX(A)));
}
inline G4double G4Pow::factorial(G4int Z) const
+47 -13
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SIunits.hh 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4SIunits.hh 92196 2015-08-21 09:55:47Z gcosmo $
//
// ----------------------------------------------------------------------
//
@@ -38,15 +38,15 @@
// -------
// The basic units are those of the International System:
//
// meter
// meter
// second
// kilogram
// ampere
// degree kelvin
// the amount of substance (mole)
// luminous intensity (candela)
// the amount of substance (mole)
// luminous intensity (candela)
// radian
// steradian
// steradian
//
//
// The SI numerical value of the positron charge is defined here,
@@ -61,11 +61,20 @@
// History:
//
// 10.03.99 created
// 01.03.01 parsec
// 01.03.01 parsec
// 11.06.15 upgrate. Equivalent to SystemOfUnits.h
// 08.08.15 add decimeter, liter (mma)
#ifndef G4UNITSTEST_HH
#define G4UNITSTEST_HH
#ifndef SI_SYSTEM_OF_UNITS_HH
#define SI_SYSTEM_OF_UNITS_HH
//
//
//
static const double pi = 3.14159265358979323846;
static const double twopi = 2*pi;
static const double halfpi = pi/2;
static const double pi2 = pi*pi;
//
// Length [L]
//
@@ -80,7 +89,7 @@ static const double millimeter3 = millimeter*millimeter*millimeter;
static const double centimeter = 10.*millimeter;
static const double centimeter2 = centimeter*centimeter;
static const double centimeter3 = centimeter*centimeter*centimeter;
static const double kilometer = 1000.*meter;
static const double kilometer2 = kilometer*kilometer;
static const double kilometer3 = kilometer*kilometer*kilometer;
@@ -99,6 +108,9 @@ static const double nanobarn = 1.e-9 *barn;
static const double picobarn = 1.e-12*barn;
// symbols
static const double nm = nanometer;
static const double um = micrometer;
static const double mm = millimeter;
static const double mm2 = millimeter2;
static const double mm3 = millimeter3;
@@ -107,6 +119,12 @@ static const double cm = centimeter;
static const double cm2 = centimeter2;
static const double cm3 = centimeter3;
static const double liter = 1.e+3*cm3;
static const double L = liter;
static const double dL = 1.e-1*liter;
static const double cL = 1.e-2*liter;
static const double mL = 1.e-3*liter;
static const double m = meter;
static const double m2 = meter2;
static const double m3 = meter3;
@@ -122,7 +140,7 @@ static const double pc = parsec;
//
static const double radian = 1.;
static const double milliradian = 1.e-3*radian;
static const double degree = (3.14159265358979323846/180.0)*radian;
static const double degree = (pi/180.0)*radian;
static const double steradian = 1.;
@@ -174,7 +192,7 @@ static const double nanoampere = 1.e-9*ampere;
// Electric charge [Q]
//
static const double coulomb = ampere*second;
static const double e_SI = 1.60217733e-19; // positron charge in coulomb
static const double e_SI = 1.602176487e-19; // positron charge in coulomb
static const double eplus = e_SI*coulomb ; // positron charge
//
@@ -269,11 +287,26 @@ static const double mole = 1.;
//
static const double becquerel = 1./second ;
static const double curie = 3.7e+10 * becquerel;
static const double kilobecquerel = 1.e+3*becquerel;
static const double megabecquerel = 1.e+6*becquerel;
static const double gigabecquerel = 1.e+9*becquerel;
static const double millicurie = 1.e-3*curie;
static const double microcurie = 1.e-6*curie;
static const double Bq = becquerel;
static const double kBq = kilobecquerel;
static const double MBq = megabecquerel;
static const double GBq = gigabecquerel;
static const double Ci = curie;
static const double mCi = millicurie;
static const double uCi = microcurie;
//
// Absorbed dose [L^2][T^-2]
//
static const double gray = joule/kilogram ;
static const double gray = joule/kilogram;
static const double kilogray = 1.e+3*gray;
static const double milligray = 1.e-3*gray;
static const double microgray = 1.e-6*gray;
//
// Luminous intensity [I]
@@ -297,4 +330,5 @@ static const double perCent = 0.01 ;
static const double perThousand = 0.001;
static const double perMillion = 0.000001;
#endif /* G4UNITSTEST_HH */
#endif /* SI_SYSTEM_OF_UNITS_HH */
+69 -68
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4String.icc 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4String.icc 92939 2015-09-22 07:24:30Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -37,91 +37,91 @@
// G4SubString
// **************************************************************
G4SubString::G4SubString(const G4SubString& str)
inline G4SubString::G4SubString(const G4SubString& str)
: mystring(str.mystring), mystart(str.mystart), extent(str.extent)
{
}
G4SubString::G4SubString(G4String& str, str_size siz, str_size e)
inline G4SubString::G4SubString(G4String& str, str_size siz, str_size e)
: mystring(&str),mystart(siz),extent(e)
{
}
G4SubString& G4SubString::operator=(const G4String& str)
inline G4SubString& G4SubString::operator=(const G4String& str)
{
return operator=(str);
}
G4SubString& G4SubString::operator=(const G4SubString& str)
inline G4SubString& G4SubString::operator=(const G4SubString& str)
{
mystring->replace(mystart,extent,str.mystring->data(),str.length());
extent=str.length();
return *this;
}
G4SubString& G4SubString::operator=(const char* str)
inline G4SubString& G4SubString::operator=(const char* str)
{
mystring->replace(mystart,extent,str,strlen(str));
extent=strlen(str);
return *this;
}
char& G4SubString::operator()(str_size i)
inline char& G4SubString::operator()(str_size i)
{
return mystring->operator[](mystart+i);
}
char G4SubString::operator()(str_size i) const
inline char G4SubString::operator()(str_size i) const
{
return mystring->operator[](mystart+i);
}
char& G4SubString::operator[](str_size i)
inline char& G4SubString::operator[](str_size i)
{
return mystring->operator[](mystart+i);
}
char G4SubString::operator[](str_size i) const
inline char G4SubString::operator[](str_size i) const
{
return mystring->operator[](mystart+i);
}
G4int G4SubString::operator!() const
inline G4int G4SubString::operator!() const
{
return (extent==0) ? 1 : 0;
}
G4bool G4SubString::operator==(const G4String& str) const
inline G4bool G4SubString::operator==(const G4String& str) const
{
return (mystring->find(str,mystart,extent) != std::string::npos);
}
G4bool G4SubString::operator==(const char* str) const
inline G4bool G4SubString::operator==(const char* str) const
{
return (mystring->find(str,mystart,extent) != std::string::npos);
}
G4bool G4SubString::operator!=(const G4String& str) const
inline G4bool G4SubString::operator!=(const G4String& str) const
{
return (mystring->find(str,mystart,extent) == std::string::npos);
}
G4bool G4SubString::operator!=(const char* str) const
inline G4bool G4SubString::operator!=(const char* str) const
{
return (mystring->find(str,mystart,extent) == std::string::npos);
}
str_size G4SubString::length() const
inline str_size G4SubString::length() const
{
return extent;
}
str_size G4SubString::start() const
inline str_size G4SubString::start() const
{
return mystart;
}
G4bool G4SubString::isNull() const
inline G4bool G4SubString::isNull() const
{
return (extent==0);
}
@@ -130,15 +130,15 @@ G4bool G4SubString::isNull() const
// G4String
// **************************************************************
G4String::G4String () {}
inline G4String::G4String () {}
G4String::G4String ( const char * astring )
inline G4String::G4String ( const char * astring )
: std_string ( astring ) {}
G4String::G4String ( const char * astring, str_size len )
inline G4String::G4String ( const char * astring, str_size len )
: std_string ( astring, len ) {}
G4String::G4String ( char ch )
inline G4String::G4String ( char ch )
{
char str[2];
str[0]=ch;
@@ -146,29 +146,29 @@ G4String::G4String ( char ch )
std_string::operator=(str);
}
G4String::G4String ( const G4String& str )
inline G4String::G4String ( const G4String& str )
: std_string(str) {}
G4String::G4String ( const G4SubString& str )
inline G4String::G4String ( const G4SubString& str )
: std_string(*(str.mystring),str.mystart,str.extent) {}
G4String::G4String ( const std::string& str )
inline G4String::G4String ( const std::string& str )
: std_string(str) {}
G4String& G4String::operator=(const G4String& str)
inline G4String& G4String::operator=(const G4String& str)
{
if (&str == this) { return *this; }
std_string::operator=(str);
return *this;
}
G4String& G4String::operator=(const std::string& str)
inline G4String& G4String::operator=(const std::string& str)
{
std_string::operator=(str);
return *this;
}
G4String& G4String::operator=(const char* str)
inline G4String& G4String::operator=(const char* str)
{
std_string::operator=(str);
return *this;
@@ -179,67 +179,68 @@ G4String& G4String::operator=(const char* str)
// one returned by the original RW function.
// Users should not rely on the specific return value.
//
char G4String::operator () (str_size i) const
inline char G4String::operator () (str_size i) const
{
return operator[](i);
}
char& G4String::operator () (str_size i)
inline char& G4String::operator () (str_size i)
{
return std_string::operator[](i);
}
G4String& G4String::operator+=(const G4SubString& str)
inline G4String& G4String::operator+=(const G4SubString& str)
{
G4String tmp(str);
std_string::operator+=(tmp);
return *this;
}
G4String& G4String::operator+=(const char* str)
inline G4String& G4String::operator+=(const char* str)
{
std_string::operator+=(str);
return *this;
}
G4String& G4String::operator+=(const std::string& str)
inline G4String& G4String::operator+=(const std::string& str)
{
std_string::operator+=(str);
return *this;
}
G4String& G4String::operator+=(const char& ch)
inline G4String& G4String::operator+=(const char& ch)
{
std_string::operator+=(ch);
return *this;
}
G4bool G4String::operator==(const G4String& str) const
inline G4bool G4String::operator==(const G4String& str) const
{
if (length() != str.length()) return false;
return (std_string::compare(str) == 0);
}
inline G4bool G4String::operator==(const char* str) const
{
return (std_string::compare(str) == 0);
}
G4bool G4String::operator==(const char* str) const
{
return (std_string::compare(str) == 0);
}
G4bool G4String::operator!=(const G4String& str) const
inline G4bool G4String::operator!=(const G4String& str) const
{
return !(*this == str);
}
G4bool G4String::operator!=(const char* str) const
inline G4bool G4String::operator!=(const char* str) const
{
return !(*this == str);
}
G4String::operator const char*() const
inline G4String::operator const char*() const
{
return c_str();
}
G4int G4String::strcasecompare(const char* s1, const char* s2) const
inline G4int G4String::strcasecompare(const char* s1, const char* s2) const
{
char* buf1 = new char[strlen(s1)+1];
char* buf2 = new char[strlen(s2)+1];
@@ -255,30 +256,30 @@ G4int G4String::strcasecompare(const char* s1, const char* s2) const
return res;
}
G4int G4String::compareTo(const char* str, caseCompare mode) const
inline G4int G4String::compareTo(const char* str, caseCompare mode) const
{
return (mode==exact) ? strcmp(c_str(),str)
: strcasecompare(c_str(),str);
}
G4int G4String::compareTo(const G4String& str, caseCompare mode) const
inline G4int G4String::compareTo(const G4String& str, caseCompare mode) const
{
return compareTo(str.c_str(), mode);
}
G4String& G4String::prepend (const char* str)
inline G4String& G4String::prepend (const char* str)
{
insert(0,str);
return *this;
}
G4String& G4String::append(const G4String& str)
inline G4String& G4String::append(const G4String& str)
{
std_string::operator+=(str);
return *this;
}
std::istream&
inline std::istream&
G4String::readLine (std::istream& strm, G4bool skipWhite)
{
char tmp[1024];
@@ -296,52 +297,52 @@ G4String::readLine (std::istream& strm, G4bool skipWhite)
return strm;
}
G4String& G4String::replace (unsigned int start, unsigned int nbytes,
inline G4String& G4String::replace (unsigned int start, unsigned int nbytes,
const char* buff, unsigned int n2 )
{
std_string::replace ( start, nbytes, buff, n2 );
return *this;
}
G4String& G4String::replace(str_size pos, str_size n, const char* str)
inline G4String& G4String::replace(str_size pos, str_size n, const char* str)
{
std_string::replace(pos,n,str);
return *this;
}
G4String& G4String::remove(str_size n)
inline G4String& G4String::remove(str_size n)
{
if(n<size()) { erase(n,size()-n); }
return *this;
}
G4String& G4String::remove(str_size pos, str_size N)
inline G4String& G4String::remove(str_size pos, str_size N)
{
erase(pos,N+pos);
return *this;
}
G4int G4String::first(char ch) const
inline G4int G4String::first(char ch) const
{
return find(ch);
}
G4int G4String::last(char ch) const
inline G4int G4String::last(char ch) const
{
return rfind(ch);
}
G4bool G4String::contains(const std::string& str) const
inline G4bool G4String::contains(const std::string& str) const
{
return (std_string::find(str) != std_string::npos);
}
G4bool G4String::contains(char ch) const
inline G4bool G4String::contains(char ch) const
{
return (std_string::find(ch) != std_string::npos);
}
G4String G4String::strip (G4int strip_Type, char ch)
inline G4String G4String::strip (G4int strip_Type, char ch)
{
G4String retVal = *this;
if(length()==0) { return retVal; }
@@ -379,7 +380,7 @@ G4String G4String::strip (G4int strip_Type, char ch)
return retVal;
}
void G4String::toLower ()
inline void G4String::toLower ()
{
for (str_size i=0; i<size();i++)
{
@@ -389,7 +390,7 @@ void G4String::toLower ()
}
}
void G4String::toUpper ()
inline void G4String::toUpper ()
{
for (str_size i=0; i<size();i++)
{
@@ -399,40 +400,40 @@ void G4String::toUpper ()
}
}
G4bool G4String::isNull() const
inline G4bool G4String::isNull() const
{
return empty ();
}
// "caseCompare" optional parameter is NOT implemented !
//
str_size G4String::index( const G4String& str, str_size ln,
inline str_size G4String::index( const G4String& str, str_size ln,
str_size st, G4String::caseCompare ) const
{
return std_string::find( str.c_str(), st, ln );
}
str_size G4String::index (const char* str, G4int pos) const
inline str_size G4String::index (const char* str, G4int pos) const
{
return std_string::find(str,pos);
}
str_size G4String::index (char ch, G4int pos) const
inline str_size G4String::index (char ch, G4int pos) const
{
return std_string::find(ch,pos);
}
G4SubString G4String::operator()(str_size start, str_size extent)
inline G4SubString G4String::operator()(str_size start, str_size extent)
{
return G4SubString(*this,start,extent);
}
const char* G4String::data() const
inline const char* G4String::data() const
{
return c_str();
}
unsigned int G4String::hash( caseCompare ) const
inline unsigned int G4String::hash( caseCompare ) const
{
const char* str=c_str();
unsigned long h = 0;
@@ -442,7 +443,7 @@ unsigned int G4String::hash( caseCompare ) const
return str_size(h);
}
unsigned int G4String::stlhash() const
inline unsigned int G4String::stlhash() const
{
const char* str=c_str();
unsigned long h = 0;
@@ -56,6 +56,11 @@ using CLHEP::mm3;
using CLHEP::cm;
using CLHEP::cm2;
using CLHEP::cm3;
using CLHEP::liter;
using CLHEP::L;
using CLHEP::dL;
using CLHEP::cL;
using CLHEP::mL;
using CLHEP::m;
using CLHEP::m2;
using CLHEP::m3;
@@ -40,6 +40,15 @@
#include "G4Types.hh"
// Macro to put current thread to sleep
//
#if defined(WIN32)
#define G4THREADSLEEP( tick ) { Sleep(tick); }
#else
#include <unistd.h> // needed for sleep()
#define G4THREADSLEEP( tick ) { sleep(tick); }
#endif
#if defined(G4MULTITHREADED)
//===============================
// Multi-threaded build
@@ -67,7 +76,8 @@
#define G4MUTEXLOCK pthread_mutex_lock
#define G4MUTEXUNLOCK pthread_mutex_unlock
// Macro to iniaizlie a Mutex
// Macro to initialize a Mutex
//
#define G4MUTEXINIT(mutex) pthread_mutex_init( &mutex , NULL);
#define G4MUTEXDESTROY(mutex) pthread_mutex_destroy( &mutex );
@@ -82,10 +92,12 @@
}
// Macro to join thread
//
#define G4THREADJOIN( worker ) pthread_join( worker , NULL)
// Macro to retrieve caller thread
#define G4THREADSELF pthread_self
// Macro to retrieve caller thread
//
#define G4THREADSELF pthread_self
// Some useful types
//
@@ -193,6 +205,7 @@ namespace G4Threading
G4int G4GetNumberOfCores();
G4int G4GetThreadId();
G4bool IsWorkerThread();
G4bool IsMasterThread();
void G4SetThreadId( G4int aNewValue );
G4bool G4SetPinAffinity( G4int idx , G4Thread& at);
void SetMultithreadedApplication(G4bool value);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Version.hh 87485 2014-12-05 09:54:59Z gcosmo $
// $Id: G4Version.hh 94738 2015-12-04 11:23:42Z gcosmo $
// GEANT4 tag $Name:$
//
// Version information
@@ -46,11 +46,11 @@
// |--> patch number
#ifndef G4VERSION_NUMBER
#define G4VERSION_NUMBER 1010
#define G4VERSION_NUMBER 1020
#endif
#ifndef G4VERSION_TAG
#define G4VERSION_TAG "$Name: geant4-10-01 $"
#define G4VERSION_TAG "$Name: geant4-10-02 $"
#endif
// as variables
@@ -58,10 +58,10 @@
#include "G4String.hh"
#ifdef G4MULTITHREADED
static const G4String G4Version = "$Name: geant4-10-01 [MT]$";
static const G4String G4Version = "$Name: geant4-10-02 [MT]$";
#else
static const G4String G4Version = "$Name: geant4-10-01 $";
static const G4String G4Version = "$Name: geant4-10-02 $";
#endif
static const G4String G4Date = "(5-December-2014)";
static const G4String G4Date = "(4-December-2015)";
#endif
+7 -2
View File
@@ -44,7 +44,7 @@
# define G4ThreadLocal __thread
#endif
#elif ( (defined(__linux__) || defined(__MACH__)) && \
defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__<9 )
!defined(__INTEL_COMPILER) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__<9 )
#if defined (G4USE_STD11)
# define G4ThreadLocalStatic static __thread
# define G4ThreadLocal thread_local
@@ -53,7 +53,7 @@
# define G4ThreadLocal __thread
#endif
#elif ( (defined(__linux__) || defined(__MACH__)) && \
defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=9 )
!defined(__INTEL_COMPILER) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=9 )
#if defined (G4USE_STD11)
# define G4ThreadLocalStatic static thread_local
# define G4ThreadLocal thread_local
@@ -63,8 +63,13 @@
#endif
#elif ( (defined(__linux__) || defined(__MACH__)) && \
defined(__INTEL_COMPILER) )
#if (defined (G4USE_STD11) && __INTEL_COMPILER>=1500)
# define G4ThreadLocalStatic static thread_local
# define G4ThreadLocal thread_local
#else
# define G4ThreadLocalStatic static __thread
# define G4ThreadLocal __thread
#endif
#elif defined(_AIX)
#if defined (G4USE_STD11)
# define G4ThreadLocalStatic static thread_local