#include <G4GenericMessenger.hh>
|
| G4GenericMessenger (void *obj, const G4String &dir="", const G4String &doc="") |
|
| ~G4GenericMessenger () override |
|
G4String | GetCurrentValue (G4UIcommand *command) override |
|
void | SetNewValue (G4UIcommand *command, G4String newValue) override |
|
Command & | DeclareProperty (const G4String &name, const G4AnyType &variable, const G4String &doc="") |
|
Command & | DeclarePropertyWithUnit (const G4String &name, const G4String &defaultUnit, const G4AnyType &variable, const G4String &doc="") |
|
Command & | DeclareMethod (const G4String &name, const G4AnyMethod &fun, const G4String &doc="") |
|
Command & | DeclareMethodWithUnit (const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="") |
|
void | SetDirectory (const G4String &dir) |
|
void | SetGuidance (const G4String &s) |
|
void | Sort (G4bool val=true) |
|
| 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 |
|
Definition at line 48 of file G4GenericMessenger.hh.
◆ G4GenericMessenger()
G4GenericMessenger::G4GenericMessenger |
( |
void * |
obj, |
|
|
const G4String & |
dir = "" , |
|
|
const G4String & |
doc = "" |
|
) |
| |
Definition at line 62 of file G4GenericMessenger.cc.
64 : directory(dir)
65 , object(obj)
66{
69}
void SetGuidance(const char *aGuidance)
◆ ~G4GenericMessenger()
G4GenericMessenger::~G4GenericMessenger |
( |
| ) |
|
|
override |
Definition at line 71 of file G4GenericMessenger.cc.
72{
73 delete dircmd;
74 for(const auto& propertie : properties)
75 {
76 delete propertie.second.command;
77 }
78 for(const auto& method : methods)
79 {
80 delete method.second.command;
81 }
82}
◆ DeclareMethod()
Definition at line 151 of file G4GenericMessenger.cc.
153{
155 auto* cmd =
new G4UIcommand(fullpath.c_str(),
this);
156 if(!doc.empty())
157 {
158 cmd->SetGuidance(doc);
159 }
160 for(std::size_t i = 0; i < fun.
NArg(); ++i)
161 {
163 char ptype = 's';
165 if(tInfo == typeid(int) || tInfo == typeid(long) ||
166 tInfo == typeid(unsigned int) ||
167 tInfo == typeid(unsigned long))
168 { ptype = 'i'; }
169 else if(tInfo == typeid(float) || tInfo == typeid(double))
170 { ptype = 'd'; }
171 else if(tInfo == typeid(bool))
172 { ptype = 'b'; }
174 { ptype = 's'; }
175 else
176 { ptype = 's'; }
178 }
179 return methods[
name] = Method(fun,
object, cmd);
180}
const std::type_info & ArgType(size_t n=0) const
const char * name(G4int ptype)
◆ DeclareMethodWithUnit()
Definition at line 182 of file G4GenericMessenger.cc.
185{
188 {
190 ed << "G4GenericMessenger::DeclareMethodWithUnit() does not support a "
191 "method that has more than\n"
192 << "one arguments (or no argument). Please use "
193 "G4GenericMessenger::DeclareMethod method for\n"
194 << "your command <" << fullpath << ">.";
195 G4Exception(
"G4GenericMessenger::DeclareMethodWithUnit()",
"Intercom70002",
197 }
200 ->SetParameterName("value", false, false);
202 if(!doc.empty())
203 {
205 }
206 return methods[
name] = Method(fun,
object, cmd);
207}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
◆ DeclareProperty()
Definition at line 84 of file G4GenericMessenger.cc.
86{
90 {
93 ->SetParameterName("valueX", "valueY", "valueZ", false, false);
94 }
95 else
96 {
98 char ptype;
99 if(var.TypeInfo() == typeid(int) || var.TypeInfo() == typeid(long) ||
100 var.TypeInfo() == typeid(unsigned int) ||
101 var.TypeInfo() == typeid(unsigned long))
102 { ptype = 'i'; }
103 else if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
104 { ptype = 'd'; }
105 else if(var.TypeInfo() == typeid(bool))
106 { ptype = 'b'; }
107 else if(var.TypeInfo() ==
typeid(
G4String))
108 { ptype = 's'; }
109 else
110 { ptype = 's'; }
112 }
113 if(!doc.empty())
115 return properties[
name] = Property(var, cmd);
116}
void SetParameter(G4UIparameter *const newParameter)
Referenced by DeclarePropertyWithUnit(), and G4SteppingVerboseWithUnits::SetManager().
◆ DeclarePropertyWithUnit()
Definition at line 118 of file G4GenericMessenger.cc.
121{
122 if(var.TypeInfo() != typeid(float) && var.TypeInfo() != typeid(double) &&
124 {
126 }
129 if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
130 {
133 ->SetParameterName("value", false, false);
135 }
136 else
137 {
140 ->SetParameterName("valueX", "valueY", "valueZ", false, false);
142 }
143
144 if(!doc.empty())
145 {
147 }
148 return properties[
name] = Property(var, cmd);
149}
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
◆ GetCurrentValue()
Reimplemented from G4UImessenger.
Definition at line 209 of file G4GenericMessenger.cc.
210{
211 if(properties.find(command->
GetCommandName()) != properties.cend())
212 {
214 return p.variable.ToString();
215 }
216 else if(methods.find(command->
GetCommandName()) != methods.cend())
217 {
218 G4cout <<
" GetCurrentValue() is not available for a command defined by "
219 "G4GenericMessenger::DeclareMethod()."
222 }
223 else
224 {
226 }
227}
G4GLOB_DLL std::ostream G4cout
const G4String & GetCommandName() const
◆ SetDirectory()
void G4GenericMessenger::SetDirectory |
( |
const G4String & |
dir | ) |
|
|
inline |
◆ SetGuidance()
void G4GenericMessenger::SetGuidance |
( |
const G4String & |
s | ) |
|
◆ SetNewValue()
Reimplemented from G4UImessenger.
Definition at line 229 of file G4GenericMessenger.cc.
230{
231
233 {
236 }
238 {
241 }
242
243 if(properties.find(command->
GetCommandName()) != properties.cend())
244 {
246 p.variable.FromString(newValue);
247 }
248 else if(methods.find(command->
GetCommandName()) != methods.cend())
249 {
251 if(m.method.NArg() == 0)
252 {
253 m.method.operator()(m.object);
254 }
255 else if(m.method.NArg() > 0)
256 {
257 m.method.operator()(m.object, newValue);
258 }
259 else
260 {
262 }
263 }
264}
static G4String ConvertToString(G4bool boolVal)
static G4double ConvertToDimensionedDouble(const char *st)
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
◆ Sort()
void G4GenericMessenger::Sort |
( |
G4bool |
val = true | ) |
|
|
inline |
Definition at line 195 of file G4GenericMessenger.hh.
196 {
197 if(dircmd != nullptr)
198 {
200 }
201 }
void Sort(G4bool val=true)
The documentation for this class was generated from the following files: