Geant4 11.4.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)
 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)
G4bool CommandsShouldBeInMaster () const

Additional Inherited Members

Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
G4String LtoS (G4long l)
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 (const 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 41 of file G4HnMessenger.cc.

42 : fManager(manager),
43 fHnType(manager.GetHnType()),
44 fHnDimension(std::stoi(manager.GetHnType().substr(1,1)))
45{
46 SetHnAsciiCmd();
47 SetHnActivationCmd();
48 SetHnActivationToAllCmd();
49 SetHnPlottingCmd();
50 SetHnPlottingToAllCmd();
51 SetHnFileNameCmd();
52 SetHnFileNameToAllCmd();
53
54 auto maxDim = (fHnDimension < kMaxDim) ? fHnDimension + 1 : kMaxDim;
55 for (unsigned int idim = 0; idim < maxDim; ++idim) {
56 fSetAxisLogCmd.push_back(CreateSetAxisLogCommand(idim));
57 }
58}
G4String GetHnType() const
constexpr unsigned int kMaxDim

◆ 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 195 of file G4HnMessenger.cc.

196{
197 // process "All" commands first
198 if ( command == fSetActivationAllCmd.get() ) {
199 fManager.SetActivation(fSetActivationAllCmd->GetNewBoolValue(newValues));
200 return;
201 }
202
203 if ( command == fSetPlottingAllCmd.get() ) {
204 fManager.SetPlotting(fSetPlottingAllCmd->GetNewBoolValue(newValues));
205 return;
206 }
207
208 if ( command == fSetFileNameAllCmd.get() ) {
209 fManager.SetFileName(newValues);
210 return;
211 }
212
213 // Tokenize parameters in a vector
214 std::vector<G4String> parameters;
215 G4Analysis::Tokenize(newValues, parameters);
216 // check consistency
217 if ( parameters.size() != command->GetParameterEntries() ) {
218 // Should never happen but let's check anyway for consistency
220 "Got wrong number of \"" + command->GetCommandName() +
221 "\" parameters: " + std::to_string(parameters.size()) +
222 " instead of " + std::to_string(command->GetParameterEntries()) + " expected",
223 fkClass, "WarnAboutParameters");
224 return;
225 }
226
227 auto counter = 0;
228 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
229
230 if ( command == fSetAsciiCmd.get() ) {
231 fManager.SetAscii(id, G4UIcommand::ConvertToBool(parameters[counter++]));
232 return;
233 }
234
235 if ( command == fSetActivationCmd.get() ) {
236 fManager.SetActivation(id, G4UIcommand::ConvertToBool(parameters[counter++]));
237 return;
238 }
239
240 if ( command == fSetPlottingCmd.get() ) {
241 fManager.SetPlotting(id, G4UIcommand::ConvertToBool(parameters[counter++]));
242 return;
243 }
244
245 if ( command == fSetFileNameCmd.get() ) {
246 fManager.SetFileName(id, parameters[counter++]);
247 return;
248 }
249
250 auto maxDim = (fHnDimension < kMaxDim) ? fHnDimension + 1 : kMaxDim;
251 for (unsigned int idim = 0; idim < maxDim; ++idim) {
252 if ( command == fSetAxisLogCmd[idim].get() ) {
253 auto axisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
254 fManager.SetAxisIsLog(idim, id, axisLog);
255 return;
256 }
257 }
258}
std::size_t GetParameterEntries() const
static G4int ConvertToInt(const char *st)
static G4bool ConvertToBool(const char *st)
const G4String & GetCommandName() const
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
std::string to_string(G4FermiAtomicMass mass)

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