Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:04

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4coutFormatters
0027 //
0028 // Description:
0029 //
0030 // Utilities to handle transformations of cout/cerr streams
0031 
0032 //      ---------------- G4coutFormatters ----------------
0033 //
0034 // Author: A.Dotti (SLAC), April 2017
0035 // --------------------------------------------------------------------
0036 #ifndef G4COUTFORMATTERS_HH
0037 #define G4COUTFORMATTERS_HH 1
0038 
0039 #include <algorithm>
0040 #include <ctime>
0041 #include <functional>
0042 #include <iomanip>
0043 #include <sstream>
0044 #include <unordered_map>
0045 #include <vector>
0046 
0047 #include "G4String.hh"
0048 #include "G4ios.hh"
0049 #include "G4coutDestination.hh"
0050 
0051 namespace G4coutFormatters
0052 {
0053   // Static definitions of provided formatters
0054   namespace ID
0055   {
0056     static const G4String SYSLOG  = "syslog";
0057     static const G4String DEFAULT = "default";
0058   }  // namespace ID
0059 
0060   using SetupStyle_f = std::function<G4int(G4coutDestination*)>;
0061   // A function that set ups a style for the destination
0062   // Example for a style that set to all capital the messages
0063   // to G4cerr:
0064   //  setupStyle_f myStyle = [](G4coutDestination* dest)->G4int {
0065   //            dest->SetCerrTransformer(
0066   //                         [](G4String& msg){
0067   //                            msg->toUpper();
0068   //                            return true; }
0069   //                    );
0070   //            };
0071 
0072   using String_V = std::vector<G4String>;
0073 
0074   String_V Names();
0075   // Return list of formatter names
0076 
0077   G4int HandleStyle(G4coutDestination* dest, const G4String& style);
0078   // Setup style (by name) to destination
0079 
0080   void SetMasterStyle(const G4String&);
0081   G4String GetMasterStyle();
0082   // Set/get name of the style for the master thread
0083 
0084   void SetupStyleGlobally(const G4String& news);
0085   // This function should be called in user application main function
0086   // to setup the style just after setting up RunManager
0087 
0088   void RegisterNewStyle(const G4String& name, SetupStyle_f& formatter);
0089   // To be used by user to register by name a new formatter.
0090   // So it can be used via one of the previous functions
0091 }  // namespace G4coutFormatters
0092 
0093 #endif