Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -23,78 +23,73 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4coutDestination
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// G4coutDestination.hh
|
||||
//
|
||||
// Cout/cerr buffer containers
|
||||
|
||||
// Authors: H.Yoshida, M.Nagamatu - November 1998
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4COUTDESTINATION_HH
|
||||
#define G4COUTDESTINATION_HH
|
||||
#define G4COUTDESTINATION_HH 1
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
class G4coutDestination
|
||||
{
|
||||
public:
|
||||
public:
|
||||
G4coutDestination() = default;
|
||||
virtual ~G4coutDestination();
|
||||
// Note: limitation on ICC for MIC cannot use 'default'
|
||||
|
||||
G4coutDestination() = default;
|
||||
virtual ~G4coutDestination();
|
||||
// Note: limitation on ICC for MIC cannot use 'default';
|
||||
// The type of the functions defining a transformation of the message.
|
||||
// The function manipulates the input message, for example, to add a
|
||||
// prefix:
|
||||
// G4coutDestination::AddCoutTransformer(
|
||||
// [](G4String& msg) -> G4bool { msg="PREFIX "+msg; return true; }
|
||||
// );
|
||||
// Function should return false if message should not be processed
|
||||
// anymore and discarded
|
||||
//
|
||||
using Transformer = std::function<G4bool(G4String&)>;
|
||||
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);
|
||||
}
|
||||
void AddCerrTransformer(Transformer&& t) { transformersCerr.push_back(t); }
|
||||
virtual void ResetTransformers();
|
||||
|
||||
// The type of the functions defining a transformation of the message.
|
||||
// The function manipulates the input message, for example, to add a prefix:
|
||||
// G4coutDestination::AddCoutTransformer(
|
||||
// [](G4String& msg) -> G4bool { msg="PREFIX "+msg; return true; }
|
||||
// );
|
||||
// Function should return false if message should not be processed
|
||||
// anymore and discarded
|
||||
//
|
||||
using Transformer=std::function<G4bool(G4String&)>;
|
||||
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); }
|
||||
void AddCerrTransformer( Transformer&& t)
|
||||
{ transformersCerr.push_back(t); }
|
||||
virtual void ResetTransformers();
|
||||
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
|
||||
|
||||
// Derived class implements here handling of message.
|
||||
// For example, streaming on std::cout or file.
|
||||
// Return 0 for success, -1 otherwise
|
||||
//
|
||||
virtual G4int ReceiveG4cout(const G4String& msg);
|
||||
virtual G4int ReceiveG4cerr(const G4String& msg);
|
||||
G4int ReceiveG4cout_(const G4String& msg);
|
||||
// Method called by G4strbuf when need to handle a message
|
||||
|
||||
// Methods called by G4strbuf when need to handle a message
|
||||
//
|
||||
G4int ReceiveG4cout_(const G4String& msg);
|
||||
G4int ReceiveG4cerr_(const G4String& msg);
|
||||
// Transformers cannot remove an error message from stream
|
||||
|
||||
// Transformers cannot remove an error message from stream
|
||||
//
|
||||
G4int ReceiveG4cerr_(const G4String& msg);
|
||||
protected:
|
||||
G4coutDestination* masterG4coutDestination = nullptr;
|
||||
// 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
|
||||
|
||||
protected:
|
||||
|
||||
// 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
|
||||
//
|
||||
G4coutDestination* masterG4coutDestination = nullptr;
|
||||
|
||||
std::vector<Transformer> transformersCout;
|
||||
std::vector<Transformer> transformersCerr;
|
||||
std::vector<Transformer> transformersCout;
|
||||
std::vector<Transformer> transformersCerr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user