Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HnMessenger Class Reference

#include <G4HnMessenger.hh>

+ Inheritance diagram for G4HnMessenger:

Public Member Functions

 G4HnMessenger (G4HnManager &manager)
 
virtual ~G4HnMessenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 47 of file G4HnMessenger.hh.

Constructor & Destructor Documentation

◆ G4HnMessenger()

G4HnMessenger::G4HnMessenger ( G4HnManager manager)
explicit

Definition at line 44 of file G4HnMessenger.cc.

45 : G4UImessenger(),
46 fManager(manager),
47 fHelper(nullptr),
48 fSetHnAsciiCmd(nullptr),
49 fSetHnActivationCmd(nullptr),
50 fSetHnActivationAllCmd(nullptr),
51 fSetHnPlottingCmd(nullptr),
52 fSetHnPlottingAllCmd(nullptr),
53 fSetHnFileNameCmd(nullptr),
54 fSetHnFileNameAllCmd(nullptr)
55{
56 G4String hnType = fManager.GetHnType();
57 hnType.toLower();
58 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(hnType);
59
60 SetHnAsciiCmd();
61 SetHnActivationCmd();
62 SetHnActivationToAllCmd();
63 SetHnPlottingCmd();
64 SetHnPlottingToAllCmd();
65 SetHnFileNameCmd();
66 SetHnFileNameToAllCmd();
67}
G4String GetHnType() const
Definition: G4HnManager.hh:140
void toLower()

◆ ~G4HnMessenger()

G4HnMessenger::~G4HnMessenger ( )
virtual

Definition at line 70 of file G4HnMessenger.cc.

71{}

Member Function Documentation

◆ SetNewValue()

void G4HnMessenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
finalvirtual

Reimplemented from G4UImessenger.

Definition at line 185 of file G4HnMessenger.cc.

186{
187 if ( command == fSetHnAsciiCmd.get() ) {
188 auto id = fSetHnAsciiCmd->GetNewIntValue(newValues);
189 fManager.SetAscii(id, true);
190 }
191 else if ( command == fSetHnActivationCmd.get() ) {
192 // tokenize parameters in a vector
193 std::vector<G4String> parameters;
194 G4Analysis::Tokenize(newValues, parameters);
195 // check consistency
196 if ( parameters.size() == command->GetParameterEntries() ) {
197 auto counter = 0;
198 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
199 auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
200 fManager.SetActivation(id, activation);
201 }
202 else {
203 // Should never happen but let's check anyway for consistency
204 fHelper->WarnAboutParameters(command, parameters.size());
205 }
206 }
207 else if ( command == fSetHnActivationAllCmd.get() ) {
208 auto activation = fSetHnActivationAllCmd->GetNewBoolValue(newValues);
209 fManager.SetActivation(activation);
210 }
211 else if ( command == fSetHnPlottingCmd.get() ) {
212 // tokenize parameters in a vector
213 std::vector<G4String> parameters;
214 G4Analysis::Tokenize(newValues, parameters);
215 // check consistency
216 if ( parameters.size() == command->GetParameterEntries() ) {
217 auto counter = 0;
218 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
219 auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
220 fManager.SetPlotting(id, activation);
221 }
222 else {
223 // Should never happen but let's check anyway for consistency
224 fHelper->WarnAboutParameters(command, parameters.size());
225 }
226 }
227 else if ( command == fSetHnPlottingAllCmd.get() ) {
228 auto activation = fSetHnPlottingAllCmd->GetNewBoolValue(newValues);
229 fManager.SetPlotting(activation);
230 }
231 else if ( command == fSetHnFileNameCmd.get() ) {
232 // tokenize parameters in a vector
233 std::vector<G4String> parameters;
234 G4Analysis::Tokenize(newValues, parameters);
235 // check consistency
236 if ( parameters.size() == command->GetParameterEntries() ) {
237 auto counter = 0;
238 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
239 auto fileName = parameters[counter++];
240 fManager.SetFileName(id, fileName);
241 }
242 else {
243 // Should never happen but let's check anyway for consistency
244 fHelper->WarnAboutParameters(command, parameters.size());
245 }
246 }
247 else if ( command == fSetHnFileNameAllCmd.get() ) {
248 auto fileName = newValues;
249 fManager.SetFileName(fileName);
250 }
251}
void SetActivation(G4bool activation)
Definition: G4HnManager.cc:202
void SetFileName(G4int id, const G4String &fileName)
Definition: G4HnManager.cc:254
void SetAscii(G4int id, G4bool ascii)
Definition: G4HnManager.cc:216
void SetPlotting(G4int id, G4bool plotting)
Definition: G4HnManager.cc:234
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:543
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:530
void Tokenize(const G4String &line, std::vector< G4String > &tokens)

The documentation for this class was generated from the following files: