Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GenericMessenger::Command Struct Reference

#include <G4GenericMessenger.hh>

+ Inheritance diagram for G4GenericMessenger::Command:

Public Types

enum  UnitSpec { UnitCategory , UnitDefault }
 

Public Member Functions

 Command (G4UIcommand *cmd, const std::type_info &ti)
 
 Command ()
 
CommandSetStates (G4ApplicationState s0)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
 
CommandSetStates (G4ApplicationState s0, G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
 
CommandSetRange (const G4String &range)
 
CommandSetGuidance (const G4String &s)
 
CommandSetUnit (const G4String &, UnitSpec=UnitDefault)
 
CommandSetUnitCategory (const G4String &u)
 
CommandSetDefaultUnit (const G4String &u)
 
CommandSetParameterName (const G4String &, G4bool, G4bool=false)
 
CommandSetDefaultValue (const G4String &)
 
CommandSetCandidates (const G4String &)
 

Public Attributes

G4UIcommandcommand
 
const std::type_info * type
 

Detailed Description

Definition at line 59 of file G4GenericMessenger.hh.

Member Enumeration Documentation

◆ UnitSpec

Constructor & Destructor Documentation

◆ Command() [1/2]

G4GenericMessenger::Command::Command ( G4UIcommand cmd,
const std::type_info &  ti 
)
inline

Definition at line 61 of file G4GenericMessenger.hh.

61: command(cmd), type(&ti) {}
const std::type_info * type

◆ Command() [2/2]

G4GenericMessenger::Command::Command ( )
inline

Definition at line 62 of file G4GenericMessenger.hh.

62: command(0), type(0) {}

Member Function Documentation

◆ SetCandidates()

G4GenericMessenger::Command & G4GenericMessenger::Command::SetCandidates ( const G4String candList)

Definition at line 182 of file G4GenericMessenger.cc.

182 {
183 G4UIparameter * theParam = command->GetParameter(0);
184 theParam->SetParameterCandidates(candList);
185 return *this;
186}
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:140
void SetParameterCandidates(const char *theString)

◆ SetDefaultUnit()

Command & G4GenericMessenger::Command::SetDefaultUnit ( const G4String u)
inline

Definition at line 73 of file G4GenericMessenger.hh.

73{return SetUnit(u, UnitDefault);}
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)

◆ SetDefaultValue()

G4GenericMessenger::Command & G4GenericMessenger::Command::SetDefaultValue ( const G4String defVal)

Definition at line 188 of file G4GenericMessenger.cc.

188 {
189 G4UIparameter * theParam = command->GetParameter(0);
190 theParam->SetDefaultValue(defVal);
191 return *this;
192}
void SetDefaultValue(const char *theDefaultValue)

◆ SetGuidance()

Command & G4GenericMessenger::Command::SetGuidance ( const G4String s)
inline

Definition at line 70 of file G4GenericMessenger.hh.

70{ command->SetGuidance(s); return *this; }
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156

◆ SetParameterName()

G4GenericMessenger::Command & G4GenericMessenger::Command::SetParameterName ( const G4String name,
G4bool  omittable,
G4bool  currentAsDefault = false 
)

Definition at line 174 of file G4GenericMessenger.cc.

174 {
175 G4UIparameter* theParam = command->GetParameter(0);
176 theParam->SetParameterName(name);
177 theParam->SetOmittable(omittable);
178 theParam->SetCurrentAsDefault(currentAsDefault);
179 return *this;
180}
void SetOmittable(G4bool om)
void SetParameterName(const char *theName)
void SetCurrentAsDefault(G4bool val)

◆ SetRange()

Command & G4GenericMessenger::Command::SetRange ( const G4String range)
inline

Definition at line 69 of file G4GenericMessenger.hh.

69{command->SetRange(range.c_str()); return *this;}
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120

◆ SetStates() [1/5]

Command & G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0)
inline

Definition at line 64 of file G4GenericMessenger.hh.

64{command->AvailableForStates(s0); return *this;}
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:219

◆ SetStates() [2/5]

Command & G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1 
)
inline

Definition at line 65 of file G4GenericMessenger.hh.

65{command->AvailableForStates(s0, s1); return *this;}

◆ SetStates() [3/5]

Command & G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2 
)
inline

Definition at line 66 of file G4GenericMessenger.hh.

66{command->AvailableForStates(s0,s1,s2); return *this;}

◆ SetStates() [4/5]

Command & G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3 
)
inline

Definition at line 67 of file G4GenericMessenger.hh.

67{command->AvailableForStates(s0,s1,s2,s3); return *this;}

◆ SetStates() [5/5]

Command & G4GenericMessenger::Command::SetStates ( G4ApplicationState  s0,
G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3,
G4ApplicationState  s4 
)
inline

Definition at line 68 of file G4GenericMessenger.hh.

68{command->AvailableForStates(s0,s1,s2,s3,s4); return *this;}

◆ SetUnit()

G4GenericMessenger::Command & G4GenericMessenger::Command::SetUnit ( const G4String unit,
UnitSpec  spec = UnitDefault 
)

Definition at line 140 of file G4GenericMessenger.cc.

140 {
141 // Change the type of command (unfortunatelly this is done a posteriory)
142 // We need to delete the old command before creating the new one and therefore we need to recover the information
143 // before the deletetion
144 G4String cmdpath = command->GetCommandPath();
145 G4UImessenger* messenger = command->GetMessenger();
146 G4String range = command->GetRange();
147 std::vector<G4String> guidance;
148 for (G4int i = 0; i < command->GetGuidanceEntries(); i++) guidance.push_back(command->GetGuidanceLine(i));
149 // Before deleting the command we need to add a fake one to avoid deleting the directory entry and with its guidance
150 G4UIcommand tmp((cmdpath+"_tmp").c_str(), messenger);
151 delete command;
152
153 if (*type == typeid(float) || *type == typeid(double) ) {
154 G4UIcmdWithADoubleAndUnit* cmd_t = new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
155 if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
156 else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
157 command = cmd_t;
158 }
159 else if (*type == typeid(G4ThreeVector)) {
160 G4UIcmdWith3VectorAndUnit* cmd_t = new G4UIcmdWith3VectorAndUnit(cmdpath, messenger);
161 if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
162 else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
163 command = cmd_t;
164 }
165 else {
166 G4cerr << "Only parameters of type <double> or <float> can be associated with units" << G4endl;
167 return *this;
168 }
169 for (size_t i = 0; i < guidance.size(); i++) command->SetGuidance(guidance[i]);
170 command->SetRange(range);
171 return *this;
172}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
void SetDefaultUnit(const char *defUnit)
void SetUnitCategory(const char *unitCategory)
void SetUnitCategory(const char *unitCategory)
void SetDefaultUnit(const char *defUnit)
G4UImessenger * GetMessenger() const
Definition: G4UIcommand.hh:144
const G4String & GetGuidanceLine(G4int i) const
Definition: G4UIcommand.hh:132
G4int GetGuidanceEntries() const
Definition: G4UIcommand.hh:130
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:134
const G4String & GetRange() const
Definition: G4UIcommand.hh:128

Referenced by SetDefaultUnit(), and SetUnitCategory().

◆ SetUnitCategory()

Command & G4GenericMessenger::Command::SetUnitCategory ( const G4String u)
inline

Definition at line 72 of file G4GenericMessenger.hh.

72{return SetUnit(u, UnitCategory);}

Member Data Documentation

◆ command

G4UIcommand* G4GenericMessenger::Command::command

Definition at line 78 of file G4GenericMessenger.hh.

Referenced by SetGuidance(), SetRange(), SetStates(), and SetUnit().

◆ type

const std::type_info* G4GenericMessenger::Command::type

Definition at line 79 of file G4GenericMessenger.hh.

Referenced by SetUnit().


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