//////////////////////////////////////////////////////////////////// // // Stream redirection for GEANT4 output. // // This file provides utilities for redirecting GEANT4's G4cout and // G4cerr streams into others. This is useful for capturing G4 output // into the RAT logging facilities or silencing G4 altogether. Available // output streams are: // // 0 G4Stream::DEFAULT The default stream (G4cout or G4cerr) // 1 G4Stream::WARN RAT's "warn" stream // 2 G4Stream::INFO RAT's "info" stream // 3 G4Stream::DETAIL RAT's "detail" stream // 4 G4Stream::DEBUG RAT's "debug" stream // 6 G4Stream::DISABLE Throw away this stream's output // // Note that this is outside the RAT namespace, defines no G4Stream // class, and is not a G4 class despite the suggestive name. // // Author: A. Mastbaum - contact person // //////////////////////////////////////////////////////////////////// #include #include #include struct G4Stream { enum { DEFAULT, // the stream's usual buffer WARN, // RAT::warn INFO, // RAT::info DETAIL, // RAT::detail DEBUG, // RAT::debug DISABLE // stream turned off }; }; class otext_streambuf : public std::streambuf { public: otext_streambuf(otext *_out) { out = _out; }; virtual int_type overflow (int_type c) { if (c != EOF) { (*out) << (char) c; } return c; }; protected: otext *out; }; class discard_streambuf : public std::streambuf { public: discard_streambuf() { }; virtual int_type overflow(int_type c) { // Do nothing with this character return c; }; }; void SetG4coutStream(int i); void SetG4cerrStream(int i);