Geant4 11.1.1
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)
 
 G4HnMessenger ()=delete
 
 ~G4HnMessenger () override
 
void SetNewValue (G4UIcommand *command, G4String value) final
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 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 (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 45 of file G4HnMessenger.hh.

Constructor & Destructor Documentation

◆ G4HnMessenger() [1/2]

G4HnMessenger::G4HnMessenger ( G4HnManager manager)
explicit

Definition at line 38 of file G4HnMessenger.cc.

39 : fManager(manager),
40 fHnType(manager.GetHnType())
41{
42 SetHnAsciiCmd();
43 SetHnActivationCmd();
44 SetHnActivationToAllCmd();
45 SetHnPlottingCmd();
46 SetHnPlottingToAllCmd();
47 SetHnFileNameCmd();
48 SetHnFileNameToAllCmd();
49}
G4String GetHnType() const
Definition: G4HnManager.hh:149

◆ G4HnMessenger() [2/2]

G4HnMessenger::G4HnMessenger ( )
delete

◆ ~G4HnMessenger()

G4HnMessenger::~G4HnMessenger ( )
overridedefault

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 162 of file G4HnMessenger.cc.

163{
164 // process "All" commands first
165 if ( command == fSetActivationAllCmd.get() ) {
166 fManager.SetActivation(fSetActivationAllCmd->GetNewBoolValue(newValues));
167 return;
168 }
169
170 if ( command == fSetPlottingAllCmd.get() ) {
171 fManager.SetPlotting(fSetPlottingAllCmd->GetNewBoolValue(newValues));
172 return;
173 }
174
175 if ( command == fSetFileNameAllCmd.get() ) {
176 fManager.SetFileName(newValues);
177 return;
178 }
179
180 // Tokenize parameters in a vector
181 std::vector<G4String> parameters;
182 G4Analysis::Tokenize(newValues, parameters);
183 // check consistency
184 if ( parameters.size() != command->GetParameterEntries() ) {
185 // Should never happen but let's check anyway for consistency
187 "Got wrong number of \"" + command->GetCommandName() +
188 "\" parameters: " + std::to_string(parameters.size()) +
189 " instead of " + std::to_string(command->GetParameterEntries()) + " expected",
190 fkClass, "WarnAboutParameters");
191 return;
192 }
193
194 auto counter = 0;
195 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
196
197 if ( command == fSetAsciiCmd.get() ) {
198 fManager.SetAscii(id, G4UIcommand::ConvertToBool(parameters[counter++]));
199 return;
200 }
201
202 if ( command == fSetActivationCmd.get() ) {
203 fManager.SetActivation(id, G4UIcommand::ConvertToBool(parameters[counter++]));
204 return;
205 }
206
207 if ( command == fSetPlottingCmd.get() ) {
208 fManager.SetPlotting(id, G4UIcommand::ConvertToBool(parameters[counter++]));
209 return;
210 }
211
212 if ( command == fSetFileNameCmd.get() ) {
213 fManager.SetFileName(id, parameters[counter++]);
214 return;
215 }
216}
void SetActivation(G4bool activation)
Definition: G4HnManager.cc:204
void SetFileName(G4int id, const G4String &fileName)
Definition: G4HnManager.cc:258
void SetAscii(G4int id, G4bool ascii)
Definition: G4HnManager.cc:218
void SetPlotting(G4int id, G4bool plotting)
Definition: G4HnManager.cc:238
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:139
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:561
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:549
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:138
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

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