#include <G4GenericMessenger.hh>
|
| G4GenericMessenger (void *obj, const G4String &dir="", const G4String &doc="") |
|
virtual | ~G4GenericMessenger () |
|
virtual G4String | GetCurrentValue (G4UIcommand *command) |
|
virtual void | SetNewValue (G4UIcommand *command, G4String newValue) |
|
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) |
|
| 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 |
|
Definition at line 48 of file G4GenericMessenger.hh.
◆ G4GenericMessenger()
G4GenericMessenger::G4GenericMessenger |
( |
void * |
obj, |
|
|
const G4String & |
dir = "" , |
|
|
const G4String & |
doc = "" |
|
) |
| |
Definition at line 52 of file G4GenericMessenger.cc.
54 : directory(dir)
55 , object(obj)
56{
57
58
59
60 std::size_t
pos = dir.find_last_of(
'/', dir.size() - 2);
61 while(pos != 0 && pos != std::string::npos)
62 {
65 guidance += dir.substr(1, pos - 1);
67 pos = dir.find_last_of(
'/', pos - 1);
68 }
71}
void SetGuidance(const char *aGuidance)
◆ ~G4GenericMessenger()
G4GenericMessenger::~G4GenericMessenger |
( |
| ) |
|
|
virtual |
Definition at line 73 of file G4GenericMessenger.cc.
74{
75 delete dircmd;
76 for(auto i = properties.cbegin(); i != properties.cend(); ++i)
77 delete i->second.command;
78 for(auto i = methods.cbegin(); i != methods.cend(); ++i)
79 delete i->second.command;
80}
◆ DeclareMethod()
Definition at line 137 of file G4GenericMessenger.cc.
139{
142 if(doc != "")
144 for(std::size_t i = 0; i < fun.
NArg(); ++i)
145 {
147 }
148 return methods[
name] = Method(fun,
object, cmd);
149}
void SetParameter(G4UIparameter *const newParameter)
const char * name(G4int ptype)
◆ DeclareMethodWithUnit()
Definition at line 151 of file G4GenericMessenger.cc.
154{
157 {
159 ed << "G4GenericMessenger::DeclareMethodWithUnit() does not support a "
160 "method that has more than\n"
161 << "one arguments (or no argument). Please use "
162 "G4GenericMessenger::DeclareMethod method for\n"
163 << "your command <" << fullpath << ">.";
164 G4Exception(
"G4GenericMessenger::DeclareMethodWithUnit()",
"Intercom70002",
166 }
169 ->SetParameterName("value", false, false);
171 if(doc != "")
173 return methods[
name] = Method(fun,
object, cmd);
174}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
◆ DeclareProperty()
Definition at line 82 of file G4GenericMessenger.cc.
84{
87 if(doc != "")
89 char ptype;
90 if(var.TypeInfo() == typeid(int) || var.TypeInfo() == typeid(long) ||
91 var.TypeInfo() == typeid(unsigned int) ||
92 var.TypeInfo() == typeid(unsigned long))
93 ptype = 'i';
94 else if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
95 ptype = 'd';
96 else if(var.TypeInfo() == typeid(bool))
97 ptype = 'b';
98 else if(var.TypeInfo() ==
typeid(
G4String))
99 ptype = 's';
100 else
101 ptype = 's';
103 return properties[
name] = Property(var, cmd);
104}
Referenced by DeclarePropertyWithUnit().
◆ DeclarePropertyWithUnit()
Definition at line 106 of file G4GenericMessenger.cc.
109{
110 if(var.TypeInfo() != typeid(float) && var.TypeInfo() != typeid(double) &&
112 {
114 }
117 if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
118 {
121 ->SetParameterName("value", false, false);
123 }
124 else
125 {
128 ->SetParameterName("valueX", "valueY", "valueZ", false, false);
130 }
131
132 if(doc != "")
134 return properties[
name] = Property(var, cmd);
135}
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
◆ GetCurrentValue()
Reimplemented from G4UImessenger.
Definition at line 176 of file G4GenericMessenger.cc.
177{
178 if(properties.find(command->
GetCommandName()) != properties.cend())
179 {
181 return p.variable.ToString();
182 }
183 else if(methods.find(command->
GetCommandName()) != methods.cend())
184 {
185 G4cout <<
" GetCurrentValue() is not available for a command defined by "
186 "G4GenericMessenger::DeclareMethod()."
189 }
190 else
191 {
193 }
194}
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 196 of file G4GenericMessenger.cc.
197{
198
200 {
203 }
205 {
208 }
209
210 if(properties.find(command->
GetCommandName()) != properties.cend())
211 {
213 p.variable.FromString(newValue);
214 }
215 else if(methods.find(command->
GetCommandName()) != methods.cend())
216 {
218 if(m.method.NArg() == 0)
219 m.method.operator()(m.object);
220 else if(m.method.NArg() > 0)
221 {
222 m.method.operator()(m.object, newValue);
223 }
224 else
225 {
227 }
228 }
229}
static G4String ConvertToString(G4bool boolVal)
static G4double ConvertToDimensionedDouble(const char *st)
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
The documentation for this class was generated from the following files: