57 virtual const char*
what()
const throw()
59 return "G4InvalidUICommand: command does not exist or is of invalid type";
76 delete i->second.command;
78 delete i->second.command;
90 ->SetParameterName(
"valueX",
"valueY",
"valueZ",
false,
false);
97 var.
TypeInfo() ==
typeid(
unsigned int) ||
98 var.
TypeInfo() ==
typeid(
unsigned long))
100 else if(var.
TypeInfo() ==
typeid(
float) || var.
TypeInfo() ==
typeid(
double))
102 else if(var.
TypeInfo() ==
typeid(
bool))
130 ->SetParameterName(
"value",
false,
false);
137 ->SetParameterName(
"valueX",
"valueY",
"valueZ",
false,
false);
153 for(std::size_t i = 0; i < fun.
NArg(); ++i)
158 if(tInfo ==
typeid(
int) || tInfo ==
typeid(
long) ||
159 tInfo ==
typeid(
unsigned int) ||
160 tInfo ==
typeid(
unsigned long))
162 else if(tInfo ==
typeid(
float) || tInfo ==
typeid(
double))
164 else if(tInfo ==
typeid(
bool))
183 ed <<
"G4GenericMessenger::DeclareMethodWithUnit() does not support a "
184 "method that has more than\n"
185 <<
"one arguments (or no argument). Please use "
186 "G4GenericMessenger::DeclareMethod method for\n"
187 <<
"your command <" << fullpath <<
">.";
188 G4Exception(
"G4GenericMessenger::DeclareMethodWithUnit()",
"Intercom70002",
193 ->SetParameterName(
"value",
false,
false);
209 G4cout <<
" GetCurrentValue() is not available for a command defined by "
210 "G4GenericMessenger::DeclareMethod()."
242 if(
m.method.NArg() == 0)
243 m.method.operator()(
m.object);
244 else if(
m.method.NArg() > 0)
246 m.method.operator()(
m.object, newValue);
270 ed <<
"G4GenericMessenger::Command::SetUnit() is thread-unsafe and should "
272 <<
"in multi-threaded mode. For your command <" << cmdpath <<
">, use\n"
273 <<
" DeclarePropertyWithUnit(const G4String& name, const G4String& "
275 <<
" const G4AnyType& variable, const G4String& "
278 <<
" DeclareMethodWithUnit(const G4String& name, const G4String& "
280 <<
" const G4AnyType& variable, const G4String& "
282 <<
"to define a command with a unit <" << unit <<
">.";
285 ed <<
"\nPlease use a default unit instead of unit category.";
287 G4Exception(
"G4GenericMessenger::Command::SetUnit()",
"Intercom70001",
295 std::vector<G4String> guidance;
302 G4UIcommand tmp((cmdpath +
"_tmp").c_str(), messenger);
305 if(*
type ==
typeid(
float) || *
type ==
typeid(
double))
328 G4cerr <<
"Only parameters of type <double> or <float> can be associated "
333 for(std::size_t i = 0; i < guidance.size(); ++i)
342 return SetParameterName(0,
name,omittable,currentAsDefault);
349 if(pIdx < 0 || pIdx >= (
G4int)(command->GetParameterEntries()))
351 G4cerr <<
"Invalid parameter index : " << pIdx <<
"\nMethod ignored."
368 G4cerr <<
"This SetParameterName method is for G4ThreeVector!! "
369 <<
"Method ignored." <<
G4endl;
376 theParam = command->GetParameter(1);
380 theParam = command->GetParameter(2);
390 return SetCandidates(0,candList);
396 if(pIdx < 0 || pIdx >= (
G4int)(command->GetParameterEntries()))
398 G4cerr <<
"Invalid parameter index : " << pIdx <<
"\nMethod ignored."
410 return SetDefaultValue(0,defVal);
416 if(pIdx < 0 || pIdx >= (
G4int)(command->GetParameterEntries()))
418 G4cerr <<
"Invalid parameter index : " << pIdx <<
"\nMethod ignored."
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
static constexpr double m
static constexpr double s
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
const std::type_info & ArgType(size_t n=0) const
void FromString(const std::string &val)
const std::type_info & TypeInfo() const
std::string ToString() const
Command & DeclareMethod(const G4String &name, const G4AnyMethod &fun, const G4String &doc="")
void SetGuidance(const G4String &s)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
Command & DeclareProperty(const G4String &name, const G4AnyType &variable, const G4String &doc="")
virtual G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4GenericMessenger()
Command & DeclareMethodWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyMethod &fun, const G4String &doc="")
G4GenericMessenger(void *obj, const G4String &dir="", const G4String &doc="")
std::map< G4String, Method > methods
Command & DeclarePropertyWithUnit(const G4String &name, const G4String &defaultUnit, const G4AnyType &variable, const G4String &doc="")
std::map< G4String, Property > properties
virtual const char * what() const
void SetDefaultUnit(const char *defUnit)
void SetUnitCategory(const char *unitCategory)
void SetUnitCategory(const char *unitCategory)
void SetDefaultUnit(const char *defUnit)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UImessenger * GetMessenger() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
static G4String ConvertToString(G4bool boolVal)
const G4String & GetCommandPath() const
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
std::size_t GetGuidanceEntries() const
void SetRange(const char *rs)
static G4double ConvertToDimensionedDouble(const char *st)
const G4String & GetCommandName() const
const G4String & GetRange() const
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterName(const char *pName)
G4bool IsOmittable() const
void SetOmittable(G4bool om)
void SetParameterCandidates(const char *theString)
void SetCurrentAsDefault(G4bool val)
const G4String & GetParameterName() const
const char * name(G4int ptype)
G4bool IsMultithreadedApplication()
Command & SetParameterName(const G4String &, G4bool, G4bool=false)
Command & SetCandidates(const G4String &)
Command & SetDefaultValue(const G4String &)
const std::type_info * type
Command & SetUnit(const G4String &, UnitSpec=UnitDefault)