Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4LocalThreadCoutMessenger 27 // 28 // Author: M.Asai, 2013 29 // ------------------------------------------- 30 31 #include "G4LocalThreadCoutMessenger.hh" 32 33 #include "G4Tokenizer.hh" 34 #include "G4UIcmdWithABool.hh" 35 #include "G4UIcmdWithAString.hh" 36 #include "G4UIcmdWithAnInteger.hh" 37 #include "G4UIcommand.hh" 38 #include "G4UIdirectory.hh" 39 #include "G4UImanager.hh" 40 #include "G4UIparameter.hh" 41 42 // ------------------------------------------- 43 G4LocalThreadCoutMessenger::G4LocalThreadCoutM 44 { 45 coutDir = new G4UIdirectory("/control/cout/" 46 coutDir->SetGuidance("Control cout/cerr for 47 48 coutFileNameCmd = new G4UIcommand("/control/ 49 coutFileNameCmd->SetGuidance("Send G4cout st 50 coutFileNameCmd->SetGuidance("To have a disp 51 coutFileNameCmd->SetGuidance("If append flag 52 coutFileNameCmd->SetGuidance("otherwise file 53 coutFileNameCmd->AvailableForStates(G4State_ 54 auto* pp = new G4UIparameter("fileName", 's' 55 pp->SetDefaultValue("**Screen**"); 56 coutFileNameCmd->SetParameter(pp); 57 pp = new G4UIparameter("append", 'b', true); 58 pp->SetDefaultValue(1); 59 coutFileNameCmd->SetParameter(pp); 60 61 cerrFileNameCmd = new G4UIcommand("/control/ 62 cerrFileNameCmd->SetGuidance("Send G4cerr st 63 cerrFileNameCmd->SetGuidance("To have a disp 64 cerrFileNameCmd->SetGuidance("If append flag 65 cerrFileNameCmd->SetGuidance("otherwise file 66 cerrFileNameCmd->AvailableForStates(G4State_ 67 pp = new G4UIparameter("fileName", 's', true 68 pp->SetDefaultValue("**Screen**"); 69 cerrFileNameCmd->SetParameter(pp); 70 pp = new G4UIparameter("append", 'b', true); 71 pp->SetDefaultValue(1); 72 cerrFileNameCmd->SetParameter(pp); 73 74 bufferCoutCmd = new G4UIcmdWithABool("/contr 75 bufferCoutCmd->SetGuidance("Send cout and/or 76 bufferCoutCmd->SetGuidance("The buffered tex 77 bufferCoutCmd->SetGuidance( 78 "for each thread at a time, so that output 79 bufferCoutCmd->SetGuidance("This command has 80 bufferCoutCmd->SetParameterName("flag", true 81 bufferCoutCmd->SetDefaultValue(true); 82 bufferCoutCmd->AvailableForStates(G4State_Pr 83 84 prefixCmd = new G4UIcmdWithAString("/control 85 prefixCmd->SetGuidance("Set the prefix strin 86 prefixCmd->SetParameterName("prefix", true); 87 prefixCmd->SetDefaultValue("G4WT"); 88 prefixCmd->AvailableForStates(G4State_PreIni 89 90 ignoreCmd = new G4UIcmdWithAnInteger("/contr 91 ignoreCmd->SetGuidance("Omit cout from threa 92 ignoreCmd->SetGuidance( 93 "This command takes effect only if cout de 94 "is screen without buffering."); 95 ignoreCmd->SetGuidance("If specified thread 96 ignoreCmd->SetGuidance("no cout is displayed 97 ignoreCmd->SetGuidance("This command does no 98 ignoreCmd->SetParameterName("threadID", true 99 ignoreCmd->SetDefaultValue(0); 100 ignoreCmd->AvailableForStates(G4State_PreIni 101 102 ignoreInitCmd = new G4UIcmdWithABool("/contr 103 ignoreInitCmd->SetGuidance( 104 "Omit cout from threads during initializat 105 "they should be identical to the master th 106 ignoreInitCmd->SetGuidance( 107 "This command takes effect only if cout " 108 "destination is screen without buffering." 109 ignoreInitCmd->SetGuidance("This command doe 110 ignoreInitCmd->SetParameterName("IgnoreInit" 111 ignoreInitCmd->SetDefaultValue(true); 112 ignoreInitCmd->AvailableForStates(G4State_Pr 113 } 114 115 // ------------------------------------------- 116 G4LocalThreadCoutMessenger::~G4LocalThreadCout 117 { 118 delete coutFileNameCmd; 119 delete cerrFileNameCmd; 120 delete bufferCoutCmd; 121 delete prefixCmd; 122 delete ignoreCmd; 123 delete ignoreInitCmd; 124 delete coutDir; 125 } 126 127 // ------------------------------------------- 128 void G4LocalThreadCoutMessenger::SetNewValue(G 129 { 130 G4UImanager* UI = G4UImanager::GetUIpointer( 131 if (command == coutFileNameCmd) { 132 G4Tokenizer next(newVal); 133 G4String fn = next(); 134 G4bool af = StoB(next()); 135 UI->SetCoutFileName(fn, af); 136 } 137 else if (command == cerrFileNameCmd) { 138 G4Tokenizer next(newVal); 139 G4String fn = next(); 140 G4bool af = StoB(next()); 141 UI->SetCerrFileName(fn, af); 142 } 143 else if (command == bufferCoutCmd) { 144 UI->SetThreadUseBuffer(StoB(newVal)); 145 } 146 else if (command == prefixCmd) { 147 UI->SetThreadPrefixString(newVal); 148 } 149 else if (command == ignoreCmd) { 150 UI->SetThreadIgnore(StoI(newVal)); 151 } 152 else if (command == ignoreInitCmd) { 153 UI->SetThreadIgnoreInit(StoB(newVal)); 154 } 155 } 156