Import Geant4 11.2.0.beta source tree
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
// and so on, *before* creating the run-manager. After the run-manager
|
||||
// has been created, one should disable the signals:
|
||||
//
|
||||
// G4Backtrace::Disable(G4BackTrace::DefaultSignals());
|
||||
// G4Backtrace::Disable(G4Backtrace::DefaultSignals());
|
||||
//
|
||||
// Additionally, at runtime, the environment variable "G4BACKTRACE" can
|
||||
// be set to select a specific set of signals or none, e.g. in bash:
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#ifndef G4BUFFERCOUTDESTINATION_HH
|
||||
#define G4BUFFERCOUTDESTINATION_HH
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include "G4coutDestination.hh"
|
||||
@@ -48,32 +49,32 @@ class G4BuffercoutDestination : public G4coutDestination
|
||||
explicit G4BuffercoutDestination(std::size_t maxSize = 0);
|
||||
~G4BuffercoutDestination() override;
|
||||
|
||||
G4int ReceiveG4debug(const G4String& msg) override;
|
||||
G4int ReceiveG4cout(const G4String& msg) override;
|
||||
G4int ReceiveG4cerr(const G4String& msg) override;
|
||||
|
||||
// Flush buffer to std output
|
||||
virtual G4int FlushG4debug();
|
||||
// Flush buffer to std output
|
||||
virtual G4int FlushG4cout();
|
||||
// Flush buffer to std error
|
||||
virtual G4int FlushG4cerr();
|
||||
// Flsuh both buffers
|
||||
|
||||
|
||||
// Flush all buffers
|
||||
virtual void Finalize();
|
||||
|
||||
// Set maximum size of buffer, when buffer grows to specified size,
|
||||
// it will trigger flush. Dimension in char
|
||||
void SetMaxSize(std::size_t max) { m_maxSize = max; }
|
||||
void SetMaxSize(std::size_t max);
|
||||
std::size_t GetMaxSize() const { return m_maxSize; }
|
||||
std::size_t GetCurrentSizeOut() const { return m_currentSize_out; }
|
||||
std::size_t GetCurrentSizeErr() const { return m_currentSize_err; }
|
||||
|
||||
protected:
|
||||
void ResetCout();
|
||||
void ResetCerr();
|
||||
std::size_t m_maxSize = 0;
|
||||
|
||||
std::ostringstream m_buffer_out;
|
||||
std::ostringstream m_buffer_err;
|
||||
std::size_t m_currentSize_out = 0;
|
||||
std::size_t m_currentSize_err = 0;
|
||||
std::size_t m_maxSize = 0;
|
||||
class BufferImpl;
|
||||
std::unique_ptr<BufferImpl> m_buffer_dbg;
|
||||
std::unique_ptr<BufferImpl> m_buffer_out;
|
||||
std::unique_ptr<BufferImpl> m_buffer_err;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,6 +58,7 @@ class G4FilecoutDestination : public G4coutDestination
|
||||
// By default append to existing file
|
||||
void Close();
|
||||
|
||||
G4int ReceiveG4debug(const G4String& msg) override;
|
||||
G4int ReceiveG4cout(const G4String& msg) override;
|
||||
G4int ReceiveG4cerr(const G4String& msg) override;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class G4LockcoutDestination : public G4coutDestination
|
||||
public:
|
||||
G4LockcoutDestination() = default;
|
||||
~G4LockcoutDestination() override = default;
|
||||
G4int ReceiveG4debug(const G4String& msg) override;
|
||||
G4int ReceiveG4cout(const G4String& msg) override;
|
||||
G4int ReceiveG4cerr(const G4String& msg) override;
|
||||
};
|
||||
|
||||
@@ -47,6 +47,7 @@ class G4MasterForwardcoutDestination : public G4coutDestination
|
||||
G4MasterForwardcoutDestination() = default;
|
||||
|
||||
~G4MasterForwardcoutDestination() override = default;
|
||||
G4int ReceiveG4debug(const G4String& msg) override;
|
||||
G4int ReceiveG4cout(const G4String& msg) override;
|
||||
G4int ReceiveG4cerr(const G4String& msg) override;
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
// auto multi = new G4MulticoutDestination();
|
||||
// multi->push_back( G4coutDestinationUPtr( new MyCout1 ) );
|
||||
// multi->push_back( G4coutDestinationUPtr( new MyCout2 ) );
|
||||
// G4coutbuf.SetDestination( multi ); // or G4cerrbuf
|
||||
// G4iosSetDestination( multi ); // or G4cerrbuf
|
||||
|
||||
// ---------------- G4MulticoutDestination ----------------
|
||||
//
|
||||
@@ -67,6 +67,15 @@ class G4MulticoutDestination
|
||||
|
||||
// Forward call to contained destination. Note that the message may have
|
||||
// been modified by formatters attached to this
|
||||
G4int ReceiveG4debug(const G4String& msg) override
|
||||
{
|
||||
G4bool result = true;
|
||||
std::for_each(begin(), end(), [&](G4coutDestinationUPtr& e) {
|
||||
result &= (e->ReceiveG4debug_(msg) == 0);
|
||||
});
|
||||
return (result ? 0 : -1);
|
||||
}
|
||||
|
||||
G4int ReceiveG4cout(const G4String& msg) override
|
||||
{
|
||||
G4bool result = true;
|
||||
|
||||
@@ -1,329 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4SIunits
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// This file is a modified version of CLHEP SystemOfUnits.h
|
||||
// It is provided for checking the overall 'units coherence' in Geant4.
|
||||
// The basic units are those of the International System:
|
||||
//
|
||||
// meter
|
||||
// second
|
||||
// kilogram
|
||||
// ampere
|
||||
// degree kelvin
|
||||
// the amount of substance (mole)
|
||||
// luminous intensity (candela)
|
||||
// radian
|
||||
// steradian
|
||||
//
|
||||
// The SI numerical value of the positron charge is defined here,
|
||||
// as it is needed for conversion factor: positron charge = e_SI (coulomb)
|
||||
//
|
||||
// The others physical constants are defined in the CLHEP header file
|
||||
// for PhysicalConstants.
|
||||
|
||||
// Authors: M.Maire, S.Giani - 10.03.1999
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef SI_SYSTEM_OF_UNITS_HH
|
||||
#define SI_SYSTEM_OF_UNITS_HH 1
|
||||
|
||||
static constexpr double pi = 3.14159265358979323846;
|
||||
static constexpr double twopi = 2 * pi;
|
||||
static constexpr double halfpi = pi / 2;
|
||||
static constexpr double pi2 = pi * pi;
|
||||
//
|
||||
// Length [L]
|
||||
//
|
||||
static constexpr double meter = 1.;
|
||||
static constexpr double meter2 = meter * meter;
|
||||
static constexpr double meter3 = meter * meter * meter;
|
||||
|
||||
static constexpr double millimeter = 0.001 * meter;
|
||||
static constexpr double millimeter2 = millimeter * millimeter;
|
||||
static constexpr double millimeter3 = millimeter * millimeter * millimeter;
|
||||
|
||||
static constexpr double centimeter = 10. * millimeter;
|
||||
static constexpr double centimeter2 = centimeter * centimeter;
|
||||
static constexpr double centimeter3 = centimeter * centimeter * centimeter;
|
||||
|
||||
static constexpr double kilometer = 1000. * meter;
|
||||
static constexpr double kilometer2 = kilometer * kilometer;
|
||||
static constexpr double kilometer3 = kilometer * kilometer * kilometer;
|
||||
|
||||
static constexpr double parsec = 3.0856775807e+16 * meter;
|
||||
|
||||
static constexpr double micrometer = 1.e-6 * meter;
|
||||
static constexpr double nanometer = 1.e-9 * meter;
|
||||
static constexpr double angstrom = 1.e-10 * meter;
|
||||
static constexpr double fermi = 1.e-15 * meter;
|
||||
|
||||
static constexpr double barn = 1.e-28 * meter2;
|
||||
static constexpr double millibarn = 1.e-3 * barn;
|
||||
static constexpr double microbarn = 1.e-6 * barn;
|
||||
static constexpr double nanobarn = 1.e-9 * barn;
|
||||
static constexpr double picobarn = 1.e-12 * barn;
|
||||
|
||||
// symbols
|
||||
static constexpr double nm = nanometer;
|
||||
static constexpr double um = micrometer;
|
||||
|
||||
static constexpr double mm = millimeter;
|
||||
static constexpr double mm2 = millimeter2;
|
||||
static constexpr double mm3 = millimeter3;
|
||||
|
||||
static constexpr double cm = centimeter;
|
||||
static constexpr double cm2 = centimeter2;
|
||||
static constexpr double cm3 = centimeter3;
|
||||
|
||||
static constexpr double liter = 1.e+3 * cm3;
|
||||
static constexpr double L = liter;
|
||||
static constexpr double dL = 1.e-1 * liter;
|
||||
static constexpr double cL = 1.e-2 * liter;
|
||||
static constexpr double mL = 1.e-3 * liter;
|
||||
|
||||
static constexpr double m = meter;
|
||||
static constexpr double m2 = meter2;
|
||||
static constexpr double m3 = meter3;
|
||||
|
||||
static constexpr double km = kilometer;
|
||||
static constexpr double km2 = kilometer2;
|
||||
static constexpr double km3 = kilometer3;
|
||||
|
||||
static constexpr double pc = parsec;
|
||||
|
||||
//
|
||||
// Angle
|
||||
//
|
||||
static constexpr double radian = 1.;
|
||||
static constexpr double milliradian = 1.e-3 * radian;
|
||||
static constexpr double degree = (pi / 180.0) * radian;
|
||||
|
||||
static constexpr double steradian = 1.;
|
||||
|
||||
// symbols
|
||||
static constexpr double rad = radian;
|
||||
static constexpr double mrad = milliradian;
|
||||
static constexpr double sr = steradian;
|
||||
static constexpr double deg = degree;
|
||||
|
||||
//
|
||||
// Time [T]
|
||||
//
|
||||
static constexpr double second = 1.;
|
||||
static constexpr double nanosecond = 1.e-9 * second;
|
||||
static constexpr double millisecond = 1.e-3 * second;
|
||||
static constexpr double microsecond = 1.e-6 * second;
|
||||
static constexpr double picosecond = 1.e-12 * second;
|
||||
|
||||
static constexpr double minute = 60*second;
|
||||
static constexpr double hour = 60*minute;
|
||||
static constexpr double day = 24*hour;
|
||||
static constexpr double year = 365*day;
|
||||
|
||||
static constexpr double hertz = 1. / second;
|
||||
static constexpr double kilohertz = 1.e+3 * hertz;
|
||||
static constexpr double megahertz = 1.e+6 * hertz;
|
||||
|
||||
// symbols
|
||||
static constexpr double ns = nanosecond;
|
||||
static constexpr double s = second;
|
||||
static constexpr double ms = millisecond;
|
||||
static constexpr double us = microsecond;
|
||||
static constexpr double ps = picosecond;
|
||||
|
||||
//
|
||||
// Mass [E][T^2][L^-2]
|
||||
//
|
||||
static constexpr double kilogram = 1.;
|
||||
static constexpr double gram = 1.e-3 * kilogram;
|
||||
static constexpr double milligram = 1.e-3 * gram;
|
||||
|
||||
// symbols
|
||||
static constexpr double kg = kilogram;
|
||||
static constexpr double g = gram;
|
||||
static constexpr double mg = milligram;
|
||||
|
||||
//
|
||||
// Electric current [Q][T^-1]
|
||||
//
|
||||
static constexpr double ampere = 1.;
|
||||
static constexpr double milliampere = 1.e-3 * ampere;
|
||||
static constexpr double microampere = 1.e-6 * ampere;
|
||||
static constexpr double nanoampere = 1.e-9 * ampere;
|
||||
|
||||
//
|
||||
// Electric charge [Q]
|
||||
//
|
||||
static constexpr double coulomb = ampere * second;
|
||||
static constexpr double e_SI = 1.602176634e-19; // positron charge in coulomb
|
||||
static constexpr double eplus = e_SI * coulomb; // positron charge
|
||||
|
||||
//
|
||||
// Energy [E]
|
||||
//
|
||||
static constexpr double joule = kg * m * m / (s * s);
|
||||
|
||||
static constexpr double electronvolt = e_SI * joule;
|
||||
static constexpr double kiloelectronvolt = 1.e+3 * electronvolt;
|
||||
static constexpr double megaelectronvolt = 1.e+6 * electronvolt;
|
||||
static constexpr double gigaelectronvolt = 1.e+9 * electronvolt;
|
||||
static constexpr double teraelectronvolt = 1.e+12 * electronvolt;
|
||||
static constexpr double petaelectronvolt = 1.e+15 * electronvolt;
|
||||
static constexpr double millielectronvolt = 1.e-3 * electronvolt;
|
||||
|
||||
// symbols
|
||||
static constexpr double MeV = megaelectronvolt;
|
||||
static constexpr double eV = electronvolt;
|
||||
static constexpr double keV = kiloelectronvolt;
|
||||
static constexpr double GeV = gigaelectronvolt;
|
||||
static constexpr double TeV = teraelectronvolt;
|
||||
static constexpr double PeV = petaelectronvolt;
|
||||
|
||||
//
|
||||
// Power [E][T^-1]
|
||||
//
|
||||
static constexpr double watt = joule / second; // watt = 6.24150 e+3 * MeV/ns
|
||||
|
||||
//
|
||||
// Force [E][L^-1]
|
||||
//
|
||||
static constexpr double newton =
|
||||
joule / meter; // newton = 6.24150 e+9 * MeV/mm
|
||||
|
||||
//
|
||||
// Pressure [E][L^-3]
|
||||
//
|
||||
#define pascal hep_pascal // a trick to avoid warnings
|
||||
static constexpr double hep_pascal =
|
||||
newton / m2; // pascal = 6.24150 e+3 * MeV/mm3
|
||||
static constexpr double bar = 100000 * pascal; // bar = 6.24150 e+8 * MeV/mm3
|
||||
static constexpr double atmosphere =
|
||||
101325 * pascal; // atm = 6.32420 e+8 * MeV/mm3
|
||||
|
||||
//
|
||||
// Electric potential [E][Q^-1]
|
||||
//
|
||||
static constexpr double megavolt = megaelectronvolt / eplus;
|
||||
static constexpr double kilovolt = 1.e-3 * megavolt;
|
||||
static constexpr double volt = 1.e-6 * megavolt;
|
||||
|
||||
//
|
||||
// Electric resistance [E][T][Q^-2]
|
||||
//
|
||||
static constexpr double ohm =
|
||||
volt / ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
|
||||
|
||||
//
|
||||
// Electric capacitance [Q^2][E^-1]
|
||||
//
|
||||
static constexpr double farad =
|
||||
coulomb / volt; // farad = 6.24150e+24 * eplus/Megavolt
|
||||
static constexpr double millifarad = 1.e-3 * farad;
|
||||
static constexpr double microfarad = 1.e-6 * farad;
|
||||
static constexpr double nanofarad = 1.e-9 * farad;
|
||||
static constexpr double picofarad = 1.e-12 * farad;
|
||||
|
||||
//
|
||||
// Magnetic Flux [T][E][Q^-1]
|
||||
//
|
||||
static constexpr double weber = volt * second; // weber = 1000*megavolt*ns
|
||||
|
||||
//
|
||||
// Magnetic Field [T][E][Q^-1][L^-2]
|
||||
//
|
||||
static constexpr double tesla =
|
||||
volt * second / meter2; // tesla =0.001*megavolt*ns/mm2
|
||||
|
||||
static constexpr double gauss = 1.e-4 * tesla;
|
||||
static constexpr double kilogauss = 1.e-1 * tesla;
|
||||
|
||||
//
|
||||
// Inductance [T^2][E][Q^-2]
|
||||
//
|
||||
static constexpr double henry =
|
||||
weber / ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2
|
||||
|
||||
//
|
||||
// Temperature
|
||||
//
|
||||
static constexpr double kelvin = 1.;
|
||||
|
||||
//
|
||||
// Amount of substance
|
||||
//
|
||||
static constexpr double mole = 1.;
|
||||
|
||||
//
|
||||
// Activity [T^-1]
|
||||
//
|
||||
static constexpr double becquerel = 1. / second;
|
||||
static constexpr double curie = 3.7e+10 * becquerel;
|
||||
static constexpr double kilobecquerel = 1.e+3 * becquerel;
|
||||
static constexpr double megabecquerel = 1.e+6 * becquerel;
|
||||
static constexpr double gigabecquerel = 1.e+9 * becquerel;
|
||||
static constexpr double millicurie = 1.e-3 * curie;
|
||||
static constexpr double microcurie = 1.e-6 * curie;
|
||||
static constexpr double Bq = becquerel;
|
||||
static constexpr double kBq = kilobecquerel;
|
||||
static constexpr double MBq = megabecquerel;
|
||||
static constexpr double GBq = gigabecquerel;
|
||||
static constexpr double Ci = curie;
|
||||
static constexpr double mCi = millicurie;
|
||||
static constexpr double uCi = microcurie;
|
||||
|
||||
//
|
||||
// Absorbed dose [L^2][T^-2]
|
||||
//
|
||||
static constexpr double gray = joule / kilogram;
|
||||
static constexpr double kilogray = 1.e+3 * gray;
|
||||
static constexpr double milligray = 1.e-3 * gray;
|
||||
static constexpr double microgray = 1.e-6 * gray;
|
||||
|
||||
//
|
||||
// Luminous intensity [I]
|
||||
//
|
||||
static constexpr double candela = 1.;
|
||||
|
||||
//
|
||||
// Luminous flux [I]
|
||||
//
|
||||
static constexpr double lumen = candela * steradian;
|
||||
|
||||
//
|
||||
// Illuminance [I][L^-2]
|
||||
//
|
||||
static constexpr double lux = lumen / meter2;
|
||||
|
||||
//
|
||||
// Miscellaneous
|
||||
//
|
||||
static constexpr double perCent = 0.01;
|
||||
static constexpr double perThousand = 0.001;
|
||||
static constexpr double perMillion = 0.000001;
|
||||
|
||||
#endif
|
||||
@@ -30,21 +30,36 @@
|
||||
#ifndef G4VERSION_HH
|
||||
#define G4VERSION_HH 1
|
||||
|
||||
// Numbering rule for "G4VERSION_NUMBER":
|
||||
// - The number is consecutive (i.e. 711) as an integer.
|
||||
// - The meaning of each digit is as follows;
|
||||
/// @def G4VERSION_NUMBER
|
||||
/// @brief Integral value representing the current Geant4 version
|
||||
///
|
||||
/// Numbering rule for "G4VERSION_NUMBER":
|
||||
/// - The number is consecutive (i.e. 711) as an integer.
|
||||
/// - The meaning of each digit is as follows;
|
||||
//
|
||||
// 711
|
||||
// |--> major version number
|
||||
// |--> minor version number
|
||||
// |--> patch number
|
||||
|
||||
/// 711
|
||||
/// |--> major version number (up to two digits)
|
||||
/// |--> minor version number (single digit)
|
||||
/// |--> patch number (single digit)
|
||||
///
|
||||
#ifndef G4VERSION_NUMBER
|
||||
#define G4VERSION_NUMBER 1112
|
||||
#define G4VERSION_NUMBER 1120
|
||||
#endif
|
||||
|
||||
/// @def G4VERSION_REFERENCE_TAG
|
||||
/// @brief Number indicating current development cycle
|
||||
///
|
||||
/// Can take values between -1 and 11. A value of -1 indicates a release, whose version
|
||||
/// can be read from @ref `G4VERSION_NUMBER`. Values 0-11 indicate an in development version,
|
||||
/// the value being incremented on each reference tag and thus corresponding to the month number
|
||||
/// (taking December as 0, the start of new development of the next major/minor release).
|
||||
///
|
||||
#ifndef G4VERSION_REFERENCE_TAG
|
||||
#define G4VERSION_REFERENCE_TAG -1
|
||||
#endif
|
||||
|
||||
#ifndef G4VERSION_TAG
|
||||
#define G4VERSION_TAG "$Name: geant4-11-01-patch-02 $"
|
||||
#define G4VERSION_TAG "$Name: geant4-11-02-beta-01 $"
|
||||
#endif
|
||||
|
||||
// as variables
|
||||
@@ -53,10 +68,10 @@
|
||||
#include "G4Types.hh"
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
static const G4String G4Version = "$Name: geant4-11-01-patch-02 [MT]$";
|
||||
static const G4String G4Version = "$Name: geant4-11-02-beta-01 [MT]$";
|
||||
#else
|
||||
static const G4String G4Version = "$Name: geant4-11-01-patch-02 $";
|
||||
static const G4String G4Version = "$Name: geant4-11-02-beta-01 $";
|
||||
#endif
|
||||
static const G4String G4Date = "(15-June-2023)";
|
||||
static const G4String G4Date = "(30-June-2023)";
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,11 +58,19 @@ class G4coutDestination
|
||||
// anymore and discarded
|
||||
//
|
||||
using Transformer = std::function<G4bool(G4String&)>;
|
||||
|
||||
void AddDebugTransformer(const Transformer& t)
|
||||
{
|
||||
transformersDebug.push_back(t);
|
||||
}
|
||||
void AddDebugTransformer(Transformer&& t) { transformersDebug.push_back(t); }
|
||||
|
||||
void AddCoutTransformer(const Transformer& t)
|
||||
{
|
||||
transformersCout.push_back(t);
|
||||
}
|
||||
void AddCoutTransformer(Transformer&& t) { transformersCout.push_back(t); }
|
||||
|
||||
void AddCerrTransformer(const Transformer& t)
|
||||
{
|
||||
transformersCerr.push_back(t);
|
||||
@@ -70,12 +78,16 @@ class G4coutDestination
|
||||
void AddCerrTransformer(Transformer&& t) { transformersCerr.push_back(t); }
|
||||
virtual void ResetTransformers();
|
||||
|
||||
virtual G4int ReceiveG4debug(const G4String& msg);
|
||||
virtual G4int ReceiveG4cout(const G4String& msg);
|
||||
virtual G4int ReceiveG4cerr(const G4String& msg);
|
||||
// Derived class implements here handling of message.
|
||||
// For example, streaming on std::cout or file.
|
||||
// Return 0 for success, -1 otherwise
|
||||
|
||||
// Called by G4debug stream to handle log message
|
||||
G4int ReceiveG4debug_(const G4String& msg);
|
||||
|
||||
G4int ReceiveG4cout_(const G4String& msg);
|
||||
// Method called by G4strbuf when need to handle a message
|
||||
|
||||
@@ -88,7 +100,7 @@ class G4coutDestination
|
||||
// For MT: if master G4coutDestination derived class wants to
|
||||
// intercept the thread outputs, derived class should set this pointer.
|
||||
// Needed for some G4UIsession like GUIs
|
||||
|
||||
std::vector<Transformer> transformersDebug;
|
||||
std::vector<Transformer> transformersCout;
|
||||
std::vector<Transformer> transformersCerr;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#include "G4String.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4strstreambuf.hh"
|
||||
#include "G4coutDestination.hh"
|
||||
|
||||
namespace G4coutFormatters
|
||||
{
|
||||
|
||||
@@ -36,15 +36,20 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class G4coutDestination;
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
|
||||
extern G4GLOB_DLL std::ostream*& _G4debug_p();
|
||||
extern G4GLOB_DLL std::ostream*& _G4cout_p();
|
||||
extern G4GLOB_DLL std::ostream*& _G4cerr_p();
|
||||
# define G4debug (*_G4debug_p())
|
||||
# define G4cout (*_G4cout_p())
|
||||
# define G4cerr (*_G4cerr_p())
|
||||
|
||||
#else // Sequential
|
||||
|
||||
extern G4GLOB_DLL std::ostream G4debug;
|
||||
extern G4GLOB_DLL std::ostream G4cout;
|
||||
extern G4GLOB_DLL std::ostream G4cerr;
|
||||
|
||||
@@ -53,6 +58,11 @@ extern G4GLOB_DLL std::ostream G4cerr;
|
||||
void G4iosInitialization();
|
||||
void G4iosFinalization();
|
||||
|
||||
// Redirect messages sent to G4cout etc to this destination
|
||||
// Callee retains ownership of the destination pointer and must call
|
||||
// this function again with `nullptr` on destination destruction.
|
||||
void G4iosSetDestination(G4coutDestination* sink);
|
||||
|
||||
#define G4cin std::cin
|
||||
#define G4endl std::endl
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4strstreambuf
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Buffer for cout/cerr streaming
|
||||
|
||||
// Authors: H.Yoshida, M.Nagamatu - November 1998
|
||||
// Revisions: G.Cosmo, 1998-2013
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4STRSTREAMBUF_HH
|
||||
#define G4STRSTREAMBUF_HH 1
|
||||
|
||||
#include <streambuf>
|
||||
|
||||
#include "G4coutDestination.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4strstreambuf;
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
|
||||
extern G4GLOB_DLL G4strstreambuf*& _G4coutbuf_p();
|
||||
extern G4GLOB_DLL G4strstreambuf*& _G4cerrbuf_p();
|
||||
# define G4coutbuf (*_G4coutbuf_p())
|
||||
# define G4cerrbuf (*_G4cerrbuf_p())
|
||||
|
||||
#else // Sequential
|
||||
|
||||
extern G4GLOB_DLL G4strstreambuf G4coutbuf;
|
||||
extern G4GLOB_DLL G4strstreambuf G4cerrbuf;
|
||||
|
||||
#endif
|
||||
|
||||
class G4strstreambuf : public std::basic_streambuf<char>
|
||||
{
|
||||
public:
|
||||
G4strstreambuf();
|
||||
~G4strstreambuf() override;
|
||||
|
||||
G4int overflow(G4int c = EOF) override;
|
||||
G4int sync() override;
|
||||
|
||||
#ifdef WIN32
|
||||
virtual G4int underflow();
|
||||
#endif
|
||||
|
||||
void SetDestination(G4coutDestination* dest);
|
||||
inline G4coutDestination* GetDestination() const;
|
||||
inline G4int ReceiveString();
|
||||
|
||||
private:
|
||||
char* buffer = nullptr;
|
||||
G4int count = 0, size = 0;
|
||||
G4coutDestination* destination = nullptr;
|
||||
|
||||
// hidden...
|
||||
G4strstreambuf(const G4strstreambuf&);
|
||||
G4strstreambuf& operator=(const G4strstreambuf&);
|
||||
};
|
||||
|
||||
#include "G4strstreambuf.icc"
|
||||
|
||||
#endif
|
||||
@@ -1,139 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4strstreambuf inline methods implementation
|
||||
//
|
||||
// Authors: H.Yoshida, M.Nagamatu - November 1998
|
||||
// Revisions: G.Cosmo, 1998-2013
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4strstreambuf::G4strstreambuf()
|
||||
{
|
||||
size = 4095;
|
||||
buffer = new char[size + 1];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4strstreambuf::~G4strstreambuf()
|
||||
{
|
||||
// flushing buffer...
|
||||
// std::cout is used because destination object may not be alive.
|
||||
if(count != 0)
|
||||
{
|
||||
buffer[count] = '\0';
|
||||
std::cout << buffer;
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4strstreambuf::G4strstreambuf(const G4strstreambuf& right)
|
||||
: std::basic_streambuf<char>() // NOLINT(readability-redundant-member-init)
|
||||
, buffer(right.buffer)
|
||||
, count(right.count)
|
||||
, size(right.size)
|
||||
, destination(right.destination)
|
||||
{}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4strstreambuf& G4strstreambuf::operator=(const G4strstreambuf& right)
|
||||
{
|
||||
if(&right == this)
|
||||
return *this;
|
||||
|
||||
destination = right.destination;
|
||||
buffer = right.buffer;
|
||||
count = right.count;
|
||||
size = right.size;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4int G4strstreambuf::overflow(G4int c)
|
||||
{
|
||||
G4int result = 0;
|
||||
if(count >= size)
|
||||
result = sync();
|
||||
|
||||
buffer[count] = (char)c;
|
||||
count++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4int G4strstreambuf::sync()
|
||||
{
|
||||
buffer[count] = '\0';
|
||||
count = 0;
|
||||
return ReceiveString();
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// --------------------------------------------------------------------
|
||||
inline G4int G4strstreambuf::underflow() { return 0; }
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline void G4strstreambuf::SetDestination(G4coutDestination* dest)
|
||||
{
|
||||
destination = dest;
|
||||
}
|
||||
|
||||
inline G4coutDestination* G4strstreambuf::GetDestination() const
|
||||
{
|
||||
return destination;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
inline G4int G4strstreambuf::ReceiveString()
|
||||
{
|
||||
G4String stringToSend(buffer);
|
||||
G4int result = 0;
|
||||
|
||||
if(this == &G4coutbuf && destination != nullptr)
|
||||
{
|
||||
result = destination->ReceiveG4cout_(stringToSend);
|
||||
}
|
||||
else if(this == &G4cerrbuf && destination != nullptr)
|
||||
{
|
||||
result = destination->ReceiveG4cerr_(stringToSend);
|
||||
}
|
||||
else if(this == &G4coutbuf && destination == nullptr)
|
||||
{
|
||||
std::cout << stringToSend << std::flush;
|
||||
result = 0;
|
||||
}
|
||||
else if(this == &G4cerrbuf && destination == nullptr)
|
||||
{
|
||||
std::cerr << stringToSend << std::flush;
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user